Community
Participate
Working Groups
git blame has a very useful feature where when you have a merge conflict it will show the annotation of lines from the merge source and the merge destination. e.g. See below for a single line file with conflicts on that line 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 1) <<<<<<< HEAD f2b76502 (m.ross 2014-05-07 09:52:29 -0400 2) Origin - Change on master branch 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 3) ======= 1be63005 (m.ross 2014-05-07 09:50:33 -0400 4) Origin -- conflicting change from branch 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 5) >>>>>>> newbranch Unfortunately jgit blame shows the following for the same file 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 1) <<<<<<< HEAD f2b76502 (m.ross 2014-05-07 09:52:29 -0400 2) Origin - Change on master branch 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 3) ======= 1be63005 (m.ross 2014-05-07 09:50:33 -0400 4) Origin -- conflicting change from branch 00000000 (Not Committed Yet 2014-05-07 09:58:47 -0400 5) >>>>>>> newbranch To reproduce git init newrepo echo Origin > file git add file git commit -a -m "First commit" git branch newbranch git checkout newbranch echo " Origin -- conflicting change from branch" > file git commit -a -m "Conflicting commit on branch" git checkout master echo " Origin - - Change on master branch" > file git commit -a -m "Conflicting commit on master branch" git merge newbranch git blame jgit.sh blame
Hello, Has this issue been resolved, or is there any plan for this? Thanks
?? Something must be wrong in the bug description. When I compare what you pasted as "git blame" and "jgit blame" output .... then these outputs are identical. Cut and paste error? And when I run your test script (I had to modify it a bit) I see differences only in what metadata is presented for each line. The content lines itself are the same. Could you explain what you are missing? Thats what I tried and where I get same results. Am I overlooking something or 'cut'-ing too much? > git init newrepo Initialized empty Git repository in /tmp/y/newrepo/.git/ > cd newrepo > echo Origin > file > git add file > git commit -a -m "First commit" [master (root-commit) 5fcaa9a] First commit 1 file changed, 1 insertion(+) create mode 100644 file > git branch newbranch > git checkout newbranch Switched to branch 'newbranch' > echo " Origin -- conflicting change from branch" > file > git commit -a -m "Conflicting commit on branch" [newbranch 689ca03] Conflicting commit on branch 1 file changed, 1 insertion(+), 1 deletion(-) > git checkout master Switched to branch 'master' > echo " Origin - - Change on master branch" > file > git commit -a -m "Conflicting commit on master branch" [master 6b7f033] Conflicting commit on master branch 1 file changed, 1 insertion(+), 1 deletion(-) > git merge newbranch Auto-merging file CONFLICT (content): Merge conflict in file Automatic merge failed; fix conflicts and then commit the result. > git blame -s file | cut -d' ' -f2- >gitBlameOutput > jgit.sh blame -s file | cut -c10- >jgitBlameOutput 2015-07-20 10:29:01 DEBUG FS:433 - readpipe [git, config, --system, --edit],/usr/local/bin 2015-07-20 10:29:01 DEBUG FS:451 - readpipe may return '/usr/local/etc/gitconfig' 2015-07-20 10:29:01 DEBUG FS:452 - (ignoring remaing output: > diff gitBlameOutput jgitBlameOutput >
Sorry.. The jgit blame file from above is (Not Committed Yet 1) <<<<<<< HEAD (Not Committed Yet 2) Origin - - Change on master branch (Not Committed Yet 3) ======= (Not Committed Yet 4) Origin -- conflicting change from branch (Not Committed Yet 5) >>>>>>> newbranch while the git blame file 00000000 (Not Committed Yet 2015-07-20 16:26:27 -0400 1) <<<<<<< HEAD 9f1f5a82 (m.ross 2015-07-20 16:10:36 -0400 2) Origin - - Change on master branch 00000000 (Not Committed Yet 2015-07-20 16:26:27 -0400 3) ======= 4a2a4361 (m.ross 2015-07-20 16:10:04 -0400 4) Origin -- conflicting change from branch 00000000 (Not Committed Yet 2015-07-20 16:26:27 -0400 5) >>>>>>> newbranch I will check against the latest as this was 3.3.2
Running with jgit version 4.0.1.201506240215-r there is the same problem 2015-07-20 16:41:20 DEBUG FS:435 - readpipe [git, config, --system, --edit],/usr/local/bin 2015-07-20 16:41:20 DEBUG FS:453 - readpipe may return '/usr/local/etc/gitconfig' 2015-07-20 16:41:20 DEBUG FS:454 - (ignoring remaing output: (Not Committed Yet 1) <<<<<<< HEAD (Not Committed Yet 2) Origin - - Change on master branch (Not Committed Yet 3) ======= (Not Committed Yet 4) Origin -- conflicting change from branch (Not Committed Yet 5) >>>>>>> newbranch The use case here is that resolving merges without this is much more difficult since you can't look at the author or time under jgit while you can in regular git.
Ok, got it. You are missing commit-id and author×tamp information in front of the lines. I agree, that looks like a bug. Have you seen it once working in JGit?
It works post commit for simple cases (See below). The real reason this is a major issue is that Show Annotations in EGit for eclipse is pretty useless since most of the time you care about origin of lines of code when trying to resolve conflicts in the same file. git add file git commit [master ee3f2ca] Merge branch 'newbranch' jgit blame file ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 1) <<<<<<< HEAD 9f1f5a82 (m.ross 2015-07-20 16:10:36 -0400 2) Origin - - Change on master branch ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 3) ======= 4a2a4361 (m.ross 2015-07-20 16:10:04 -0400 4) Origin -- conflicting change from branch ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 5) >>>>>>> newbranch git blame file ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 1) <<<<<<< HEAD 9f1f5a82 (m.ross 2015-07-20 16:10:36 -0400 2) Origin - - Change on master branch ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 3) ======= 4a2a4361 (m.ross 2015-07-20 16:10:04 -0400 4) Origin -- conflicting change from branch ee3f2ca6 (m.ross 2015-07-21 08:23:12 -0400 5) >>>>>>> newbranch
Bug still exists in 5.4.0. Workaround for using jgit as a library. However, you will lose merge state: //commit all files for ((filename, _) in mergeResult.conflicts) { git.add().addFilepattern(filename).call() } git.commit().setMessage("Temp commit for proper blaming").call() //blame as wanted for ((filename, _) in mergeResult.conflicts) { val blameResult = git.blame().setFilePath(filename).call() } //Do not forget to reset git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD^").call()
New Gerrit change created: https://git.eclipse.org/r/147130
(In reply to Eclipse Genie from comment #8) > New Gerrit change created: https://git.eclipse.org/r/147130 This change should fix the real problem here, which is that lines 2 and 4 are not identified to come from the merge parents. The missing timestamp (and zero commit Id) on the "Not Committed Yet" lines is dealt with in https://git.eclipse.org/r/#/c/147131/ .
Gerrit change https://git.eclipse.org/r/147130 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=59f9d206c954b5633f5978723bd0a2e7db31c2e8