git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Tao Klerks <tao@klerks.biz>
Cc: git <git@vger.kernel.org>
Subject: Re: Determining whether you have a commit locally, in a partial clone?
Date: Tue, 20 Jun 2023 11:31:01 -0700	[thread overview]
Message-ID: <xmqqo7lam1ei.fsf@gitster.g> (raw)
In-Reply-To: <CAPMMpog8Hv_KcjNxbh_wzjwrFYt7TuTvrVy1XEtJMm6RWSKzRg@mail.gmail.com> (Tao Klerks's message of "Tue, 20 Jun 2023 14:04:06 +0200")

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..

> ... 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.

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


  reply	other threads:[~2023-06-20 18:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 11:26 Determining whether you have a commit locally, in a partial clone? Tao Klerks
2023-06-20 12:04 ` Tao Klerks
2023-06-20 18:31   ` Junio C Hamano [this message]
2023-06-20 19:41     ` Tao Klerks
2023-06-21  6:54     ` Jeff King
2023-06-20 19:12   ` Tao Klerks
2023-06-21  6:44     ` Jeff King
2023-06-21 10:10       ` Tao Klerks
2023-06-27  8:09         ` Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqo7lam1ei.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=tao@klerks.biz \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).