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

Re: [Outreachy PATCH] merge: stop using the_repository

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 9, 2026, 08:17 UTC
Message-ID
<avGBpifgkHQ4L6WZ@pks.im>
In-Reply-To
<xmqq33tdcuub.fsf@gitster.g>
On Fri, Nov 06, 2026 at 05:07:40PM -0800, Junio C Hamano wrote:
Show 37 quoted lines
> Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
> 
> >>  merge.c | 16 +++++++---------
> >>  1 file changed, 7 insertions(+), 9 deletions(-)
> >
> >> +               strvec_push(&cmd.args, merge_argument(r, j->item));
> >>         strvec_push(&cmd.args, "--");
> >>         strvec_push(&cmd.args, head_arg);
> >>         for (j = remotes; j; j = j->next)
> >> -               strvec_push(&cmd.args, merge_argument(j->item));
> >> +               strvec_push(&cmd.args, merge_argument(r, j->item));
> >>
> >>         cmd.git_cmd = 1;
> >>         ret = run_command(&cmd);
> >> @@ -68,18 +66,18 @@ int checkout_fast_forward(struct repository *r,
> >>         memset(&trees, 0, sizeof(trees));
> >>         memset(&t, 0, sizeof(t));
> >>         }
> >>         for (i = 0; i < nr_trees; i++) {
> >> -               if (repo_parse_tree(the_repository, trees[i]) < 0) {
> >> +               if (repo_parse_tree(r, trees[i]) < 0) {
> >>                         rollback_lock_file(&lock_file);
> >>                         return -1;
> >>                 }
> 
> This shows one thing that I really hate about the current
> USE_THE_REPOSITORY model.
> 
> This function still calls unpack_trees(), which explicitly refers to
> and depends on the_repository.  It is somewhat misleading to claim
> that merge.c no longer depends on the_repository because of that.
> Even if you pass an arbitrary repository to checkout_fast_forward(),
> the call would not work as intended because unpack_trees() called by
> it will only work with the_repository under the hood.
> 
> Yet, this file now compiles without USE_THE_REPOSITORY defined,
> giving a false sense of achievement.

It _is_ an achievement. That achievement isn't that this file is now properly libified and that it can be used with an arbitrary repo. Because even if the subsystem didn't reference `the_repository` at all anymore, "libification" to me isn't only about that but also about having a sane API.

But it is an achievement because we have one less file to worry about with regards to our end goal of getting rid of `the_repository`, and this file cannot grow new explicit references to it.

[snip]
Show 10 quoted lines
> Again, that is why I really hate the USE_THE_REPOSITORY macro.  It
> does not help us measure our progress incrementally.  Perhaps we
> could hide certain symbols from their header files (like the
> functions I converted in this demonstration patch to rid them of
> the_repository dependency) for those who do not define the macro,
> so we can get a more accurate picture of our progress.  However,
> an earlier attempt to do exactly that on notes-utils.h in
> https://lore.kernel.org/git/xmqqjymt94l3.fsf@gitster.g/ was shot
> down by Patrick, so I am not sure what a good direction would be
> to provide a real incremental progress indicator.

The thing is that no matter what, unless we now start to hide every single symbol that implicitly references `the_repository`, it will be an imperfect measure anyway. And sure, in a perfect world we'd do exactly that. But it would result in a ton of churn, and I don't think it's easy to get right.

So from my perspective, the best direction here is "forward", because the problem will solve itself automatically once libgit.a does not use `the_repository` at all anymore.

Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “merge: stop using the_repository”
  1. merge: stop using the_repositoryOkhuomon Ajayi, Oct 15, 2026
  2. Usman AkinyemiOct 15, 2026
  3. Okhuomon AjayiOct 15, 2026
  4. Junio C HamanoNov 7, 2026
  5. Patrick SteinhardtNov 9, 2026
  6. Junio C HamanoOct 15, 2026
  7. Okhuomon AjayiOct 15, 2026

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.