From: Junio C Hamano <gitster@pobox.com>
To: Ingo Rohloff <ingo.rohloff@lauterbach.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] branch: Forbid to create local branches with confusing names
Date: Fri, 08 Nov 2019 11:54:29 +0900 [thread overview]
Message-ID: <xmqq36ezoz6i.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191107135409.13fa0336@ingpc3.intern.lauterbach.com> (Ingo Rohloff's message of "Thu, 7 Nov 2019 13:54:09 +0100")
Ingo Rohloff <ingo.rohloff@lauterbach.com> writes:
> On Thu, 07 Nov 2019 15:05:49 +0900
> Junio C Hamano <gitster@pobox.com> wrote:
>> Ingo Rohloff <ingo.rohloff@lauterbach.com> writes:
>>
>> > ...
>> > This patch forbids to create local branches, with names which start
>> > with any of
>> >
>> > refs/
>> > heads/
>> > remotes/
>> > tags/
>>
>> Is there a reason why notes/ hierarchy is excluded? What about
>> pull/? Are we dealing with an unbounded set? Should this list be
>> somehow end-user configurable so that say Gerrit users can add for/
>> and changes/ to the "forbidden" set?
>
> I think I did not explain the intention that well.
> What I basically want to avoid is a situation in which there is
> no way at all to refer unambiguously to a particular reference.
Hmph, I thought this was a solved problem, but maybe I am still
misunderstanding you.
When you have a possibly ambigous branch whose name is $X, whether
$X begins with one of the strings you listed above or not, you can
always
- refer to the commit at the tip of that branch by saying
refs/heads/$X (e.g. "git show refs/heads/$X") and that always
refers to the commit, even if there are other branches and tags
that may begin with refs/ or refs/heads/. You would of course
get a warning about possible ambiguity because saying just $X
(e.g. "git show $X") may not refer to refs/heads/$X when you have
other refs that make $X ambiguous.
- refer to the branch by saying $X (and not refs/heads/$X).
The thing to know is when you are naming a branch and when you are
naming a commit.
- "git branch -d $X" is referring to the branch itself and removes
refs/heads/$X.
- "git branch new <start-point>" uses <start-point> to specify the
commit to begin the 'new' branch at, and does not necessarily
take a branch name, so you should say refs/heads/$X. You may not
be able to rely on lazy-man's short-hands, like "git checkout -t
origin/master" that DWIMs what you did not say, as you have to
say refs/heads/$X that is *not* in the <remote-nick>/<branch>
form (you can still do so with "git checkout -b master
refs/heads/$X" followed by necessary configuration updates), but
that is a price to pay for using ambiguous names.
And for those who do not want to pay for using ambiguous names, we
issue warnings when resolving refnames.
next prev parent reply other threads:[~2019-11-08 2:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 16:56 [PATCH] branch: Forbid to create local branches with confusing names Ingo Rohloff
2019-11-06 22:15 ` Johannes Schindelin
2019-11-07 19:04 ` Ingo Rohloff
2019-11-07 6:05 ` Junio C Hamano
2019-11-07 12:54 ` Ingo Rohloff
2019-11-08 2:54 ` Junio C Hamano [this message]
2019-11-08 12:45 ` Ingo Rohloff
2019-11-07 19:07 ` [PATCH v2 0/4] Do not create new refnames "refs" or "refs/*" Ingo Rohloff
2019-11-07 19:07 ` [PATCH v2 1/4] refs: new function newname_has_bad_prefix Ingo Rohloff
2019-11-07 19:07 ` [PATCH v2 2/4] branch: Prevent creation of local branches named "refs" or "refs/*" Ingo Rohloff
2019-11-07 19:07 ` [PATCH v2 3/4] remote: Prevent users from creating remotes " Ingo Rohloff
2019-11-07 19:07 ` [PATCH v2 4/4] tag: Prevent users from creating tags " Ingo Rohloff
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=xmqq36ezoz6i.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ingo.rohloff@lauterbach.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).