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

Re: [PATCH 3/3] refspec: stop depending on `the_repository`

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 16, 2026, 20:59 UTC
Message-ID
<xmqqpl0mejlc.fsf@gitster.g>
In-Reply-To
<20260716-pks-refspec-wo-the-repository-v1-3-aa40844d067f@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 14 quoted lines
> The only remaining user of `the_hash_algo` in "refspec.c" is
> `refspec_append()`, which needs to know the hash algorithm so that it
> can parse the appended refspec item. In contrast to the functions
> adapted in the preceding commit, this function always operates on a
> `struct refspec`. As that structure is expected to only ever contain
> refspecs that all use the same hash function it doesn't make sense
> though to adapt each caller.
>
> Instead, adapt the structure itself so that it gets initialized with a
> hash function and use that hash function to parse new refspec items.
> Adapt callers accordingly.
>
> This removes the final dependency on the global repository variable in
> "refspec.c", so we can drop `USE_THE_REPOSITORY_VARIABLE`.

While we lost some references to the_repository, we gained more references to the_hash_algo in exchange. Because the_hash_algo is defined in terms of the_repository->hash_algo, it is only available when the_repository is still in use. So these changes do not really help callers, and only leave more for them to clean up later.

Which is probably fine. We have to start somewhere, and refspec parsing is a fairly well-isolated corner of the universe that serves as a good starting point.

Thanks.
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 5 of 6 in “refspec: remove dependency on `the_repository`”
  1. 0/3 refspec: remove dependency on `the_repository`Patrick Steinhardt, Jul 16, 2026
  2. 1/3 refspec: group related structures and functionsPatrick Steinhardt, Jul 16, 2026
  3. 2/3 refspec: let callers pass in hash algorithm when parsing itemsPatrick Steinhardt, Jul 16, 2026
  4. 3/3 refspec: stop depending on `the_repository`Patrick Steinhardt, Jul 16, 2026
  5. Junio C HamanoJul 16, 2026
  6. Patrick SteinhardtJul 17, 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.