git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: On blame/pickaxe

From
Junio C Hamano <junkio@cox.net>
Date
Oct 13, 2006, 07:54 UTC
Message-ID
<7vu028d51r.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vr6xddm7h.fsf@assigned-by-dhcp.cox.net>

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

Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 12 in “On blame/pickaxe”
  1. Junio C HamanoOct 13, 2006
  2. Junio C HamanoOct 13, 2006
  3. Junio C HamanoOct 14, 2006
  4. Junio C HamanoOct 14, 2006
  5. Petr BaudisOct 16, 2006
  6. Junio C HamanoOct 16, 2006
  7. Josef WeidendorferOct 16, 2006
  8. Andy WhitcroftOct 16, 2006
  9. Petr BaudisOct 17, 2006
  10. Junio C HamanoOct 21, 2006
  11. Luben TuikovOct 16, 2006
  12. Junio C HamanoOct 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.