From: Junio C Hamano <gitster@pobox.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org, Guillaume Seguin <guillaume@segu.in>
Subject: Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
Date: Wed, 05 Dec 2007 11:46:53 -0800 [thread overview]
Message-ID: <7v7ijsq5zm.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 200712051113.40654.jnareb@gmail.com
Jakub Narebski <jnareb@gmail.com> writes:
> First patch, which is modified version of Guillaume Seguin patch solves
> problem that links in gitweb does lead to correct 'tag' view, while the
> second one solves the problem from the other side: instead of ensuring
> that links in gitweb are unambiguous it tries to resolve ambiguity.
Ok, I'll queue the first one (disambiguate) for 1.5.4 while letting the
people decide the latter for now.
> The problem is caused by the fact that git _always_ prefer heads (head
> refs) to tags (tag refs), even when it is clear
> $ git cat-file tags ambiguous-ref
> that we want a tag. So alternate solution would be to correct
> git-cat-file.
You are getting the layering all wrong.
* git-cat-file takes "object name" on its command line (so do many
other commands).
* One of the way to spell an "object name" is to refer to it with a ref
that can reach it (e.g. to name 12th generation parent of the tip of
the master branch, you spell "master~12" and you are using the ref
refs/heads/master).
* You do not have to always write out the ref in full. There is a
defined order to disambiguate refs (see git-rev-parse(1)), that
allows you to say 'master' and it expands to either refs/tags/master,
refs/heads/master or whatever.
Now git-cat-file does not care how you spelled your object name, and has
no business influencing the ref disambiguation order. You _could_ argue
"git cat-file tag <foo>" _expects_ <foo> to name a tag, but that logic
is very flawed (and that is why I said your understanding of layering is
screwed) for two reasons:
(1) <foo> may be user input to the script that uses cat-file and the
script may be expecting a tag there. Perhaps the script is about
creating a new branch from a tag (expecting a tag) and adds some
administrative info in the configuration file for the branch. It
does first:
t=$(git cat-file tag "$1") || die not a tag
and later the script may want to do:
git branch $newone "$1"
git config branch.$newone.description "created from tag $1 ($t)"
If you make "cat-file tag" to favor tag, and in a similar fashion
if you make "branch" favor branch, the above will not do what you
expect.
Consistently resolving the refname without (or minimum number of)
exceptions would give less surprising result.
(2) "git cat-file -t <foo>" is to find out what type the object is and
is meant to be used by callers who do not know the type. There is
no "favoring this class of ref over other classses" possible there.
> It would be quite easy I think to add checking if gitweb returns
> expected HTTP return code (HTTP status). So what is the portable way
> to check if first line of some output matches given regexp (given fixed
> string)?
Huh? Wouldn't something like this be enough?
>expect.empty &&
cmd >actual.out 2>actual.err &&
diff -u expect.empty actual.err &&
first=$(sed -e '1q' <actual.out) &&
test "z$first" = "I like it"
next prev parent reply other threads:[~2007-12-05 19: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 ` [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name Jakub Narebski
2007-12-01 3:06 ` 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 [this message]
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=7v7ijsq5zm.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=guillaume@segu.in \
--cc=jnareb@gmail.com \
/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).