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

Re: [PATCH v2] log: use true parents for diff even when rewriting

From
Jeff King <peff@peff.net>
Date
Jul 31, 2013, 22:55 UTC
Message-ID
<20130731225520.GB25882@sigill.intra.peff.net>
In-Reply-To
<e7f2ead2267ff78940aab00fe36c378a2ce5d85e.1375301293.git.trast@inf.ethz.ch>
On Wed, Jul 31, 2013 at 10:13:20PM +0200, Thomas Rast wrote:
Show 18 quoted lines
> When using pathspec filtering in combination with diff-based log
> output, parent simplification happens before the diff is computed.
> The diff is therefore against the *simplified* parents.
> 
> This works okay, arguably by accident, in the normal case:
> simplification reduces to one parent as long as the commit is TREESAME
> to it.  So the simplified parent of any given commit must have the
> same tree contents on the filtered paths as its true (unfiltered)
> parent.
> 
> However, --full-diff breaks this guarantee, and indeed gives pretty
> spectacular results when comparing the output of
> 
>   git log --graph --stat ...
>   git log --graph --full-diff --stat ...
> 
> (--graph internally kicks in parent simplification, much like
> --parents).

Your description (and solution) make a lot of sense to me. Another code path that has a similar problem is the "-g" reflog walker. It rewrites the parents based on the reflog, and the diffs it produces are mostly useless (e.g., try "git stash list -p").

Should we be applying the same technique there?

I guess it might bother people who really want to see the diff between two lines in the reflog (e.g., comparing the results stored by "rebase" with the previous version). I think that is rare enough that "git diff" would be a better tool in that case, though.

And arguably, "log -g" should not be rewriting the parents at all, because it makes "--graph" pointless (and indeed, we disallow the combination). So potentially the solution is to stop the rewriting entirely, not mask it for the diffs. But doing so might be a good interim solution until somebody feels like rewriting the reflog walker.

-Peff
Previous: Thomas Rast
Message 9 of 9 in “git log anomalities”
  1. Uwe Kleine-KönigJul 22, 2013
  2. Thomas RastJul 22, 2013
  3. log: use true parents for diff even when rewritingThomas Rast, Jul 22, 2013
  4. Junio C HamanoJul 22, 2013
  5. Thomas RastJul 23, 2013
  6. Uwe Kleine-KönigJul 23, 2013
  7. Junio C HamanoJul 23, 2013
  8. log: use true parents for diff even when rewritingThomas Rast, Jul 31, 2013
  9. Jeff KingJul 31, 2013

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.