summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-10-01 12:28:15 +0200
committerJunio C Hamano <gitster@pobox.com>2014-10-01 13:45:11 -0700
commit7108ad232fc7a4c889e82b40c52125adc9796ff5 (patch)
tree21a15d1fe052aa839d0b4f536da92695b74d0f1b /refs.c
parent0a06f148373285822baf5f3e83696732a556a2d1 (diff)
downloadgit-7108ad232fc7a4c889e82b40c52125adc9796ff5.tar.gz
cache.h: define constants LOCK_SUFFIX and LOCK_SUFFIX_LEN
There are a few places that use these values, so define constants for them. 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.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 0e324770c9..73d6baedb0 100644
--- a/refs.c
+++ b/refs.c
@@ -79,7 +79,8 @@ out:
if (refname[1] == '\0')
return -1; /* Component equals ".". */
}
- if (cp - refname >= 5 && !memcmp(cp - 5, ".lock", 5))
+ if (cp - refname >= LOCK_SUFFIX_LEN &&
+ !memcmp(cp - LOCK_SUFFIX_LEN, LOCK_SUFFIX, LOCK_SUFFIX_LEN))
return -1; /* Refname ends with ".lock". */
return cp - refname;
}
@@ -2602,11 +2603,11 @@ static int delete_ref_loose(struct ref_lock *lock, int flag)
{
if (!(flag & REF_ISPACKED) || flag & REF_ISSYMREF) {
/* loose */
- int err, i = strlen(lock->lk->filename) - 5; /* .lock */
+ int err, i = strlen(lock->lk->filename) - LOCK_SUFFIX_LEN;
lock->lk->filename[i] = 0;
err = unlink_or_warn(lock->lk->filename);
- lock->lk->filename[i] = '.';
+ lock->lk->filename[i] = LOCK_SUFFIX[0];
if (err && errno != ENOENT)
return 1;
}