From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Guillaume Seguin <guillaume@segu.in>
Subject: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
Date: Sat, 1 Dec 2007 02:47:24 +0100 [thread overview]
Message-ID: <200712010247.25107.jnareb@gmail.com> (raw)
In-Reply-To: <200712010245.29204.jnareb@gmail.com>
If parse_tag was given ambiguous name, i.e. name which is both head
(branch) name and tag name, parse_tag failed because git prefer heads
to tags if there is ambiguity. Now it tries harder: if git-cat-file
doesn't produce output, try to resolve argument as tag name using
git-show-ref.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This supplements previous patch; while previous modified links to always
use unambiguous name, this one makes 'tag' view work even if passed
ambiguous name which is both name of head and of tag.
gitweb/gitweb.perl | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6ff4221..0427290 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1876,6 +1876,18 @@ sub parse_tag {
my @comment;
open my $fd, "-|", git_cmd(), "cat-file", "tag", $tag_id or return;
+ # try harder in case there is head (branch) with the same name as tag
+ if (eof($fd)) {
+ close $fd or return;
+ my $git_command = git_cmd_str();
+ $tag_id = qx($git_command show-ref --hash --tags $tag_id);
+ return unless $tag_id;
+ open $fd, "-|", git_cmd(), "cat-file", "tag", $tag_id or return;
+ if (eof($fd)) {
+ close $fd;
+ return;
+ };
+ }
$tag{'id'} = $tag_id;
while (my $line = <$fd>) {
chomp $line;
--
1.5.3.6
next prev parent reply other threads:[~2007-12-01 1:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-01 1:45 [PATCH] gitweb: disambiguate heads and tags withs the same name Jakub Narebski
2007-12-01 1:47 ` Jakub Narebski [this message]
2007-12-01 3:06 ` [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name Jakub Narebski
2007-12-05 7:01 ` Junio C Hamano
2007-12-05 10:13 ` Jakub Narebski
2007-12-05 19:46 ` Junio C Hamano
2007-12-05 21:02 ` Jakub Narebski
2007-12-05 21:14 ` Junio C Hamano
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=200712010247.25107.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=guillaume@segu.in \
/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 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).