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

Re: [PATCH 0/5] global: drop external `the_index` variable

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 15, 2024, 14:15 UTC
Message-ID
<Zh02ZpS8x9H7FpHJ@tanuki>
In-Reply-To
<28541f00-9054-4aa0-8e47-348043b5f863@gmail.com>
On Mon, Apr 15, 2024 at 02:55:07PM +0100, Phillip Wood wrote:
Show 16 quoted lines
> Hi Patrick
> 
> On 15/04/2024 12:42, Patrick Steinhardt wrote:
> > The motivation of these patches comes from the introduction of the ref
> > format extension. I found it really hard to reason about the state of
> > `the_repository` and would like to continue its deprecation in favor of
> > explicitly passing down a `struct repository *`. Getting rid of
> > `the_index` is a first easy step into that direction to make things more
> > self-contained.
> 
> Maybe I've got the wrong end of the stick but my impression is that it is
> the use of "the_repository" in library code (i.e. the files outside
> builtin/) that causes most of the pain. With that in mind would be we better
> focusing contributor and reviewer effort on eliminating "the_repository"
> from those files instead? It would need to be done in carefully in stages
> but would bring real benefits.

I see these two things as orthogonal. Overall, the target is to have as few global state as possible. This requires us to over time remove both `the_repository`, but also `the_index`. Removing the latter is a ton easier to achieve than removing the former, and so I took the easier step first.

Whatever we do, we have to do things gradually anyway and thus we have to start somewhere. I've already got more things in the pipeline, where the next step for me is to touch up "refs.h" so that we always pass in the `struct ref_store *`. And here we will be introducing more uses of `the_repository`, as well. But I think this is okay, and by working from the bottom up we will over time get to a state where the lower levels of Git don't require globals anymore, whereas higher levels like e.g. the builtins still do use them.

Eventually, we can then introduce a macro `USE_THE_REPOSITORY_VARIABLE`, similar to `USE_THE_INDEX_VARIABLE` that I have just removed in this patch series.

Patrick
Previous: Phillip WoodNext: Junio C Hamano
Message 13 of 26 in “global: drop external `the_index` variable”
  1. 0/5 global: drop external `the_index` variablePatrick Steinhardt, Apr 15, 2024
  2. 1/5 t/helper: stop using `the_index`Patrick Steinhardt, Apr 15, 2024
  3. Karthik NayakApr 17, 2024
  4. 2/5 builtin: stop using `the_index`Patrick Steinhardt, Apr 15, 2024
  5. Karthik NayakApr 17, 2024
  6. Patrick SteinhardtApr 18, 2024
  7. 3/5 repository: initialize index in `repo_init()`Patrick Steinhardt, Apr 15, 2024
  8. Karthik NayakApr 17, 2024
  9. Patrick SteinhardtApr 18, 2024
  10. 4/5 builtin/clone: stop using `the_index`Patrick Steinhardt, Apr 15, 2024
  11. 5/5 repository: drop global `the_index` variablePatrick Steinhardt, Apr 15, 2024
  12. Phillip WoodApr 15, 2024
  13. Patrick SteinhardtApr 15, 2024
  14. Junio C HamanoApr 15, 2024
  15. Patrick SteinhardtApr 16, 2024
  16. Karthik NayakApr 17, 2024
  17. Patrick SteinhardtApr 18, 2024
  18. 0/6 global: drop `the_index` variablePatrick Steinhardt, Apr 18, 2024
  19. 1/6 t/helper: stop using `the_index`Patrick Steinhardt, Apr 18, 2024
  20. 2/6 builtin: stop using `the_index`Patrick Steinhardt, Apr 18, 2024
  21. 3/6 repository: initialize index in `repo_init()`Patrick Steinhardt, Apr 18, 2024
  22. 4/6 builtin/clone: stop using `the_index`Patrick Steinhardt, Apr 18, 2024
  23. 5/6 repository: drop `the_index` variablePatrick Steinhardt, Apr 18, 2024
  24. 6/6 repository: drop `initialize_the_repository()`Patrick Steinhardt, Apr 18, 2024
  25. Junio C HamanoApr 18, 2024
  26. Patrick SteinhardtApr 19, 2024

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.