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

Re: [PATCH 2/2] sequencer: rework reflog message handling

From
Junio C Hamano <gitster@pobox.com>
Date
May 9, 2025, 20:37 UTC
Message-ID
<xmqqfrhdzfjc.fsf@gitster.g>
In-Reply-To
<90c6912478683d96ef18b521506c703a2467585e.1746807747.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> Fix this by creating the reflog message nearer to where the commit is
> created and storing it in a local variable which is passed as an
> additional parameter to run_git_commit() rather than storing the message
> in `struct replay_ctx`. This makes it harder to forget to call
> `reflog_message()` before creating a commit and using a variable with a
> narrower scope means that a stale value cannot carried across a from one
> iteration of the loop to the next which should prevent any similar
> use-after-free bugs in the future.
Nice.
Show 19 quoted lines
> @@ -1124,10 +1119,10 @@ static int run_command_silent_on_success(struct child_process *cmd)
>   * author metadata.
>   */
>  static int run_git_commit(const char *defmsg,
> +			  const char *reflog_action,
>  			  struct replay_opts *opts,
>  			  unsigned int flags)
> ...
>  static int try_to_commit(struct repository *r,
>  			 struct strbuf *msg, const char *author,
> +			 const char *reflog_action,
>  			 struct replay_opts *opts, unsigned int flags,
>  			 struct object_id *oid)
> ...
>  static int do_commit(struct repository *r,
>  		     const char *msg_file, const char *author,
> +		     const char *reflog_action,
>  		     struct replay_opts *opts, unsigned int flags,
>  		     struct object_id *oid)

OK. We no longer have the reflog_action as a part of replay_opts, but they are almost always passed together, so making them sit together in the list of parameters does make sense.

Will queue.  Thanks.
Previous: Phillip Wood via GitGitGadget
Message 4 of 4 in “Sequencer: avoid use-after-free when creating merges”
  1. 0/2 Sequencer: avoid use-after-free when creating mergesPhillip Wood via GitGitGadget, May 9, 2025
  2. 1/2 sequencer: move reflog message functionsPhillip Wood via GitGitGadget, May 9, 2025
  3. 2/2 sequencer: rework reflog message handlingPhillip Wood via GitGitGadget, May 9, 2025
  4. Junio C HamanoMay 9, 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.