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

Re: [PATCH] commit: simplify building parents list

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2016, 23:03 UTC
Message-ID
<xmqqd1ihv3rp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<30afdbeb-7a45-70b2-495e-35fd3b62419a@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 16 quoted lines
> Push pptr down into the FROM_MERGE branch of the if/else statement,
> where it's actually used, and call commit_list_append() for appending
> elements instead of playing tricks with commit_list_insert().  Call
> copy_commit_list() in the amend branch instead of open-coding it.  Don't
> bother setting pptr in the final branch as it's not used thereafter.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> ...
> @@ -1729,7 +1727,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  			reflog_msg = (whence == FROM_CHERRY_PICK)
>  					? "commit (cherry-pick)"
>  					: "commit";
> -		pptr = &commit_list_insert(current_head, pptr)->next;
> +		commit_list_insert(current_head, &parents);
>  	}

I needed to read the full preimage to determine why this hunk is equivalent to the original. Which is a good demonstration that what motivated this patch is a valid issue to tackle---initializing the pptr variable to point at &parents too early and have the long if/elseif/... cascade work with it made the code unnecessarily harder to understand and this update untangles that.

Thanks.
Previous: René Scharfe
Message 2 of 2 in “commit: simplify building parents list”
  1. commit: simplify building parents listRené Scharfe, Oct 29, 2016
  2. Junio C HamanoOct 30, 2016

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.