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

[PATCH v2 0/4] Do not create new refnames "refs" or "refs/*"

From
IRIngo Rohloff <ingo.rohloff@lauterbach.com>
Date
Nov 7, 2019, 19:07 UTC
Message-ID
<20191107190750.26674-1-ingo.rohloff@lauterbach.com>
In-Reply-To
<20191106165628.28563-1-ingo.rohloff@lauterbach.com>

After the previous round of input: The intention of this patch series is to make sure, that you always might use "refs/<something>" to unambiguously refer to a specific reference.

Or put in another way: With this patch series, refnames for "git log", 
starting with "refs/" should never result in a
  warning: refname '...' is ambiguous.
Exceptions: 
You already have strangely named references in your repository.
You pull such strangely named references from a remote repository.

This patch series does not prevent you from creating various other forms of ambiguous refnames. Example:

    git branch origin/master

This will very likely result in an ambiguity, because now the references

   refs/heads/origin/master
   refs/remotes/origin/master
will very likely both exist. "origin/master" matches both refnames.

This patch series forbids to create new reference names, which start with "refs" or "refs/*" with the commands

  git branch <name>
  git checkout -b <name>
  git tag <name>
  git remote add <name>
Note: This patch does NOT prevent you from working with references
which already exist.  It just prevents you from creating new ones
with the commands listed above.
That's also the reason why the '--force' option is not evaluated here.
I cannot think of a good reason, why you ever should want to create
refnames matching any of the following patterns:
   refs/heads/refs/*
   refs/tags/refs/*
   refs/remotes/refs/*
  
Ingo Rohloff (4):
  refs: new function newname_has_bad_prefix
  branch: Prevent creation of local branches named "refs" or "refs/*"
  remote: Prevent users from creating remotes named "refs" or "refs/*"
  tag: Prevent users from creating tags named "refs" or "refs/*"
 builtin/branch.c   |  6 ++++++
 builtin/checkout.c |  3 +++
 builtin/remote.c   |  3 +++
 builtin/tag.c      |  3 +++
 refs.c             | 30 ++++++++++++++++++++++++++++++
 refs.h             |  2 ++
 6 files changed, 47 insertions(+)
-- 
2.24.0
Previous: Ingo RohloffNext: Ingo Rohloff
Message 8 of 12 in “branch: Forbid to create local branches with confusing names”
  1. branch: Forbid to create local branches with confusing namesIngo Rohloff, Nov 6, 2019
  2. Johannes SchindelinNov 6, 2019
  3. Ingo RohloffNov 7, 2019
  4. Junio C HamanoNov 7, 2019
  5. Ingo RohloffNov 7, 2019
  6. Junio C HamanoNov 8, 2019
  7. Ingo RohloffNov 8, 2019
  8. 0/4 Do not create new refnames "refs" or "refs/*"Ingo Rohloff, Nov 7, 2019
  9. 1/4 refs: new function newname_has_bad_prefixIngo Rohloff, Nov 7, 2019
  10. 3/4 remote: Prevent users from creating remotes named "refs" or "refs/*"Ingo Rohloff, Nov 7, 2019
  11. 4/4 tag: Prevent users from creating tags named "refs" or "refs/*"Ingo Rohloff, Nov 7, 2019
  12. 2/4 branch: Prevent creation of local branches named "refs" or "refs/*"Ingo Rohloff, Nov 7, 2019

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.