summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 49295d4)
raw | patch | inline | side by side (parent: 49295d4)
author | Michael Haggerty <mhagger@alum.mit.edu> | |
Thu, 15 Sep 2011 21:10:27 +0000 (23:10 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Oct 2011 20:45:30 +0000 (13:45 -0700) |
Allowing any refname component to end with ".lock" is looking for
trouble; for example,
$ git br foo.lock/bar
$ git br foo
fatal: Unable to create '[...]/.git/refs/heads/foo.lock': File exists.
Therefore, do not allow any refname component to end with ".lock".
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trouble; for example,
$ git br foo.lock/bar
$ git br foo
fatal: Unable to create '[...]/.git/refs/heads/foo.lock': File exists.
Therefore, do not allow any refname component to end with ".lock".
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-check-ref-format.txt | patch | blob | history | |
refs.c | patch | blob | history | |
t/t1402-check-ref-format.sh | patch | blob | history |
index dcb8cc38a3a6856b51ad2c217e81271bcdf2535d..9114751966aa31d1ff233077d53ff98a7c4c70fa 100644 (file)
. They can include slash `/` for hierarchical (directory)
grouping, but no slash-separated component can begin with a
- dot `.`.
+ dot `.` or end with the sequence `.lock`.
. They must contain at least one `/`. This enforces the presence of a
category like `heads/`, `tags/` etc. but the actual names are not
. They cannot end with a slash `/` nor a dot `.`.
-. They cannot end with the sequence `.lock`.
-
. They cannot contain a sequence `@{`.
. They cannot contain a `\`.
index 52597244b871887028aafbefece4d22bbe1001ec..5a0bd0f7af35334a1daf469178e4e5e4f4063906 100644 (file)
--- a/refs.c
+++ b/refs.c
return -1; /* Component has zero length. */
if (ref[0] == '.')
return -1; /* Component starts with '.'. */
+ if (cp - ref >= 5 && !memcmp(cp - 5, ".lock", 5))
+ return -1; /* Refname ends with ".lock". */
return cp - ref;
}
if (ref[component_len - 1] == '.')
return -1; /* Refname ends with '.'. */
- if (component_len >= 5 && !memcmp(&ref[component_len - 5], ".lock", 5))
- return -1; /* Refname ends with ".lock". */
if (!(flags & REFNAME_ALLOW_ONELEVEL) && component_count < 2)
return -1; /* Refname has only one component. */
return 0;
index 1cad88f2dcf56fe9499feedbdabeea6abbdc841d..419788f78ff2e767c50abee654f0b39c3cd5ec44 100755 (executable)
valid_ref 'foo./bar'
invalid_ref 'heads/foo.lock'
invalid_ref 'heads///foo.lock'
-valid_ref 'foo.lock/bar'
-valid_ref 'foo.lock///bar'
+invalid_ref 'foo.lock/bar'
+invalid_ref 'foo.lock///bar'
valid_ref 'heads/foo@bar'
invalid_ref 'heads/v@{ation'
invalid_ref 'heads/foo\bar'
invalid_ref_normalized 'heads\foo'
invalid_ref_normalized 'heads/foo.lock'
invalid_ref_normalized 'heads///foo.lock'
-valid_ref_normalized 'foo.lock/bar' 'foo.lock/bar'
-valid_ref_normalized 'foo.lock///bar' 'foo.lock/bar'
+invalid_ref_normalized 'foo.lock/bar'
+invalid_ref_normalized 'foo.lock///bar'
test_done