]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ref_transaction_delete(): remove "have_old" parameter
authorMichael Haggerty <mhagger@alum.mit.edu>
Tue, 17 Feb 2015 17:00:16 +0000 (18:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Feb 2015 19:23:48 +0000 (11:23 -0800)
Instead, verify the reference's old value if and only if old_sha1 is
non-NULL.

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>
builtin/receive-pack.c
builtin/update-ref.c
refs.c
refs.h

index 0be50e95401561eca0b379fa5203ec17f007ca41..70e9ce5f96f3e8da78e4b5746580869f9ae65330 100644 (file)
@@ -953,8 +953,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
                if (ref_transaction_delete(transaction,
                                           namespaced_name,
                                           old_sha1,
-                                          0, old_sha1 != NULL,
-                                          "push", &err)) {
+                                          0, "push", &err)) {
                        rp_error("%s", err.buf);
                        strbuf_release(&err);
                        return "failed to delete";
index 1ad6ce1877ed203ec2593aeb1bd12cc6282fdae7..226995f0290a3323d86b7c6649fa688f32aaa76b 100644 (file)
@@ -265,8 +265,9 @@ static const char *parse_cmd_delete(struct ref_transaction *transaction,
        if (*next != line_termination)
                die("delete %s: extra input: %s", refname, next);
 
-       if (ref_transaction_delete(transaction, refname, old_sha1,
-                                  update_flags, have_old, msg, &err))
+       if (ref_transaction_delete(transaction, refname,
+                                  have_old ? old_sha1 : NULL,
+                                  update_flags, msg, &err))
                die("%s", err.buf);
 
        update_flags = 0;
diff --git a/refs.c b/refs.c
index e88817c623e687804a6e2e911f64704e456cbe32..e3c4ab5fd56e07dbeb49e6142cb9e80e7d6ff0fa 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2576,7 +2576,7 @@ static void prune_ref(struct ref_to_prune *r)
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_delete(transaction, r->name, r->sha1,
-                                  REF_ISPRUNING, 1, NULL, &err) ||
+                                  REF_ISPRUNING, NULL, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
                error("%s", err.buf);
@@ -2753,8 +2753,9 @@ int delete_ref(const char *refname, const unsigned char *sha1, unsigned int flag
 
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
-           ref_transaction_delete(transaction, refname, sha1, flags,
-                                  sha1 && !is_null_sha1(sha1), NULL, &err) ||
+           ref_transaction_delete(transaction, refname,
+                                  (sha1 && !is_null_sha1(sha1)) ? sha1 : NULL,
+                                  flags, NULL, &err) ||
            ref_transaction_commit(transaction, &err)) {
                error("%s", err.buf);
                ref_transaction_free(transaction);
@@ -3696,11 +3697,11 @@ int ref_transaction_create(struct ref_transaction *transaction,
 int ref_transaction_delete(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *old_sha1,
-                          unsigned int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err)
 {
        return ref_transaction_update(transaction, refname,
-                                     null_sha1, have_old ? old_sha1 : NULL,
+                                     null_sha1, old_sha1,
                                      flags, msg, err);
 }
 
diff --git a/refs.h b/refs.h
index dced4c9464cfdfe9257634a766d8557767d03b5a..100731d1c87b6130e301f1c7bbc2e765828959e7 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -295,8 +295,8 @@ int ref_transaction_create(struct ref_transaction *transaction,
                           struct strbuf *err);
 
 /*
- * Add a reference deletion to transaction.  If have_old is true, then
- * old_sha1 holds the value that the reference should have had before
+ * Add a reference deletion to transaction.  If old_sha1 is non-NULL, then
+ * it holds the value that the reference should have had before
  * the update (which must not be the null SHA-1).
  * Function returns 0 on success and non-zero on failure. A failure to delete
  * means that the transaction as a whole has failed and will need to be
@@ -305,7 +305,7 @@ int ref_transaction_create(struct ref_transaction *transaction,
 int ref_transaction_delete(struct ref_transaction *transaction,
                           const char *refname,
                           const unsigned char *old_sha1,
-                          unsigned int flags, int have_old, const char *msg,
+                          unsigned int flags, const char *msg,
                           struct strbuf *err);
 
 /*