From: Michael Haggerty <mhagger@alum.mit.edu>
To: Lars Schneider <larsxschneider@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Luke Diamand <luke@diamand.org>,
novalis@novalis.org
Subject: Re: What's cooking in git.git (Jun 2016, #05; Thu, 16)
Date: Tue, 28 Jun 2016 11:23:43 +0200 [thread overview]
Message-ID: <5772421F.3030100@alum.mit.edu> (raw)
In-Reply-To: <576B9081.3020405@alum.mit.edu>
On 06/23/2016 09:32 AM, Michael Haggerty wrote:
> [...]
> I have to say, I'm still confused about how the old code could have
> worked at all. For quite some time, Git hasn't allowed references with
> weird names like `git-p4-tmp/6` to be created, so how could there be any
> references there that need to be deleted? It seems to me that one of the
> following must be true:
> [...]
> * I'm wrong about Git not allowing references like `git-p4-tmp/6` to
> be created, in which case I'd like to know what code path allows it
> so that I can fix it.
I was indeed wrong.
Reference names are vetted by `check_refname_format()` on creation, but
that function knows and enforces nothing about the `refs/` namespace or
the ALL_CAPS convention for top-level references. Moreover, the relevant
caller passes the `REFNAME_ALLOW_ONELEVEL` option, which has semantics
that are fairly useless as far as I can tell. A casual reader might
assume that `REFNAME_ALLOW_ONELEVEL` allows one-level reference only if
they satisfy the special `ALL_CAPS` convention, but in fact it doesn't
enforce the convention. (I suppose that `REFNAME_ALLOW_ONELEVEL` was
meant for checking partial reference names, for example to vet "foo"
that the caller wants to pass to `git branch`, which automatically turns
it into `refs/heads/foo`.)
In summary, `check_refname_format()` is in some ways less strict than
`refname_is_safe()`. For example, it allows reference names like
`git-p4-tmp/6` or even `git-p4-tmp`. With current master:
$ git update-ref git-p4-tmp HEAD
$ echo $?
0
$ git rev-parse git-p4-tmp
cf4c2cfe52be5bd973a4838f73a35d3959ce2f43
$ git update-ref -d git-p4-tmp
$ echo $?
0
I don't know what I was thinking. Long ago, when I refactored and
documented check_refname_format(), I realized that the checks are
surprisingly lax and that the `REFNAME_ALLOW_ONELEVEL` option is
misleading. But I was new to the project and wasn't brave or energetic
enough to do something about it. Meanwhile I guess I forgot that it
never got fixed. Commit
d0f810f0 2014-09-03 refs.c: allow listing and deleting badly named refs
, which introduced `refname_is_safe()`, perhaps muddled the situation by
adding a "fallback" check that is not strictly laxer than the main check.
Where does that leave us?
* It is currently possible to create and delete references with
names that are neither within `refs/` nor ALL_CAPS (though not
remotely).
* Such references do not participate in reachability checks, so
they have to be considered semi-broken.
* Users could create chaos (though not remotely) by creating a
loose "reference" whose name coincides with that of another
file under `$GIT_DIR`.
(`git update-ref objects/info/alternates HEAD` anyone?)
* `git-p4` is apparently the only code within the Git project that
was making use of this questionable freedom.
* Presumably there is user code in the wild that creates and uses
such references.
I think we need to get this under control, but given that we've allowed
such references (albeit partly broken) for a long time, we probably need
to provide an escape hatch to aid the transition. I'm skeptical that the
mh/split-under-lock patch series is the best place to start such a
campaign. On the other hand, I don't want that patch series to open up
any new avenues to creating references that escape `$GIT_DIR`.
Let me think for a bit about the next step. Input is welcome.
In any case, I think that Lars's patch to `git-p4` is a good thing.
Michael
next prev parent reply other threads:[~2016-06-28 9:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 3:20 What's cooking in git.git (Jun 2016, #05; Thu, 16) Junio C Hamano
2016-06-17 13:25 ` Pranit Bauva
2016-06-17 17:55 ` Vasco Almeida
2016-06-17 22:05 ` Lars Schneider
2016-06-17 22:17 ` Junio C Hamano
2016-06-18 17:09 ` Michael Haggerty
2016-06-19 7:59 ` Michael Haggerty
2016-06-19 15:04 ` Lars Schneider
2016-06-19 16:11 ` Lars Schneider
2016-06-19 18:13 ` Junio C Hamano
2016-06-19 18:49 ` Lars Schneider
2016-06-19 18:53 ` Lars Schneider
2016-06-19 18:09 ` Junio C Hamano
2016-06-19 23:51 ` Junio C Hamano
2016-06-20 7:57 ` Lars Schneider
2016-06-23 7:32 ` Michael Haggerty
2016-06-27 7:09 ` Lars Schneider
2016-06-27 16:29 ` Junio C Hamano
2016-06-28 9:23 ` Michael Haggerty [this message]
2016-06-28 17:44 ` Junio C Hamano
2016-06-18 4:18 ` Michael Haggerty
2016-06-18 18:20 ` Junio C Hamano
2016-06-19 8:15 ` Michael Haggerty
2016-06-19 18:07 ` Junio C Hamano
2016-06-20 6:06 ` Torsten Bögershausen
2016-06-20 20:06 ` Junio C Hamano
2016-06-22 21:09 ` Joey Hess
2016-06-23 13:13 ` Torsten Bögershausen
2016-07-12 22:20 ` Joey Hess
2016-07-14 2:09 ` Torsten Bögershausen
2016-07-14 18:17 ` 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=5772421F.3030100@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=larsxschneider@gmail.com \
--cc=luke@diamand.org \
--cc=novalis@novalis.org \
/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).