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

Re: [PATCH 3/5] repository: initialize index in `repo_init()`

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 18, 2024, 12:16 UTC
Message-ID
<ZiEPHLVhedJCjQjI@tanuki>
In-Reply-To
<CAOLa=ZQHGSvpzupNPTBQ=j8rd7txMWt9mbGQpQUSJTgr-pP5uA@mail.gmail.com>
On Wed, Apr 17, 2024 at 05:38:29PM +0000, Karthik Nayak wrote:
Show 13 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > Refactor the code and create a common `initialize_repository()` function
> > that gets called from `repo_init()` and `initialize_the_repository()`.
> > This function sets up both the repository and the index as required.
> > Like this, we can easily special-case when `repo_init()` gets called
> > with `the_repository`.
> >
> 
> Nit: `initialize_the_repository()` calling `initialize_repository()`
> doesn't really indicate what each of them does and why we have two
> functions which are similarly named but calling each other. Maybe we
> should rename them?

I think once you know about `the_repository` it isn't all that bad. Whereas `initialize_repository()` initializes any repository, `initialize_the_repository()` only initializes `the_repository`.

But you know, let's further simplify this and move all initialization logic into `initialize_repository()` to make this hopefully clearer. And on top of that we can then also drop `initialize_the_repository()` completely by statically initializing the `the_repository` pointer so that callers can simply call `initialize_repository(&the_repository)` instead.

Patrick
Previous: Karthik NayakNext: Patrick Steinhardt
Message 9 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.