summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9800b2)
raw | patch | inline | side by side (parent: e9800b2)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 27 Sep 2006 08:09:18 +0000 (01:09 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 27 Sep 2006 08:42:44 +0000 (01:42 -0700) |
This drops "mustexist" parameter lock_ref_sha1() and lock_any_ref_forupdate()
functions take.
Signed-off-by: Junio C Hamano <junkio@cox.net>
functions take.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-pack-refs.c | patch | blob | history | |
builtin-update-ref.c | patch | blob | history | |
fetch.c | patch | blob | history | |
refs.c | patch | blob | history | |
refs.h | patch | blob | history |
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index db57fee72d55e9c54ee1a938e24703ebbdc12a90..4093973a0517b02dbdffc3a742605d38b2134e85 100644 (file)
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
/* make sure nobody touched the ref, and unlink */
static void prune_ref(struct ref_to_prune *r)
{
- struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1, 1);
+ struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
if (lock) {
unlink(git_path("%s", r->name));
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 90a3da53ad003a82781e6d4acfc7815c8f15f24f..ab528337aac66fb9fa93e86739a897ebffc364d5 100644 (file)
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
if (oldval && get_sha1(oldval, oldsha1))
die("%s: not a valid old SHA1", oldval);
- lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL, 0);
+ lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL);
if (!lock)
return 1;
if (write_ref_sha1(lock, sha1, msg) < 0)
index a2cbdfba8246a24b7da3ccf7cc0dbc1be2bd52bf..c426c049974fa1bf1aceea9d43d2e2c5ce194e06 100644 (file)
--- a/fetch.c
+++ b/fetch.c
if (!write_ref || !write_ref[i])
continue;
- lock[i] = lock_ref_sha1(write_ref[i], NULL, 0);
+ lock[i] = lock_ref_sha1(write_ref[i], NULL);
if (!lock[i]) {
error("Can't lock ref %s", write_ref[i]);
goto unlock_and_fail;
index 2cef2b4f0e8da19049c30a57199c27b100998c90..9a1bc0db59078fe5dc9c7919e119abfc6f579fc3 100644 (file)
--- a/refs.c
+++ b/refs.c
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)
index 305d408690cec81bf094702848f52364708c6613..0d4d79e03f50223ef95e9297b29a581fadeaa1a1 100644 (file)
--- a/refs.h
+++ b/refs.h
extern int get_ref_sha1(const char *ref, unsigned char *sha1);
/** Locks a "refs/" ref returning the lock on success and NULL on failure. **/
-extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1, int mustexist);
+extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1);
/** Locks any ref (for 'HEAD' type refs). */
-extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int mustexist);
+extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1);
/** Release any lock taken but not written. **/
extern void unlock_ref(struct ref_lock *lock);