git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] fetch/push: allow refs/*:refs/*
Date: Tue, 15 May 2012 08:19:01 -0700	[thread overview]
Message-ID: <7vpqa5fp5m.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4FB218AA.2060006@alum.mit.edu> (Michael Haggerty's message of "Tue, 15 May 2012 10:49:46 +0200")

Michael Haggerty <mhagger@alum.mit.edu> writes:

> * Full refnames like "refs/foo" or "refs/bar/baz" (starting with "refs/").

When reading any of these out of existing set of ref candidates (i.e. read
from readdir() recursing down from ".git/refs"), we shouldn't be rejecting
with format checks, but we may want to warn.

When creating, we have full refnames in this case, so we can just check.

> * Top-level special ALL_CAPS reference names like "MERGE_HEAD".

Similar.  These are "full refname" as far as ref format checking code is
concerned, and the format logic allows only ALL_CAPS at the top-level.
When reading any single-level out of existing set of ref candidates
(i.e. read from readdir() scanning ".git/"), malformed candidates should
be ignored without even warning (otherwise you will incorrectly complain
upon seeing ".git/config").  When creating, we have full refnames in this
case, so we can just check.

> * Refspec-style patterns with wildcards, like "refs/heads/*" or
> "refs/foo/*/bar".

As I said in the message you are replying to, the format check for these
should be a separate function (which might happen to share some code with
ref, but that is an implementation detail).

> * Short branch names with an implied "refs/heads/" prefix omitted;
> e.g., "master" meaning "refs/heads/master".
>
> * Short tag names with an implied "refs/tags/" prefix omitted; e.g.,
> "v1.2.3" meaning "refs/tags/v1.2.3".

Checking for the above two classes should conceptually happen with the
implied prefix.  When creating (i.e. git branch/git checkout -b/git tag),
you know what full refname the thing will become if you allow it to be
created.

As an optimization measure at the implementation level, being able to
check "frotz", knowing that the calling code wants to know that the name
is usable as a branch name, without having to do an allocation to hold
"refs/heads/frotz" somewhere to call the format-check function, options
like allow-onelevel is sometimes useful, but at the conceptual level it is
not strictly necessary.

> Currently, I believe that code usually handles the short branch/tag
> names via one of two mechanisms:
>
> * Explicitly prepend "refs/heads/" or "refs/tags/" to the short name
> to make the corresponding full name, then work exclusively with the
> full name.

Conceptually everybody should be doing that.

> * Use the ref_rev_parse_rules based functions like dwim_ref() to guess
> which prefix can be applied to a short refname to make it into a full
> refname, then work exclusively with the full name.

That is merely _matching_ with existing name, no?  Once you see an
existing name, you shouldn't be _rejecting_ anything.  If you see a
questionable name, you may warn.

I am not sure if these "two mechanisms" is a proper characterization of
the problem space.  Shouldn't you be separating between reading and
creating instead?

> * Refnames either have to start with "refs/" or have to be ALL_CAPS.

Sensible.

> * Refnames cannot be directly under "refs/" but should be in a
> namespace like "refs/heads/".  (This is implied by the old
> check-ref-format documentation:

Almost, but beware of stashes.

      reply	other threads:[~2012-05-15 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01 22:19 [BUG] "fetch $there +refs/*:refs/*" fails if there is a stash Junio C Hamano
2012-05-02  9:15 ` Michael Haggerty
2012-05-02 16:26   ` Junio C Hamano
2012-05-04 22:30 ` [PATCH] fetch/push: allow refs/*:refs/* Junio C Hamano
2012-05-04 22:35   ` [PATCH] get_fetch_map(): tighten checks on dest refs Junio C Hamano
2012-05-05  6:03   ` [PATCH] fetch/push: allow refs/*:refs/* Michael Haggerty
2012-05-05 18:22     ` Michael Haggerty
2012-05-07 16:24     ` Junio C Hamano
2012-05-15  8:49       ` Michael Haggerty
2012-05-15 15:19         ` Junio C Hamano [this message]

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=7vpqa5fp5m.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    /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).