[PATCH v2 3/4] remote: Prevent users from creating remotes 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 remote add refs/heads <URL>
   git fetch refs/heads
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/remotes/refs/heads/master

git cannot decide which of the two references is meant.

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

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

diff --git a/builtin/remote.c b/builtin/remote.c
index 5591cef775..2272c16d18 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -189,6 +189,9 @@ static int add(int argc, const char **argv)
 	name = argv[0];
 	url = argv[1];
 
+	if (newname_has_bad_prefix(name))
+		die(_("Invalid new remote name: '%s'"), name);
+
 	remote = remote_get(name);
 	if (remote_is_configured(remote, 1))
 		die(_("remote %s already exists."), name);
-- 
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