git ls-remote and protocolv2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx/

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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux