0

In order to detect whether someone else has modified a file named "myfile.txt" and pushed it to origin/master, I do type on terminal

git fetch
git diff --quiet origin/master myfile.txt

The exit status tells me whether the file has been modified by someone else or not and this works great.

Now, I want to do the same but using jgit, on a java program. Fetch is not a problem but i can't find how to specify a branch (origin/master) and specific file (myfile.txt) to the jgit.diff request.

Is it possible to do this ?

  • This post describes how to diff two commits https://stackoverflow.com/questions/27361538/how-to-show-changes-between-commits-with-jgit. For each changed file, a `DiffEntry` is available that you can inspect to see if the desired file was changed. – Rüdiger Herrmann May 09 '21 at 10:15
  • Does this answer your question? [How to show changes between commits with JGit](https://stackoverflow.com/questions/27361538/how-to-show-changes-between-commits-with-jgit) – Rüdiger Herrmann May 09 '21 at 10:16

0 Answers0