Thread (1 message) 1 message, 1 author, 2016-06-15
  • (off-list ancestor, not in this archive)
  • Re: On blame/pickaxe · Junio C Hamano <hidden> · 2016-06-15

Re: On blame/pickaxe

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:43

In an earlier message, I talked about pickaxe data structure
that has potential for blaming more than one paths in a single
revision.

I was talking about the future enhancements, but it turns out
that there is a corner case that the feature is already needed
using the classic blame algorithm, and running blame shows its
limitation through.

The scenario is like this:

 - initial has two files A and B
 - branch left renames A to C and adds stuff at the top.
 - branch right renames B to C and adds stuff at the bottom.
 - left and right is merged and leaves one file, C, by taking
   what both branches did.
 - annotate C from the top.

The parts that came from A and B in the initial revision should
be assigned to these files in the initial commit.  If you look
at the blame output, you will see it fails to do so.  pickaxe
gives what is expected.

-- >8 --
#!/bin/sh

if test -d .git
then
        echo 'please run this in a fresh empty directory'
	exit
fi

git init-db

for i in 1 2 3 4 5 6 7 8 9 ; do echo line line line $i ; done >A
for i in A B C D E F G H I ; do echo line line line $i ; done >B

git add A B
git commit --author='Initial <initial@author>' -m initial

git branch right
git branch left

# Left
git checkout left
for i in 1 2 3; do echo added by left; done >C
cat A >>C
rm -f A B
git update-index --add --remove A B C
git commit --author='Left <left@branch>' -m Left

# Right
git checkout right
cat B >C
for i in 1 2 3; do echo added by right; done >>C
rm -f A B
git update-index --add --remove A B C
git commit --author='Right <right@branch>' -m Right

# Merge them; this should fail which is expected
git pull . left
{
	git cat-file blob :3:C
	git cat-file blob :2:C
} >C
git update-index C
git commit --author='Merge <merge@branch>' -m 'Changes are merged.'
rm -f C~*

echo blame
git blame -f -n -t C

echo pickaxe
git pickaxe -f -n -t C
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help