git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Disallow creating ambiguous branch names by default

From
Conrad Irwin <conrad.irwin@gmail.com>
Date
Aug 19, 2011, 18:14 UTC
Message-ID
<CAOTq_ptU2QmPMMZYQLd2MFQ_=_RnADdBnoN5+v4rXh_nmpOcjw@mail.gmail.com>
In-Reply-To
<7vhb5fev8a.fsf@alter.siamese.dyndns.org>
On Wed, Aug 17, 2011 at 11:41 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 26 quoted lines
> Conrad Irwin <conrad.irwin@gmail.com> writes:
>
>> Before this change, it was comparatively easy to create a confusingly
>
> Drop everything before the ", ".
>
>> named branch (like "origin/master" or "tag.1"). The former case is
>> particularly biting to newcomers, who suddenly find themselves needing
>> to handle nuances of the refs namespaces.
>
> If you start forbidding certain names, newcomers will need to be exposed
> the same nuances to understand why what they wanted to do is not allowed,
> so that is not an argument.
>
> My preferences (take them as "the ground rules" if you want) are:
>
>  - We don't disallow what we have long allowed, without a good reason;
>  - We make sure new people will get a warning with useful advice.
>
> I would be happy to see the end result that warns when the end user
> creates a branch (or a tag) that is ambiguous _when_ it is created (not
> "much later, when we noticed there are ambiguous refs"), and offers an
> advice message to use "branch -m" to rename it away (control the message
> with a new "advice.*" configuration and unless explicitly declined with
> it, always give the advice).
>
In the process of changing things around to do this, I noticed that
git checkout -M <foo> <current-branch>
surprisingly works, and does confusing things, in that you will get a:

$ git rev-parse HEAD@{1} warning: Log .git/logs/HEAD has gap after Fri, 19 Aug 2011 02:00:09 -0700

Presumably this is the reason that git branch -f forbids you from changing the current branch?

If so is this a reasonable case where the current behaviour should be forbidden (with the same error message "fatal: Cannot force update the current branch.") — or should I just make it output a warning?

Conrad
Previous: Stephen BashNext: Junio C Hamano
Message 7 of 10 in “Disallow creating ambiguous branch names by default”
  1. Disallow creating ambiguous branch names by defaultConrad Irwin, Aug 17, 2011
  2. Junio C HamanoAug 17, 2011
  3. Vijay LakshminarayananAug 18, 2011
  4. Stephen BashAug 18, 2011
  5. Conrad IrwinAug 19, 2011
  6. Stephen BashAug 19, 2011
  7. Conrad IrwinAug 19, 2011
  8. Junio C HamanoAug 19, 2011
  9. Conrad IrwinAug 19, 2011
  10. Junio C HamanoAug 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.