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

Re: Determining whether you have a commit locally, in a partial clone?

From
Tao Klerks <tao@klerks.biz>
Date
Jun 20, 2023, 19:41 UTC
Message-ID
<CAPMMpoj+5XT9LwL==ih-cmdYyz6RN6Ysr=g661keTOTH-QrK-g@mail.gmail.com>
In-Reply-To
<xmqqo7lam1ei.fsf@gitster.g>
On Tue, Jun 20, 2023 at 8:31 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
>
> Tao Klerks <tao@klerks.biz> writes:
>
> > My apologies for the self-reply, I did find a workaround here:
> >
> > git -c remote.origin.url log SOME_HASH_NOT_IN_REFSPEC
> >
> > I don't understand what's happening here at all, because setting
> > "remote.origin.url" to "True" in this way works to prevent the
> > normally configured URL from kicking in, ...
>
> Interesting.  This happens inside remote.c:handle_config() where
> git_config_string() is used to reject a non-string value given to
> the "remote.<name>.url" variable and abort the process to read from
> the configuration file by returning -1 and causes whoever uses that
> configuration value to die.  As the command line configuration is
> read first, aborting the configuration reader early would mean that
> the configured values would not even be read.
>
> I am not sure why this does not cause the entire thing to die,
> though.  It requires further digging, for which I do not have time
> for right now..

I'm reasonably sure this is because the process that reads this config value is a subprocess, and that subprocess dying was actually *helping* me in this case.

Show 7 quoted lines
>
> > ... but setting a different value
> > (or empty value) does not.
>
> Most likely, this is because you are giving a syntactically correct
> value so the usual "last one wins" logic kicks in.
>

I don't understand - surely what's provided "-c" should beat what's in the repo's .config? "Last one wins" is exactly what I would expect, but don't seem to be seeing...

Show 38 quoted lines
> In hindsight, I think (1) the first one should probably fail the
> "git log" process (not just the lazy fetch subprocess), and (2)
> there should be an explicit way, e.g. giving an empty string, to
> "clear" the list of .url accumulated so far.
>
> (2) may look something silly like this:
>
>  remote.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git c/remote.c w/remote.c
> index 0764fca0db..ecc146856a 100644
> --- c/remote.c
> +++ w/remote.c
> @@ -64,12 +64,22 @@ static const char *alias_url(const char *url, struct rewrites *r)
>
>  static void add_url(struct remote *remote, const char *url)
>  {
> +       if (!*url) {
> +               remote->url_nr = 0;
> +               return;
> +       }
> +
>         ALLOC_GROW(remote->url, remote->url_nr + 1, remote->url_alloc);
>         remote->url[remote->url_nr++] = url;
>  }
>
>  static void add_pushurl(struct remote *remote, const char *pushurl)
>  {
> +       if (!*pushurl) {
> +               remote->pushurl_nr = 0;
> +               return;
> +       }
> +
>         ALLOC_GROW(remote->pushurl, remote->pushurl_nr + 1, remote->pushurl_alloc);
>         remote->pushurl[remote->pushurl_nr++] = pushurl;
>  }
>
Thank you, I'll play with this when I get the chance.
Previous: Junio C HamanoNext: Jeff King
Message 4 of 9 in “Determining whether you have a commit locally, in a partial clone?”
  1. Tao KlerksJun 20, 2023
  2. Tao KlerksJun 20, 2023
  3. Junio C HamanoJun 20, 2023
  4. Tao KlerksJun 20, 2023
  5. Jeff KingJun 21, 2023
  6. Tao KlerksJun 20, 2023
  7. Jeff KingJun 21, 2023
  8. Tao KlerksJun 21, 2023
  9. Jeff KingJun 27, 2023

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.