diff options
author | Junio C Hamano <junkio@cox.net> | 2006-09-27 12:09:18 +0400 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-09-27 12:42:44 +0400 |
commit | 4431fcc4b134ae501e3e57dc568ae4f031e57898 (patch) | |
tree | 572af9e0e6b4e387af2c71e60c94953350d28826 /refs.c | |
parent | e9800b28c24465377dc2b8e26b322d362912647c (diff) |
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.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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) |