0

I have an Eclipse workspace that I've cloned from Git and I need a list of files that have changed in my local compared to the ones on Git master.

I don't mean using git diff, I mean using Java programmatically using possible Java/Git APIs... So eventually a list/array of files that have changed should be returned.

I've seen some resources on servers other than Git, like here: How to compare local file with Amazon s3 file

Community
  • 1
  • 1
hotkoreanchick
  • 49
  • 1
  • 2
  • 9
  • If you've got Eclipse, I presume you've also install egit. So yes, you *should* use `git diff`! And/or `git status`. Why *wouldn't* you??? – paulsm4 Jun 03 '16 at 17:52
  • @paulsm4 No I'm making a plug in that will do stuff with the locally changed files... So I need a list of files in JAVA so I can tell my plugin to do stuff with those files! If that makes any sense – hotkoreanchick Jun 03 '16 at 17:56
  • Yes, understood. You can easily create that list in Java by using [ProcessBuilder](http://alvinalexander.com/java/java-exec-processbuilder-process-1) to invoke `git status`. – paulsm4 Jun 03 '16 at 22:50
  • Ahh, with that I'm just worried if it would work well on windows. But I'll give that a try, I was hoping for more of a pure java answer I guess. Thanks for your help! – hotkoreanchick Jun 05 '16 at 23:14

1 Answers1

1

You can use JGIT API to compare the file between project files and a git branch/tag. It's pure java solution. All you need is install EGIT.

I ever wrote a Eclipse plugin TeamFileList for similar purpose. You can read the source of com.beck.ep.team.git.GitListBuilder, maybe it could help you.

Beck Yang
  • 3,004
  • 2
  • 21
  • 26
  • That was my solution except the eclipse version I have to use to build the plugins is 3.7.2 (indigo) which isn't compatible with JGIT libraries.. do you know any work arounds? – hotkoreanchick Jun 15 '16 at 03:54
  • For Eclipse 3.7.2, the latest EGIT is v2.3.1. You can find the link for **download p2 repository** in https://wiki.eclipse.org/EGit/FAQ – Beck Yang Jun 15 '16 at 13:03