diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2015-02-17 18:00:15 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-02-17 11:22:50 -0800 |
commit | 1d147bdff0b8132d3aa53a46df8dbab7b673b796 (patch) | |
tree | bc10a34c8136b89c3e646bb9eb1d6ea840f9376b /builtin | |
parent | struct ref_update: move "have_old" into "flags" (diff) | |
download | tgif-1d147bdff0b8132d3aa53a46df8dbab7b673b796.tar.xz |
ref_transaction_update(): remove "have_old" parameter
Instead, verify the reference's old value if and only if old_sha1 is
non-NULL.
ref_transaction_delete() will get the same treatment in a moment.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit.c | 2 | ||||
-rw-r--r-- | builtin/fetch.c | 6 | ||||
-rw-r--r-- | builtin/receive-pack.c | 2 | ||||
-rw-r--r-- | builtin/replace.c | 2 | ||||
-rw-r--r-- | builtin/tag.c | 2 | ||||
-rw-r--r-- | builtin/update-ref.c | 7 |
6 files changed, 12 insertions, 9 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 7f467133b8..8afb0ff5e0 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1767,7 +1767,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) ref_transaction_update(transaction, "HEAD", sha1, current_head ? current_head->object.sha1 : NULL, - 0, !!current_head, sb.buf, &err) || + 0, sb.buf, &err) || ref_transaction_commit(transaction, &err)) { rollback_index_files(); die("%s", err.buf); diff --git a/builtin/fetch.c b/builtin/fetch.c index 7b84d35d83..719bf4f244 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -416,8 +416,10 @@ static int s_update_ref(const char *action, transaction = ref_transaction_begin(&err); if (!transaction || - ref_transaction_update(transaction, ref->name, ref->new_sha1, - ref->old_sha1, 0, check_old, msg, &err)) + ref_transaction_update(transaction, ref->name, + ref->new_sha1, + check_old ? ref->old_sha1 : NULL, + 0, msg, &err)) goto fail; ret = ref_transaction_commit(transaction, &err); diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index e0ce78e5a0..0be50e9540 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -971,7 +971,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) if (ref_transaction_update(transaction, namespaced_name, new_sha1, old_sha1, - 0, 1, "push", + 0, "push", &err)) { rp_error("%s", err.buf); strbuf_release(&err); diff --git a/builtin/replace.c b/builtin/replace.c index 85d39b58d8..54bf01acb4 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -172,7 +172,7 @@ static int replace_object_sha1(const char *object_ref, transaction = ref_transaction_begin(&err); if (!transaction || ref_transaction_update(transaction, ref, repl, prev, - 0, 1, NULL, &err) || + 0, NULL, &err) || ref_transaction_commit(transaction, &err)) die("%s", err.buf); diff --git a/builtin/tag.c b/builtin/tag.c index 6dc85a9d5e..4194b9a711 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -733,7 +733,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) transaction = ref_transaction_begin(&err); if (!transaction || ref_transaction_update(transaction, ref.buf, object, prev, - 0, 1, NULL, &err) || + 0, NULL, &err) || ref_transaction_commit(transaction, &err)) die("%s", err.buf); ref_transaction_free(transaction); diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 9a1659e11e..1ad6ce1877 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -198,8 +198,9 @@ static const char *parse_cmd_update(struct ref_transaction *transaction, if (*next != line_termination) die("update %s: extra input: %s", refname, next); - if (ref_transaction_update(transaction, refname, new_sha1, old_sha1, - update_flags, have_old, msg, &err)) + if (ref_transaction_update(transaction, refname, + new_sha1, have_old ? old_sha1 : NULL, + update_flags, msg, &err)) die("%s", err.buf); update_flags = 0; @@ -297,7 +298,7 @@ static const char *parse_cmd_verify(struct ref_transaction *transaction, die("verify %s: extra input: %s", refname, next); if (ref_transaction_update(transaction, refname, new_sha1, old_sha1, - update_flags, 1, msg, &err)) + update_flags, msg, &err)) die("%s", err.buf); update_flags = 0; |