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

Re: [PATCH 4/4] line-log: simplify condition checking for merge commits

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2025, 20:57 UTC
Message-ID
<xmqq4itvp19r.fsf@gitster.g>
In-Reply-To
<20250824190644.2573279-5-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
> In process_ranges_arbitrary_commit() the condition deciding whether
> the given commit is not a merge, i.e. that it doesn't have more than
> one parent, is head-scratchingly backwards, flip it.

Hmph, the condition is about "is it a root commit? or is it a single-parent commit?", which does not sound overly complicated to me.

Show 23 quoted lines
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  line-log.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/line-log.c b/line-log.c
> index 71fa857ee8..188d387d40 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -1273,10 +1273,10 @@ int line_log_process_ranges_arbitrary_commit(struct rev_info *rev, struct commit
>  			struct line_log_data *prange = line_log_data_copy(range);
>  			add_line_range(rev, commit->parents->item, prange);
>  			clear_commit_line_range(rev, commit);
> -		} else if (!commit->parents || !commit->parents->next)
> -			changed = process_ranges_ordinary_commit(rev, commit, range);
> -		else
> +		} else if (commit->parents && commit->parents->next)
>  			changed = process_ranges_merge_commit(rev, commit, range);
> +		else
> +			changed = process_ranges_ordinary_commit(rev, commit, range);
>  	}
>  
>  	if (!changed)
Previous: SZEDER GáborNext: Derrick Stolee
Message 9 of 12 in “line-log: optimize merge commit processing”
  1. 0/4 line-log: optimize merge commit processingSZEDER Gábor, Aug 24, 2025
  2. 1/4 line-log: avoid unnecessary tree diffs when processing merge commitsSZEDER Gábor, Aug 24, 2025
  3. Derrick StoleeAug 25, 2025
  4. Junio C HamanoAug 25, 2025
  5. SZEDER GáborAug 28, 2025
  6. 2/4 line-log: get rid of the parents array in process_ranges_merge_commit()SZEDER Gábor, Aug 24, 2025
  7. 3/4 line-log: initialize diff queue in process_ranges_ordinary_commit()SZEDER Gábor, Aug 24, 2025
  8. 4/4 line-log: simplify condition checking for merge commitsSZEDER Gábor, Aug 24, 2025
  9. Junio C HamanoAug 25, 2025
  10. Derrick StoleeAug 25, 2025
  11. Junio C HamanoAug 25, 2025
  12. Derrick StoleeAug 25, 2025

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.