delete_ref(): handle special case more explicitly

delete_ref() uses a different convention for its old_sha1 parameter than, say, ref_transaction_delete(): NULL_SHA1 means not to check the old value. Make this fact a little bit clearer in the code by handling it in explicit, commented code rather than burying it in a conditional expression. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jun 22, 2015 at 16:02 UTC fc67a0825caaff4eb5d4afdcc626263c8d214f36
1 file changed +9 -2
refs.c
+9 -2
@@ -2807,10 +2807,17 @@ int delete_ref(const char *refname, const unsigned char *old_sha1,
2807 struct ref_transaction *transaction;
2808 struct strbuf err = STRBUF_INIT;
2809
2810 + /*
2811 + * Treat NULL_SHA1 and NULL alike, to mean "we don't care what
2812 + * the old value of the reference was (or even if it didn't
2813 + * exist)":
2814 + */
2815 + if (old_sha1 && is_null_sha1(old_sha1))
2816 + old_sha1 = NULL;
2817 +
2818 transaction = ref_transaction_begin(&err);
2819 if (!transaction ||
2812 - ref_transaction_delete(transaction, refname,
2813 - (old_sha1 && !is_null_sha1(old_sha1)) ? old_sha1 : NULL,
2820 + ref_transaction_delete(transaction, refname, old_sha1,
2821 flags, NULL, &err) ||
2822 ref_transaction_commit(transaction, &err)) {
2823 error("%s", err.buf);