Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358033

Summary: Blame command not working with git repository created with git-p4 tool
Product: [Technology] JGit Reporter: Timothy Lusk <darkcube>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen, robin.rosenberg
Version: 1.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Sample git repository created with git-p4 none

Description Timothy Lusk CLA 2011-09-18 15:22:35 EDT
Build Identifier: 1.1

A git repository created with the git-p4 tool (which is used to bridge perforce repositories with git) does not work correctly with the blame command.  The bug occurs both in Windows and Linux but appears to be different between the two.

This repository does correctly show blame information when used with the official git executable.

I've attacked a small sample repository that was created using the git-p4 tool that displays this issue.  The repository has two files in it, one in the root and one inside a folder.

Output from git:

git blame file.txt
40f1964b (JM - DEV - Timothy Lusk 2011-09-18 13:57:58 -0500 1) Line 1
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 2) Line 2a
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 3) Line 3
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 4) Line 4

git blame folder\file2.txt
091634fd (JM - DEV - Timothy Lusk 2011-09-18 13:59:33 -0500 1) Line 1
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 2) Line 2a
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 3) Line 3
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 4) Line 4

Output from jgit on Windows:

jgit blame file.txt
         (Not Committed Yet                                 1) Line 1
         (Not Committed Yet                                 2) Line 2a
         (Not Committed Yet                                 3) Line 3
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 4) Line 4

jgit blame folder\file2.txt
         (Not Committed Yet          1) Line 1
         (Not Committed Yet          2) Line 2a
         (Not Committed Yet          3) Line 3
         (Not Committed Yet          4) Line 4

Output from jgit on Linux:

jgit blame file.txt
         (Not Committed Yet                                 1) Line 1
         (Not Committed Yet                                 2) Line 2a
         (Not Committed Yet                                 3) Line 3
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 4) Line 4

jgit blame folder\file2.txt
         (Not Committed Yet                                 1) Line 1
         (Not Committed Yet                                 2) Line 2a
         (Not Committed Yet                                 3) Line 3
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 4) Line 4

Reproducible: Always
Comment 1 Timothy Lusk CLA 2011-09-18 15:23:36 EDT
Created attachment 203560 [details]
Sample git repository created with git-p4
Comment 2 Robin Rosenberg CLA 2011-09-19 16:09:23 EDT
Does "jgit blame HEAD file.txt" work better?
Comment 3 Timothy Lusk CLA 2011-09-19 16:36:44 EDT
(In reply to comment #2)
> Does "jgit blame HEAD file.txt" work better?

Just tested this and it appears "blame HEAD" does show the correct results on both linux and windows.  

The problem is I would like the egit blame annotations in Eclipse to work, and the results I see with egit are the same as running "jgit blame file.txt" and not "jgit blame HEAD file.txt"
Comment 4 Timothy Lusk CLA 2011-09-19 18:29:03 EDT
After more investigation I've discovered that the problem seems to be jgit detecting whitespace changes while msysgit does not.  Running jgit blame with the -w option to ignore whitespace results in an acceptable output, but is still different than msysgit.

jgit blame -w file.txt
^e0ba52e (JM - DEV - Timothy Lusk 2011-09-18 13:57:32 -0500 1) Line 1
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 2) Line 2a
5c020016 (JM - DEV - Timothy Lusk 2011-09-18 13:58:12 -0500 3) Line 3
d8d66f14 (JM - DEV - Timothy Lusk 2011-09-18 13:58:32 -0500 4) Line 4

jgit blame -w folder/file2.txt
c7c89e4c (JM - DEV - Timothy Lusk 2011-09-18 13:59:08 -0500 1) Line 1
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 2) Line 2a
091634fd (JM - DEV - Timothy Lusk 2011-09-18 13:59:33 -0500 3) Line 3
1f4aa4f4 (JM - DEV - Timothy Lusk 2011-09-18 14:00:01 -0500 4) Line 4

Note that the revision numbers are still different than what I posted in the original comment from msysgit.

As a workaround I discovered the "ignore whitespace changes in blame annotations" option in the latest egit build.  This option solves the issue for me currently, but it still looks like jgit is working a little different under the hood.
Comment 5 Robin Rosenberg CLA 2011-09-20 01:59:27 EDT
You must compare the output from jgit blame -w with the output from git blame -w before drawing conlusions.
Comment 6 Timothy Lusk CLA 2011-09-20 11:30:25 EDT
(In reply to comment #5)
> You must compare the output from jgit blame -w with the output from git blame
> -w before drawing conlusions.

Sorry I did test both with -w and they are the same.  I meant the fact that without -w they work differently, it seems like they should be the same?