Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
Cc: git@vger.kernel.org,  usmanakinyemi202@gmail.com,
	christian.couder@gmail.com,  siddharthasthana31@gmail.com,
	kaartic.sivaraam@gmail.com
Subject: Re: [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()
Date: Thu, 22 Oct 2026 12:30:16 -0700	[thread overview]
Message-ID: <xmqq33txfs8n.fsf@gitster.g> (raw)
In-Reply-To: <xmqqo6clfu19.fsf@gitster.g> (Junio C. Hamano's message of "Thu, 22 Oct 2026 11:51:30 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> 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);

  reply	other threads:[~2026-10-22 19:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 22:53 [Outreachy PATCH] checkout: use repository parameter in unique_tracking_name Okhuomon Ajayi
2026-10-22  9:41 ` Usman Akinyemi
2026-10-22 10:26   ` Okhuomon Ajayi
2026-10-22 10:56 ` [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name() Okhuomon Ajayi
2026-10-22 18:51   ` Junio C Hamano
2026-10-22 19:30     ` Junio C Hamano [this message]
2026-10-22 21:23     ` Okhuomon Ajayi
2026-10-23 21:15   ` [Outreachy PATCH v3 0/2] checkout: make unique_tracking_name() use the given repository Okhuomon Ajayi
2026-10-23 21:15     ` [Outreachy PATCH v3 1/2] remote: add repo_for_each_remote() Okhuomon Ajayi
2026-10-23 21:15     ` [Outreachy PATCH v3 2/2] checkout: pass the repository to unique_tracking_name() Okhuomon Ajayi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq33txfs8n.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=okhuomonajayi54@gmail.com \
    --cc=siddharthasthana31@gmail.com \
    --cc=usmanakinyemi202@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox