[PATCH v2 4/4] tag: Prevent users from creating tags named "refs" or "refs/*"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To explain the intention, here is an example:

A user executes
   git tag -m "a tag" refs/heads/master
after this operation
   git log refs/heads/master
will very likely complain that this reference is ambiguous.

The reason is, that you now very likely have the following two
references which both match:

   refs/heads/master
   refs/tags/refs/heads/master

git cannot decide which of the two references is meant.

By preventing the creation of tags which are named
  refs  or  refs/*
this issue is circumvented:
  git log refs/*
will never refer to a tag located under
  refs/tags/refs/*
because such a tag should not exist.

Signed-off-by: Ingo Rohloff <ingo.rohloff@xxxxxxxxxxxxxx>
---
 builtin/tag.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/builtin/tag.c b/builtin/tag.c
index e0a4c25382..c818fe3fcd 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -537,6 +537,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	tag = argv[0];
 
+	if (!cmdmode && newname_has_bad_prefix(tag))
+		die(_("Invalid new tag name: '%s'"), tag);
+
 	object_ref = argc == 2 ? argv[1] : "HEAD";
 	if (argc > 2)
 		die(_("too many params"));
-- 
2.24.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux