aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2011-09-15 23:10:27 +0200
committerJunio C Hamano <gitster@pobox.com>2011-10-05 13:45:30 -0700
commit7e9d2fe96060957d90870d2fac9b85608423e277 (patch)
treedc68fe7286d63488a9a9a0115554b7ac75a16e41 /refs.c
parent49295d4e3fb58c6179b7434cd87805f86cb1f7b7 (diff)
downloadgit-7e9d2fe96060957d90870d2fac9b85608423e277.tar.gz
git-7e9d2fe96060957d90870d2fac9b85608423e277.tar.xz
Do not allow ".lock" at the end of any refname component
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>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 52597244b..5a0bd0f7a 100644
--- a/refs.c
+++ b/refs.c
@@ -898,6 +898,8 @@ static int check_refname_component(const char *ref)
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;
}
@@ -931,8 +933,6 @@ int check_refname_format(const char *ref, int flags)
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;