Git.pm: Add remote_refs() git-ls-remote frontend
PATCH 1/1 Git.pm: Add remote_refs() git-ls-remote frontend
Should support all the important features, I guess. Too bad that
git-ls-remote --heads .
is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
This patch also converts git-remote.perl to use it.
---
git-remote.perl | 5 +---- perl/Git.pm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-)
git-remote.perl +1 -4
@@ -128,10 +128,7 @@ sub update_ls_remote { return if (($harder == 0) || (($harder == 1) && exists $info->{'LS_REMOTE'})); - my @ref = map { - s|^[0-9a-f]{40}\s+refs/heads/||; - $_; - } $git->command(qw(ls-remote --heads), $info->{'URL'}); + my @ref = keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])}; $info->{'LS_REMOTE'} = \@ref; }
perl/Git.pm +54 -1
67 lines not on this page · raw message
Quoted 5 lines · Petr Baudis
git-remote.perl +0
-0
git-remote.perl sub update_ls_remote { · line 133
Quoted 10 lines
git-remote.perl +1
-4@@ -128,10 +128,7 @@ sub update_ls_remote { return if (($harder == 0) || (($harder == 1) && exists $info->{'LS_REMOTE'})); - my @ref = map { - s|^[0-9a-f]{40}\s+refs/heads/||; - $_; - } $git->command(qw(ls-remote --heads), $info->{'URL'}); + my @ref = keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])}; $info->{'LS_REMOTE'} = \@ref; }
IIRC, ls-remote returns refs sorted and this function returns them as it receives.
Doesn't this change make @ref randomly ordered?
Quoted 21 lines · Junio C Hamano
Quoted 5 lines · Petr Baudis
git-remote.perl +0
-0git-remote.perl sub update_ls_remote { · line 133
Quoted 10 lines
git-remote.perl +1
-4@@ -128,10 +128,7 @@ sub update_ls_remote { return if (($harder == 0) || (($harder == 1) && exists $info->{'LS_REMOTE'})); - my @ref = map { - s|^[0-9a-f]{40}\s+refs/heads/||; - $_; - } $git->command(qw(ls-remote --heads), $info->{'URL'}); + my @ref = keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])}; $info->{'LS_REMOTE'} = \@ref; }IIRC, ls-remote returns refs sorted and this function returns them as it receives.
Quoted 1 line
Doesn't this change make @ref randomly ordered?
Yes, but I couldn't find any place in git-remote.perl where we rely on the @ref ordering - maybe I'm blind...
Signature · 3 lines
Petr "Pasky" Baudis Ever try. Ever fail. No matter. // Try again. Fail again. Fail better. -- Samuel Beckett
PATCH 1/1 Git.pm: Add remote_refs() git-ls-remote frontend
In reply to Petr BaudisShould support all the important features, I guess. Too bad that
git-ls-remote --heads .
is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
This patch also converts git-remote.perl to use it.
---
This version re-adds missed out stripping of refs/heads/ in git-remote.perl.
---
git-remote.perl | 5 +---- perl/Git.pm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-)
git-remote.perl +1 -4
@@ -128,10 +128,7 @@ sub update_ls_remote { return if (($harder == 0) || (($harder == 1) && exists $info->{'LS_REMOTE'})); - my @ref = map { - s|^[0-9a-f]{40}\s+refs/heads/||; - $_; - } $git->command(qw(ls-remote --heads), $info->{'URL'}); + my @ref = map { s|refs/heads/||; $_; } keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])}; $info->{'LS_REMOTE'} = \@ref; }
perl/Git.pm +54 -1
67 lines not on this page · raw message
Quoted 9 lines · Petr Baudis
Should support all the important features, I guess. Too bad that
git-ls-remote --heads .is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
Are they subtly different? To me they look like asking for completely different things. IIRC, the patterns are ref globs, so
git ls-remote $URL 'refs/heads/*'
would be the same as the former one.
Quoted 5 lines
This patch also converts git-remote.perl to use it.
Signed-off-by Petr Baudis <[email protected]>---
This version re-adds missed out stripping of refs/heads/ in git-remote.perl.
Ah, that was the bug you were talking about on #git channel, I guess...
Quoted 12 lines · Junio C Hamano
Quoted 9 lines · Petr Baudis
Should support all the important features, I guess. Too bad that
git-ls-remote --heads .is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
Quoted 7 lines
Are they subtly different? To me they look like asking for completely different things. IIRC, the patterns are ref globs, so
git ls-remote $URL 'refs/heads/*'
would be the same as the former one.
Yes, though subtly different, as I've already explained before - for the case of say
refs/remotes/evil/refs/heads
Quoted 2 lines
Ah, that was the bug you were talking about on #git channel, I guess...
*nod*
Signature · 3 lines
Petr "Pasky" Baudis
Early to rise and early to bed makes a male healthy and wealthy and dead.
-- James ThurberQuoted 8 lines · Petr Baudis
Quoted 3 lines
git ls-remote $URL 'refs/heads/*'
would be the same as the former one.
Yes, though subtly different, as I've already explained before - for the case of say
refs/remotes/evil/refs/heads
Are you voting for removal of "ls-remote $URL 'heads/*'" support? I actually think removing it makes a perfect sense.
Quoted 4 lines
Quoted 2 lines
Ah, that was the bug you were talking about on #git channel, I guess...
*nod*
[Cc: Petr Baudis <[email protected]>, [email protected]]
Quoted 8 lines · Petr Baudis
Should support all the important features, I guess. Too bad that
git-ls-remote --heads .is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
Why do not use git-for-each-ref or git-show-refs? If I remember correctly they _were_ faster than git-ls-remote or git-peek-remote...
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Quoted 7 lines · Jakub Narebski
[Cc: Petr Baudis <[email protected]>, [email protected]]
Quoted 3 lines · Petr Baudis
Should support all the important features, I guess. Too bad that
git-ls-remote --heads .
Quoted 8 lines
Quoted 5 lines
is subtly different from
git-ls-remote . refs/heads/
so we have to provide the interface for specifying both.
Why do not use git-for-each-ref or git-show-refs? If I remember correctly they _were_ faster than git-ls-remote or git-peek-remote...
But we want to typically list refs in a remote repository.
Signature · 3 lines
Petr "Pasky" Baudis
Early to rise and early to bed makes a male healthy and wealthy and dead.
-- James Thurber