From: Keegan Carruthers-Smith <keegan.csmith@gmail.com>
To: git@vger.kernel.org
Subject: git ls-remote and protocolv2
Date: Wed, 15 Apr 2020 15:09:17 +0200 [thread overview]
Message-ID: <m2k12g7v5u.fsf@gmail.com> (raw)
Hi,
I would like to take advantage of protocol v2 in "git
ls-remote". However, it can't reasonably use it because the patterns for
ls-remote aren't prefix based patterns. See
https://public-inbox.org/git/20181031042405.GA5503@sigill.intra.peff.net/
This is behaviour I would like to implement. At Sourcegraph (were I
work) we use "git ls-remote HEAD" to test if a remote is reachable and a
valid git remote. Additionally we use it to get the symref for the
default branch.
There may be a better way to do this, but so far it seems ls-remote is
the most reliable. However, we don't get to take advantage of protocol
v2. A simple hack I did gives much better perf for our use case:
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 6ef519514b..12d3af177a 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -91,6 +91,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
}
}
+ argv_array_push(&ref_prefixes, "HEAD");
+
if (flags & REF_TAGS)
argv_array_push(&ref_prefixes, "refs/tags/");
if (flags & REF_HEADS)
What are the options to allow the use of protocol v2? The ideas I have
in mind are the following.
"--ref-prefixes" flag. This changes the behaviour of the patterns to
instead be ref prefixes so we can pass them as ref prefixes.
"--ref-prefix=PREFIX" flag. Can be passed in multiple times. Each PREFIX
is set as a ref prefix.
"refs/" prefix in pattern. If all patterns have a prefix of "refs/" pass
in the relevant prefixes to remote refs. This would be a breaking change
for the rare case of refs named like "refs/heads/refs/foo". You also
wouldn't be able to pass in the symref "HEAD" which is what I want for
my usecase.
I'm happy to implement any of these.
Cheers,
Keegan
next reply other threads:[~2020-04-15 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 13:09 Keegan Carruthers-Smith [this message]
2020-04-15 16:04 ` git ls-remote and protocolv2 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2k12g7v5u.fsf@gmail.com \
--to=keegan.csmith@gmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.