refs: report ref type from lock_any_ref_for_update

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>

Brad King committed Aug 30, 2013 at 14:12 UTC 9bbb0fa1fdc6c413b1f35c26e090515e5d0096aa
11 files changed +17 -13
branch.c
+1 -1
@@ -291,7 +291,7 @@ void create_branch(const char *head,
291 hashcpy(sha1, commit->object.sha1);
292
293 if (!dont_change_ref) {
294 - lock = lock_any_ref_for_update(ref.buf, NULL, 0);
294 + lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
295 if (!lock)
296 die_errno(_("Failed to lock ref for update"));
297 }
builtin/commit.c
+1 -1
@@ -1618,7 +1618,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1618 !current_head
1619 ? NULL
1620 : current_head->object.sha1,
1621 - 0);
1621 + 0, NULL);
1622
1623 nl = strchr(sb.buf, '\n');
1624 if (nl)
builtin/fetch.c
+2 -1
@@ -246,7 +246,8 @@ static int s_update_ref(const char *action,
246 rla = default_rla.buf;
247 snprintf(msg, sizeof(msg), "%s: %s", rla, action);
248 lock = lock_any_ref_for_update(ref->name,
249 - check_old ? ref->old_sha1 : NULL, 0);
249 + check_old ? ref->old_sha1 : NULL,
250 + 0, NULL);
251 if (!lock)
252 return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
253 STORE_REF_ERROR_OTHER;
builtin/receive-pack.c
+2 -1
@@ -524,7 +524,8 @@ static const char *update(struct command *cmd)
524 return NULL; /* good */
525 }
526 else {
527 - lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
527 + lock = lock_any_ref_for_update(namespaced_name, old_sha1,
528 + 0, NULL);
529 if (!lock) {
530 rp_error("failed to lock %s", name);
531 return "failed to lock";
builtin/reflog.c
+1 -1
@@ -366,7 +366,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
366 * we take the lock for the ref itself to prevent it from
367 * getting updated.
368 */
369 - lock = lock_any_ref_for_update(ref, sha1, 0);
369 + lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
370 if (!lock)
371 return error("cannot lock ref '%s'", ref);
372 log_file = git_pathdup("logs/%s", ref);
builtin/replace.c
+1 -1
@@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
105 else if (!force)
106 die("replace ref '%s' already exists", ref);
107
108 - lock = lock_any_ref_for_update(ref, prev, 0);
108 + lock = lock_any_ref_for_update(ref, prev, 0, NULL);
109 if (!lock)
110 die("%s: cannot lock the ref", ref);
111 if (write_ref_sha1(lock, repl, NULL) < 0)
builtin/tag.c
+1 -1
@@ -577,7 +577,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
577 if (annotate)
578 create_tag(object, tag, &buf, &opt, prev, object);
579
580 - lock = lock_any_ref_for_update(ref.buf, prev, 0);
580 + lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
581 if (!lock)
582 die(_("%s: cannot lock the ref"), ref.buf);
583 if (write_ref_sha1(lock, object, NULL) < 0)
fast-import.c
+1 -1
@@ -1678,7 +1678,7 @@ static int update_branch(struct branch *b)
1678 return 0;
1679 if (read_ref(b->name, old_sha1))
1680 hashclr(old_sha1);
1681 - lock = lock_any_ref_for_update(b->name, old_sha1, 0);
1681 + lock = lock_any_ref_for_update(b->name, old_sha1, 0, NULL);
1682 if (!lock)
1683 return error("Unable to lock %s", b->name);
1684 if (!force_update && !is_null_sha1(old_sha1)) {
refs.c
+4 -3
@@ -2121,11 +2121,12 @@ struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha
2121 }
2122
2123 struct ref_lock *lock_any_ref_for_update(const char *refname,
2124 - const unsigned char *old_sha1, int flags)
2124 + const unsigned char *old_sha1,
2125 + int flags, int *type_p)
2126 {
2127 if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
2128 return NULL;
2128 - return lock_ref_sha1_basic(refname, old_sha1, flags, NULL);
2129 + return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
2130 }
2131
2132 /*
@@ -3174,7 +3175,7 @@ int update_ref(const char *action, const char *refname,
3175 int flags, enum action_on_err onerr)
3176 {
3177 static struct ref_lock *lock;
3177 - lock = lock_any_ref_for_update(refname, oldval, flags);
3178 + lock = lock_any_ref_for_update(refname, oldval, flags, NULL);
3179 if (!lock) {
3180 const char *str = "Cannot lock the ref '%s'.";
3181 switch (onerr) {
refs.h
+1 -1
@@ -137,7 +137,7 @@ extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *
137 #define REF_NODEREF 0x01
138 extern struct ref_lock *lock_any_ref_for_update(const char *refname,
139 const unsigned char *old_sha1,
140 - int flags);
140 + int flags, int *type_p);
141
142 /** Close the file descriptor owned by a lock and return the status */
143 extern int close_ref(struct ref_lock *lock);
sequencer.c
+2 -1
@@ -279,7 +279,8 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
279 read_cache();
280 if (checkout_fast_forward(from, to, 1))
281 exit(1); /* the callee should have complained already */
282 - ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
282 + ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from,
283 + 0, NULL);
284 strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
285 ret = write_ref_sha1(ref_lock, to, sb.buf);
286 strbuf_release(&sb);