Re: difflame
- From
Jeff King <peff@peff.net>
- Date
- Jan 28, 2017, 03:53 UTC
- Message-ID
- <20170128035321.yrcqwkg2fiwadxj4@sigill.intra.peff.net>
- In-Reply-To
- <CAOc6etaCk=OEyarMNhorM94MBnYRscCkJBM-K08snv1ecmOaPQ@mail.gmail.com>
On Tue, Jan 17, 2017 at 11:24:02PM -0600, Edmundo Carmona Antoranz wrote:
> For a very long time I had wanted to get the output of diff to include > blame information as well (to see when something was added/removed).
This is something I've wanted, too. The trickiest part, though, is blaming deletions, because git-blame only tracks the origin of content, not the origin of a change.
For example, try this case:
git init
for i in $(seq 1 10); do
echo $i >>file
git add file
git commit -m "add $i"
done
sed 4d <file >tmp && mv tmp file
git commit -am "drop 4"Running "difflame HEAD~5 HEAD" produces this output:
diff --git a/file b/file index b414108..051c298 100644 --- a/file +++ b/file @@ -1,6 +1,9 @@ ^2b028ff (Jeff King 2017-01-27 22:44:10 -0500 1) 1 ed056366 (Jeff King 2017-01-27 22:44:10 -0500 2) 2 771030d8 (Jeff King 2017-01-27 22:44:10 -0500 3) 3 -89c09c82 (Jeff King 2017-01-27 22:44:10 -0500 4) 4 b619039c (Jeff King 2017-01-27 22:44:10 -0500 4) 5 6a7aa0e5 (Jeff King 2017-01-27 22:44:10 -0500 5) 6 +39bc9dc4 (Jeff King 2017-01-27 22:44:10 -0500 6) 7 +f253cc8f (Jeff King 2017-01-27 22:44:10 -0500 7) 8 +85c10f46 (Jeff King 2017-01-27 22:44:10 -0500 8) 9 +89c09c82 (Jeff King 2017-01-27 22:44:10 -0500 9) 10
The last 4 lines are right; they correspond to the addition commits. But the line taking away 4 is wrong. You can see even without looking at its patch, because it is blamed to the same commit that added "10", which is wrong.
Sorry I don't have a solution. I think it's an open problem with git-blame, though you could probably script something around "git blame --reverse". See the commit message of 85af7929e (git-blame --reverse, 2008-04-02) for some discussion.
-Peff