refs: report ref type from lock_any_ref_for_update
authorBrad King <brad.king@kitware.com>
Fri, 30 Aug 2013 18:12:00 +0000 (14:12 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Aug 2013 21:57:28 +0000 (14:57 -0700)
Expose lock_ref_sha1_basic's type_p argument to callers of
lock_any_ref_for_update. Update all call sites to ignore it by passing
NULL for now.

Signed-off-by: Brad King <brad.king@kitware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
builtin/commit.c
builtin/fetch.c
builtin/receive-pack.c
builtin/reflog.c
builtin/replace.c
builtin/tag.c
fast-import.c
refs.c
refs.h
sequencer.c
index c5c6984cb5266c27d3c13aa6e6aacaab56e112c0..f2d383fa7723a1f7a77bee6c5bd9f323766f6caf 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -291,7 +291,7 @@ void create_branch(const char *head,
        hashcpy(sha1, commit->object.sha1);
 
        if (!dont_change_ref) {
-               lock = lock_any_ref_for_update(ref.buf, NULL, 0);
+               lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
                if (!lock)
                        die_errno(_("Failed to lock ref for update"));
        }
index 10acc53f8012f53b6a15a3d006b622bda3409b17..be08f4153ee89bb382f50b0fad857d0ea2a44ee9 100644 (file)
@@ -1618,7 +1618,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                                           !current_head
                                           ? NULL
                                           : current_head->object.sha1,
-                                          0);
+                                          0, NULL);
 
        nl = strchr(sb.buf, '\n');
        if (nl)
index d784b2e6947f1b5ace0016d92258e29377e9d1a7..28e40255beb6541350525615e6b9d57b19794bd3 100644 (file)
@@ -246,7 +246,8 @@ static int s_update_ref(const char *action,
                rla = default_rla.buf;
        snprintf(msg, sizeof(msg), "%s: %s", rla, action);
        lock = lock_any_ref_for_update(ref->name,
-                                      check_old ? ref->old_sha1 : NULL, 0);
+                                      check_old ? ref->old_sha1 : NULL,
+                                      0, NULL);
        if (!lock)
                return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
                                          STORE_REF_ERROR_OTHER;
index e3eb5fc0588a79b2b6c29bccdaf71ba49dc14c1f..a32307038e12de776fec409a6ea67c1c9dade7d0 100644 (file)
@@ -524,7 +524,8 @@ static const char *update(struct command *cmd)
                return NULL; /* good */
        }
        else {
-               lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
+               lock = lock_any_ref_for_update(namespaced_name, old_sha1,
+                                              0, NULL);
                if (!lock) {
                        rp_error("failed to lock %s", name);
                        return "failed to lock";
index 54184b3d133bb66db272fd21ad3cad53a4a9a5cb..28d756a418b27c9b9bf23805e54b74f6c3332ece 100644 (file)
@@ -366,7 +366,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
         * we take the lock for the ref itself to prevent it from
         * getting updated.
         */
-       lock = lock_any_ref_for_update(ref, sha1, 0);
+       lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
        if (!lock)
                return error("cannot lock ref '%s'", ref);
        log_file = git_pathdup("logs/%s", ref);
index 59d31152d0068dd4a542d2c8e076c629d508500f..1ecae8d076e4a58541c600e71a0680dd6f192788 100644 (file)
@@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
        else if (!force)
                die("replace ref '%s' already exists", ref);
 
-       lock = lock_any_ref_for_update(ref, prev, 0);
+       lock = lock_any_ref_for_update(ref, prev, 0, NULL);
        if (!lock)
                die("%s: cannot lock the ref", ref);
        if (write_ref_sha1(lock, repl, NULL) < 0)
index af3af3f64935c3f92ed3f85acd44ed2ca2a35b3f..2c867d2c0963f3187c2b77114518d9691799545a 100644 (file)
@@ -577,7 +577,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
        if (annotate)
                create_tag(object, tag, &buf, &opt, prev, object);
 
-       lock = lock_any_ref_for_update(ref.buf, prev, 0);
+       lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
        if (!lock)
                die(_("%s: cannot lock the ref"), ref.buf);
        if (write_ref_sha1(lock, object, NULL) < 0)
index 23f625f561dfd664a460827d507e7c0b720e9849..5c329f60095b1e5649b06399587e900bf8b9567a 100644 (file)
@@ -1678,7 +1678,7 @@ static int update_branch(struct branch *b)
                return 0;
        if (read_ref(b->name, old_sha1))
                hashclr(old_sha1);
-       lock = lock_any_ref_for_update(b->name, old_sha1, 0);
+       lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
        if (!lock)
                return error("Unable to lock %s", b->name);
        if (!force_update && !is_null_sha1(old_sha1)) {
diff --git a/refs.c b/refs.c
index 7922261580515859bc89005c4c69e8623c50c728..c69fd6802182bbd228d8d7e3df0fa337ccad1d3d 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2121,11 +2121,12 @@ struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha
 }
 
 struct ref_lock *lock_any_ref_for_update(const char *refname,
-                                        const unsigned char *old_sha1, int flags)
+                                        const unsigned char *old_sha1,
+                                        int flags, int *type_p)
 {
        if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
                return NULL;
-       return lock_ref_sha1_basic(refname, old_sha1, flags, NULL);
+       return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
 }
 
 /*
@@ -3174,7 +3175,7 @@ int update_ref(const char *action, const char *refname,
                int flags, enum action_on_err onerr)
 {
        static struct ref_lock *lock;
-       lock = lock_any_ref_for_update(refname, oldval, flags);
+       lock = lock_any_ref_for_update(refname, oldval, flags, NULL);
        if (!lock) {
                const char *str = "Cannot lock the ref '%s'.";
                switch (onerr) {
diff --git a/refs.h b/refs.h
index 9e5db3ae26ec7898d8ee9083c37562d3af05c0ab..2cd307af2552c33ccf3b44b2cf3edf36dc0a5e1a 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -137,7 +137,7 @@ extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *
 #define REF_NODEREF    0x01
 extern struct ref_lock *lock_any_ref_for_update(const char *refname,
                                                const unsigned char *old_sha1,
-                                               int flags);
+                                               int flags, int *type_p);
 
 /** Close the file descriptor owned by a lock and return the status */
 extern int close_ref(struct ref_lock *lock);
index 351548f57db61e62b47584020464aee877b48d8d..06e52b4c83ffc0ce2b9414afe3fb1b4ee91d4335 100644 (file)
@@ -279,7 +279,8 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
        read_cache();
        if (checkout_fast_forward(from, to, 1))
                exit(1); /* the callee should have complained already */
-       ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
+       ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
+                                          0, NULL);
        strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
        ret = write_ref_sha1(ref_lock, to, sb.buf);
        strbuf_release(&sb);