git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Use git-show-ref instead of git-peek-remote
@ 2006-11-24 22:01 Jakub Narebski
  2006-11-24 22:20 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2006-11-24 22:01 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski

Use "git show-ref --dereference" instead of "git peek-remote ." in
git_get_references. git-show-ref is faster than git-peek-remote; even
faster is reading info/refs file (if it exists), but the information
in info/refs can be stale.

git-show-ref is available since v1.4.4; the output format is slightly
different than git-peek-remote output format.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f06cd3e..290751f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1154,14 +1154,15 @@ sub git_get_last_activity {
 sub git_get_references {
 	my $type = shift || "";
 	my %refs;
-	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c	refs/tags/v2.6.11
-	# c39ae07f393806ccf406ef966e9a15afc43cc36a	refs/tags/v2.6.11^{}
-	open my $fd, "-|", $GIT, "peek-remote", "$projectroot/$project/"
+	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
+	# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
+	open my $fd, "-|", git_cmd(), "show-ref", "--dereference",
+		($type ? ("--", "refs/$type") : ()) # use -- <pattern> if $type
 		or return;
 
 	while (my $line = <$fd>) {
 		chomp $line;
-		if ($line =~ m/^([0-9a-fA-F]{40})\trefs\/($type\/?[^\^]+)/) {
+		if ($line =~ m/^([0-9a-fA-F]{40}) refs\/($type\/?[^\^]+)/) {
 			if (defined $refs{$1}) {
 				push @{$refs{$1}}, $2;
 			} else {
-- 
1.4.4.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-11-25 11:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-24 22:01 [PATCH] gitweb: Use git-show-ref instead of git-peek-remote Jakub Narebski
2006-11-24 22:20 ` Junio C Hamano
2006-11-24 22:35   ` Jakub Narebski
2006-11-25 10:18   ` [PATCH (amend)] " Jakub Narebski
2006-11-25 10:24     ` Jakub Narebski
2006-11-25 10:32   ` [PATCH (take 3)] " Jakub Narebski
2006-11-25 10:42     ` Junio C Hamano
2006-11-25 11:08       ` Jakub Narebski

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 NNTP newsgroup(s).