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

Re: git-annotate bug report

From
Junio C Hamano <junkio@cox.net>
Date
Aug 8, 2006, 08:49 UTC
Message-ID
<7vvep3wr15.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060807115000.GC15477@h4x0r5.com>
Ryan Anderson <ryan@michonline.com> writes:
Show 7 quoted lines
> 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.

Show 7 quoted lines
> 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.

Previous: Junio C Hamano
Message 11 of 11 in “git-annotate bug report”
  1. Jeff KingAug 3, 2006
  2. Ryan AndersonAug 3, 2006
  3. Ryan AndersonAug 7, 2006
  4. 1/2 log-tree: show_log() should respect the setting of diffopt->line_terminationRyan Anderson, Aug 7, 2006
  5. 2/2 annotate: Fix bug when parsing merges with differing real and logical parents.Ryan Anderson, Aug 7, 2006
  6. Junio C HamanoAug 7, 2006
  7. Ryan AndersonAug 7, 2006
  8. Annotate another problem reportJunio C Hamano, Aug 7, 2006
  9. Ryan AndersonAug 7, 2006
  10. Junio C HamanoAug 7, 2006
  11. Junio C HamanoAug 8, 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.