Thread (1 message) 1 message, 1 author, 2016-06-15

Re: git-annotate bug report

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

Ryan Anderson [off-list ref] writes:
Second, one I don't know how to fix, at the moment:

git annotate uses the automatic tree simplification that git rev-list
does.  So, when it sees a commit with 1 parent, it assumes that it
really only has one parent.  git diff-tree -c doesn't know about this
same tree simplification, and, in the case of a merge commit, will still
output the -c format patch.
When a merge M between A and B is simplified to have only A as a
parent, that means the file in question are identical in M and
A.  So you can just pass all the remaining blame on to A without
letting M taking any blame for itself.  So you do not need to do
any diff at all for a simplified merge.
There is, unfortunately, another situation, that of an octopus merge.
In the case of read-tree.c (after the rename is followed), the commit
7bd1527d2d8c80a6e9a0f8583082a5aee5428c68 is problematic.  In it we have
a 4-way merge, yet only 3 paths affected read-tree.c.  The diff-parsing
in annotate constructs a regular expression to find the diff header and
read out the line number to work on, and also to construct some regular
expressions from which to tell which lines affect which parents.
If a merge is not simplified, and if you end up reading from
--cc or -c -p, then:
For example, it looks for a line like:
+ ++Line added in 3 parents
with dynamically generated regular expressions.
the merge needs to claim responsibility only for lines that have
all pluses (i.e. evil merge), which you are already doing, I
think.  Any line without a minus that has at least one space can
be blamed on the parent that corresponds to the space (and if
there are more than one space, pick the first one).

Your particular "octopus" case, I think, is the same story.

$ git diff-tree --pretty=short -p -c 7bd1527 -- read-tree.c builtin-read-tree.c

would give you a combined diff, none of which has $allparentplus
(so nothing should be attributed to this merge), and the header
would tell you which parent to pass the blame on from that
point.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help