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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2013, 21:48 UTC
Message-ID
<7v61w2clli.fsf@alter.siamese.dyndns.org>
In-Reply-To
<a598aec3e3c90de4d2c08e58ee0a4828edc80ac2.1374527806.git.trast@inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 25 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: the pruned
> commits did not affect the paths being filtered, so the diff against
> the prune-result is the same as against the diff against the true
> parents.
>
> 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).
>
> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
> ---
>
> Perhaps like this.  It's getting a bit late, so I'm not sure if I'm
> missing another user of the "true" parent list, but it does fix the
> issue you reported.

Conceptually I can see how this will change the history simplification in the vertical direction (skipping the ancestry chain and jumping directly to the closest grandparent that touched the specified path), but I am not sure how well this interacts with history simplification in the horizontal direciton (culling irrelevant side branches from the merge).

Show 8 quoted lines
> @@ -2820,6 +2821,7 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
>  	if (action == commit_show &&
>  	    !revs->show_all &&
>  	    revs->prune && revs->dense && want_ancestry(revs)) {
> +		save_parents(commit);
>  		if (rewrite_parents(revs, commit, rewrite_one) < 0)
>  			return commit_error;
>  	}

After this, rewritten parent list may have shrunk by dropping irrelevant side branches, but saved parents would have the full parents list. When we decide how to show diff depending on the number of remaining parents, we would still use the rewritten parents (which may have been reduced to a single strand of pearls) and your change will use the original parents (which may be multiple).

I also have to wonder if we always want to incur this save-parents overhead, or we are better off limiting it to only when --full-diff is in effect.

Thanks for getting the ball rolling, anyway.
Previous: Thomas RastNext: Thomas Rast
Message 4 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.