From: Jonathan Nieder <jrnieder@gmail.com>
To: Ronnie Sahlberg <sahlberg@google.com>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Michael Haggerty <mhagger@alum.mit.edu>
Subject: Re: check-ref-format: include refs/ in the argument or to strip it?
Date: Mon, 25 Aug 2014 11:26:36 -0700 [thread overview]
Message-ID: <20140825182636.GO20185@google.com> (raw)
In-Reply-To: <CAL=YDWk5FxnNWaFXJk3t+H0Q_axETmNeb=puuUqhiDBNeQVDGQ@mail.gmail.com>
Ronnie Sahlberg wrote:
> On Fri, Aug 22, 2014 at 10:46 PM, Jeff King <peff@peff.net> wrote:
>> Yeah, this weird "do not allow refs/foo" behavior has continually
>> confused me. Coincidentally I just noticed a case today where
>> "pack-refs" treats "refs/foo" specially for no good reason:
>>
>> http://thread.gmane.org/gmane.comp.version-control.git/255729
>>
>> After much head scratching over the years, I am of the opinion that
>> nobody every really _meant_ to prevent "refs/foo", and that code
>> comments like the one you quote above were an attempt to document
>> existing buggy behavior that was really trying to differentiate "HEAD"
>> from "refs/*". That's just my opinion, though. :)
It's still very puzzling to me. The comment came at the same time as
the behavior, in v0.99.9~120 (git-check-ref-format: reject funny ref
names, 2005-10-13). Before that, the behavior was even stranger ---
it checked that there was exactly one slash in the argument.
I'm willing to believe we might not want that check any more, though.
[...]
> There are also a lot of places where we assume that a refs will start
> with "refs/heads/" and not just "refs/"
> for_each_branch_ref(), log_ref_setup() (so no reflogs) is_branch() to
> name a few.
for_each_branch_ref is for iterating over local branches, which are
defined as refs that start with refs/heads/*. Likewise, the only
point of is_branch is to check whether a ref is under refs/heads/*.
That's not an assumption about all refs.
log_ref_setup implements the policy that there are only reflogs for:
* refs where the reflog was explicitly created ("git branch
--create-reflog" does this, but for some reason there's no
corresponding "git update-ref --create-reflog" so people have
to use mkdir directly for other refs), plus
* if the '[core] logallrefupdates' configuration is enabled (and it
is by default for non-bare repositories), then HEAD, refs/heads/*,
refs/notes/*, and refs/remotes/*.
This is documented in git-config(1) --- see core.logAllRefUpdates.
That way, when tools internally use other refs (e.g., FETCH_HEAD),
git doesn't have to automatically incur the cost of maintaining the
reflog for those. What other refs should there be reflogs for? I
haven't thought carefully about this.
It definitely isn't an assumption that *all* refs will match that
pattern. But it might be worth changing for other reasons.
Jonathan
next prev parent reply other threads:[~2014-08-25 18:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <gerrit.1408574889668.Iac983fc86f7edd2a0543779d85973c57bf068ca4@code-review.googlesource.com>
[not found] ` <047d7b624d36142d46050131f336@google.com>
2014-08-22 15:41 ` check-ref-format: include refs/ in the argument or to strip it? Jonathan Nieder
2014-08-22 18:37 ` Junio C Hamano
2014-08-22 18:45 ` Jonathan Nieder
2014-08-23 5:46 ` Jeff King
2014-08-23 5:50 ` Junio C Hamano
2014-08-25 17:43 ` Ronnie Sahlberg
2014-08-25 18:26 ` Jonathan Nieder [this message]
2014-08-25 19:09 ` Jeff King
2014-08-27 20:53 ` Michael Haggerty
2014-08-25 19:01 ` Junio C Hamano
2014-08-23 2:59 ` Jonathan Nieder
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=20140825182636.GO20185@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
--cc=peff@peff.net \
--cc=sahlberg@google.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).