ref_transaction_delete(): check that old_sha1 is not null_sha1
authorMichael Haggerty <mhagger@alum.mit.edu>
Tue, 17 Feb 2015 17:00:20 +0000 (18:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Feb 2015 19:24:55 +0000 (11:24 -0800)
It makes no sense to delete a reference that is already known not to
exist.

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>
refs.c
diff --git a/refs.c b/refs.c
index b9cf284f310d52d0be34fd51b236e08cdfc2f9c0..d5bfd1179044b9a6aeec1492a31d2a907b951d36 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3702,6 +3702,8 @@ int ref_transaction_delete(struct ref_transaction *transaction,
                           unsigned int flags, const char *msg,
                           struct strbuf *err)
 {
+       if (old_sha1 && is_null_sha1(old_sha1))
+               die("BUG: delete called with old_sha1 set to zeros");
        return ref_transaction_update(transaction, refname,
                                      null_sha1, old_sha1,
                                      flags, msg, err);