aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
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 2cef2b4f0..9a1bc0db5 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)