git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Kristoffer Haugsbakk <code@khaugsbakk.name>,
	 Jeff King <peff@peff.net>,
	 Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH 2/2] sequencer: rework reflog message handling
Date: Fri, 09 May 2025 13:37:43 -0700	[thread overview]
Message-ID: <xmqqfrhdzfjc.fsf@gitster.g> (raw)
In-Reply-To: <90c6912478683d96ef18b521506c703a2467585e.1746807747.git.gitgitgadget@gmail.com> (Phillip Wood via GitGitGadget's message of "Fri, 09 May 2025 16:22:27 +0000")

"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

> @@ -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.

      reply	other threads:[~2025-05-09 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09 16:22 [PATCH 0/2] Sequencer: avoid use-after-free when creating merges Phillip Wood via GitGitGadget
2025-05-09 16:22 ` [PATCH 1/2] sequencer: move reflog message functions Phillip Wood via GitGitGadget
2025-05-09 16:22 ` [PATCH 2/2] sequencer: rework reflog message handling Phillip Wood via GitGitGadget
2025-05-09 20:37   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfrhdzfjc.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).