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

Re: [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 22, 2026, 19:30 UTC
Message-ID
<xmqq33txfs8n.fsf@gitster.g>
In-Reply-To
<xmqqo6clfu19.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Replace the last sentence with something like:
>
>     The callers still cannot call unique_tracking_name() with an
>     arbitrary repository parameter other than the_repository, until
>     the call in unique_tracking_name() to for_each_remote(), which
>     only works with the_repository, is updated to take an arbitrary
>     repository instance.
>
> perhaps?
>
> And explained that way, it becomes dubious if we chose a good place
> to stop.  The updated unique_tracking_name() gives an illusion that
> callers now can pass an arbitrary repository to it and expect it to
> work correctly with the given repository, but it does not.
>
> So, I dunno.

I think we need to improve the situation by doing something like the attached patch. We already have similar provisions in environment.h (to clarify that have_git_dir() and friends only work with 'the_repository'), hash.h ('the_hash_algo'), hex.h (get_hash_hex(), get_oid_hex(), etc.), path.h (GIT_PATH_FUNC() macro) and repository.h ('the_repository' itself).

As we pass a 'struct repository' pointer to more functions, making sure they do not call functions that still work only with 'the_repository' will become more important.

I suspect that in remote.h, there may be more symbols that need to be hidden when 'USE_THE_REPOSITORY_VARIABLE' is not defined, to ensure functions written without the macro can truly work with an arbitrary repository instance. The attached patch is just to illustrate the direction.

This is totally outside your topic and meant for more senior developers who help polish the foundation of the codebase.

Thanks.
 remote.h | 2 ++
 1 file changed, 2 insertions(+)
diff --git i/remote.h w/remote.h
index bfa5218c6e..eb7d4481eb 100644
--- i/remote.h
+++ w/remote.h
@@ -145,8 +145,10 @@ int remote_is_configured(struct remote *remote, int in_repo);
 
 typedef int each_remote_fn(struct remote *remote, void *priv);
 
+#ifdef USE_THE_REPOSITORY_VARIABLE
 /* iterate through struct remotes */
 int for_each_remote(each_remote_fn fn, void *priv);
+#endif
 
 int remote_has_url(struct remote *remote, const char *url);
 struct strvec *push_url_of_remote(struct remote *remote);
Previous: Junio C HamanoNext: Okhuomon Ajayi
Message 6 of 14 in “checkout: use repository parameter in unique_tracking_name”
  1. checkout: use repository parameter in unique_tracking_nameOkhuomon Ajayi, Oct 17, 2026
  2. Usman AkinyemiOct 22, 2026
  3. Okhuomon AjayiOct 22, 2026
  4. checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Oct 22, 2026
  5. Junio C HamanoOct 22, 2026
  6. Junio C HamanoOct 22, 2026
  7. Okhuomon AjayiOct 22, 2026
  8. 0/2 checkout: make unique_tracking_name() use the given repositoryOkhuomon Ajayi, Oct 23, 2026
  9. 1/2 remote: add repo_for_each_remote()Okhuomon Ajayi, Oct 23, 2026
  10. Christian CouderNov 3, 2026
  11. 2/2 checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Oct 23, 2026
  12. 0/2 checkout: make unique_tracking_name() use the given repositoryOkhuomon Ajayi, Nov 4, 2026
  13. 1/2 remote: add repo_for_each_remote()Okhuomon Ajayi, Nov 4, 2026
  14. 2/2 checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Nov 4, 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.