summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-27 08:09:18 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-09-27 08:42:44 (GMT)
commit4431fcc4b134ae501e3e57dc568ae4f031e57898 (patch)
tree572af9e0e6b4e387af2c71e60c94953350d28826 /refs.c
parente9800b28c24465377dc2b8e26b322d362912647c (diff)
downloadgit-4431fcc4b134ae501e3e57dc568ae4f031e57898.zip
git-4431fcc4b134ae501e3e57dc568ae4f031e57898.tar.gz
git-4431fcc4b134ae501e3e57dc568ae4f031e57898.tar.bz2
Clean-up lock-ref implementation
This drops "mustexist" parameter lock_ref_sha1() and lock_any_ref_forupdate() functions take. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/refs.c b/refs.c
index 2cef2b4..9a1bc0d 100644
--- a/refs.c
+++ b/refs.c
@@ -447,12 +447,13 @@ static struct ref_lock *verify_lock(struct ref_lock *lock,
return lock;
}
-static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1, int mustexist)
+static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1)
{
char *ref_file;
const char *orig_ref = ref;
struct ref_lock *lock;
struct stat st;
+ int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
lock = xcalloc(1, sizeof(struct ref_lock));
lock->lock_fd = -1;
@@ -480,20 +481,18 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
return old_sha1 ? verify_lock(lock, old_sha1, mustexist) : lock;
}
-struct ref_lock *lock_ref_sha1(const char *ref,
- const unsigned char *old_sha1, int mustexist)
+struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
{
char refpath[PATH_MAX];
if (check_ref_format(ref))
return NULL;
strcpy(refpath, mkpath("refs/%s", ref));
- return lock_ref_sha1_basic(refpath, old_sha1, mustexist);
+ return lock_ref_sha1_basic(refpath, old_sha1);
}
-struct ref_lock *lock_any_ref_for_update(const char *ref,
- const unsigned char *old_sha1, int mustexist)
+struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1)
{
- return lock_ref_sha1_basic(ref, old_sha1, mustexist);
+ return lock_ref_sha1_basic(ref, old_sha1);
}
void unlock_ref(struct ref_lock *lock)