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

Re: [PATCH v3 3/4] log: simplify --follow following renames for non-linear history

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 26, 2026, 11:40 UTC
Message-ID
<at88KXp0vhXlPhFQ@pks.im>
In-Reply-To
<ba2dc35c77b95803f184e63cc9933e3765bd1417.1792701579.git.vmiklos@collabora.com>
On Thu, Oct 22, 2026 at 10:46:39PM +0200, Miklos Vajna wrote:
Show 7 quoted lines
> Code added in 304812ed33 (log: improve --follow following renames for
> non-linear history, 2026-06-22) implemented the feature by introducing a
> new propagate_follow_pathspec_to_parent() function which adds a new call
> to diff_tree_oid(). Also it introduces a new loop to record what path
> each parent of a merge commit should use when following a path.
> 
> This was working, but fixing its performance would require adding even

It's somewhat curious that you start talking about performance here without even mentioning that performance is what breaks the current approach. You mention contributing factors to the performance regression without really calling it that.

Show 12 quoted lines
> more custom code, instead of just extending the existing code in
> log_tree_diff().
> 
> Remove propagate_follow_pathspec_to_parent() and the loop calling it
> for each parent. Instead, record the path to follow for each parent in
> the parent loop of log_tree_diff(), right after diff_tree_oid() updated
> the pathspec in case of a rename. Merges are not diffed by default, so
> with --follow, run the same loop for them as well, but without showing
> anything. With -c, --cc or --remerge-diff, show the merge diff after the
> loop. This gets rid of the additional call to diff_tree_oid(). The
> rework has no positive performance impact yet, it just simplifies the
> code.
> This also fixes 'git log -m --follow': -m diffs the merge against each
> parent with rename following, so a rename found against the first parent
> updated the followed path, and the second parent was then diffed with
> the already renamed path.

So next to a performance regression there's also a bug? Interesting. I feel like giving a bit more time to introduce and explain the bug would have helped.

Show 5 quoted lines
> Also, propagate_follow_pathspec_to_parent()
> started from that same updated path, so history was lost on the side of
> the second parent. Now the path of the merge is restored before diffing
> each parent. Add a test for this, which shows the full history of the
> diamond case with -m.
And another bug?

So in summary we have two bugs and one performance regression? The two bugs are fixed by this change, and it also prepares us for the fix to the performance regression? It might be easier to reason through all of that if we were able to split this so that we fix one issue at a time, but that may of course not be possible (or just very awkward).

Show 44 quoted lines
> diff --git a/log-tree.c b/log-tree.c
> index b4c97b86f5..c5ac6c2bcb 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -1240,35 +1215,67 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
>  	}
>  
>  	if (is_merge) {
> -		if (opt->remerge_diff || opt->combine_merges)
> +		int merge_diff = opt->remerge_diff || opt->combine_merges;
> +
> +		if (merge_diff && !opt->diffopt.flags.follow_renames)
>  			return log_tree_merge_diff(opt, commit, parents, oid);
> -		if (opt->separate_merges) {
> +		if (opt->separate_merges && !merge_diff) {
>  			if (!opt->first_parent_merges) {
>  				/* Show parent info for multiple diffs */
>  				log->parent = parents->item;
>  			}
> +		} else if (opt->diffopt.flags.follow_renames) {
> +			/* Diff only to find the path to follow in parents */
> +			follow_only = 1;
>  		} else
>  			return 0;
>  	}
>  
> +	if (opt->diffopt.flags.follow_renames)
> +		path = xstrdup_or_null(
> +			pathspec_single_path(&opt->diffopt.pathspec));
> +
>  	showed_log = 0;
> +	all_parents = parents;
>  	for (;;) {
>  		struct commit *parent = parents->item;
>  
>  		parse_commit_or_die(parent);
>  		diff_tree_oid(get_commit_tree_oid(parent),
>  			      oid, "", &opt->diffopt);
> -		log_tree_diff_flush(opt);
> +		if (follow_only) {
> +			diff_queue_clear(&diff_queued_diff);
> +			opt->diffopt.found_follow = 0;
> +		} else
> +			log_tree_diff_flush(opt);
Nit: style, if once condition body requires curly braces all of them
should have it. Sorry, I cannot really provide more valuable feedback on
this patch than this.
Patrick
Previous: Miklos VajnaNext: Miklos Vajna
Message 10 of 48 in “Performance regression in `git log --follow`”
  1. Patrick SteinhardtOct 13, 2026
  2. SZEDER GáborOct 13, 2026
  3. log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 15, 2026
  4. Junio C HamanoOct 15, 2026
  5. log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 19, 2026
  6. 0/4 log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 22, 2026
  7. 1/4 t4219: test more --follow cases across mergesMiklos Vajna, Oct 22, 2026
  8. 2/4 log: extract showing the remerge/combined diff of a merge commitMiklos Vajna, Oct 22, 2026
  9. 3/4 log: simplify --follow following renames for non-linear historyMiklos Vajna, Oct 22, 2026
  10. Patrick SteinhardtOct 26, 2026
  11. 4/4 log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 22, 2026
  12. Patrick SteinhardtOct 26, 2026
  13. Patrick SteinhardtOct 26, 2026
  14. 0/6 log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 30, 2026
  15. 1/6 t4219: test more --follow cases across mergesMiklos Vajna, Oct 30, 2026
  16. 2/6 log: extract showing the remerge/combined diff of a merge commitMiklos Vajna, Oct 30, 2026
  17. 3/6 log: fix -m --follow losing the history of later parentsMiklos Vajna, Oct 30, 2026
  18. 4/6 log: simplify --follow following renames for non-linear historyMiklos Vajna, Oct 30, 2026
  19. 5/6 log: speed up --follow following renames for non-linear historyMiklos Vajna, Oct 30, 2026
  20. Patrick SteinhardtNov 6, 2026
  21. Miklos VajnaNov 9, 2026
  22. 6/6 log: fix --follow following an edit on a side the merge did not takeMiklos Vajna, Oct 30, 2026
  23. Patrick SteinhardtNov 6, 2026
  24. Miklos VajnaNov 9, 2026
  25. Patrick SteinhardtNov 6, 2026
  26. Miklos VajnaNov 9, 2026
  27. 0/5 log: speed up --follow following renames for non-linear historyMiklos Vajna, Nov 9, 2026
  28. 1/5 t4219: test more --follow cases across mergesMiklos Vajna, Nov 9, 2026
  29. Justin ToblerNov 10, 2026
  30. 2/5 log: extract showing the remerge/combined diff of a merge commitMiklos Vajna, Nov 9, 2026
  31. 3/5 log: fix -m --follow losing the history of later parentsMiklos Vajna, Nov 9, 2026
  32. 4/5 log: simplify --follow following renames for non-linear historyMiklos Vajna, Nov 9, 2026
  33. Toon ClaesNov 10, 2026
  34. 5/5 log: speed up --follow following renames for non-linear historyMiklos Vajna, Nov 9, 2026
  35. Justin ToblerNov 11, 2026
  36. Patrick SteinhardtNov 11, 2026
  37. Miklos VajnaNov 11, 2026
  38. Patrick SteinhardtNov 11, 2026
  39. log: make --follow following renames for non-linear history optionalMiklos Vajna, Nov 12, 2026
  40. Junio C HamanoNov 12, 2026
  41. Patrick SteinhardtNov 13, 2026
  42. log: make --follow following renames for non-linear history optionalMiklos Vajna, Nov 16, 2026
  43. Patrick SteinhardtNov 16, 2026
  44. Junio C HamanoNov 16, 2026
  45. Miklos VajnaNov 17, 2026
  46. Junio C HamanoNov 11, 2026
  47. Junio C HamanoOct 16, 2026
  48. Miklos VajnaOct 14, 2026

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.