Subject: Re: [PATCH v6 03/11] replay: stop using `the_repository`

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 2 Dec 2025 19:47:43 +0100

On Wed, Nov 19, 2025 at 11:01:29PM -0800, Elijah Newren wrote:
> On Mon, Oct 27, 2025 at 4:34 AM Patrick Steinhardt <[email-masked]> wrote:
> >
> > In `create_commit()` we're using `the_repository` even though we already
> > have a repository passed to use as an argument. Fix this.
> 
> I feel like I've fixed this multiple times, but it keeps coming back.
> In fact, I have this same fix locally in my replay-edit work.  Thanks
> for fixing it.
> 
> >
> > Note that we still cannot get rid of `USE_THE_REPOSITORY_VARIABLE`. This
> > is because we use `DEFAULT_ABBREV and `get_commit_output_encoding()`,
> > both of which are stored as global variables that can be modified via
> > the Git configuration.
> 
> Indeed.
> 
> Going on a tangent for a second...I feel like I've had to remove
> "the_repository" from builtin/replay.c multiple times.  In my local
> replay-edit work, I actually added a "#define the_repository
> DO_NOT_USE_THE_REPOSITORY" in builtin/replay.c, after all the header
> includes, because the_repository isn't what builtin/replay.c is using,
> it's these other two things that are also only included if
> USE_THE_REPOSITORY_VARIABALE is defined.  That obviously doesn't need
> to be part of your series, but what would you think if I were to
> submit that?  Is it too ugly/weird of a way to avoid the_repository
> being added back to builtin/replay.c so we can stop having to remove
> it again?

It does feel somewhat ugly, and the better solution would of course be
to refactor both `DEFAULT_ABBREV` and `get_commit_output_encoding()` to
accept a repository as input. But if I remember correctly that was a
nontrivial endeavour, so your proposed hack might be the next-best
solution.

Patrick