summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-06-22 14:03:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-22 20:17:14 (GMT)
commit1c03c4d34771db20b78231359caa6fda28e2d9fe (patch)
tree32d5851eb76677cdf990e10a23884d3fed5d8364 /refs.c
parente2991c80485c646c86f5d80423f9ae983bed120b (diff)
downloadgit-1c03c4d34771db20b78231359caa6fda28e2d9fe.zip
git-1c03c4d34771db20b78231359caa6fda28e2d9fe.tar.gz
git-1c03c4d34771db20b78231359caa6fda28e2d9fe.tar.bz2
delete_ref(): use the usual convention for old_sha1
The ref_transaction_update() family of functions use the following convention for their old_sha1 parameters: * old_sha1 == NULL: Don't check the old value at all. * is_null_sha1(old_sha1): Ensure that the reference didn't exist before the transaction. * otherwise: Ensure that the reference had the specified value before the transaction. delete_ref() had a different convention, namely treating is_null_sha1(old_sha1) as "don't care". Change it to adhere to the standard convention to reduce the scope for confusion. Please note that it is now a bug to pass old_sha1=NULL_SHA1 to delete_ref() (because it doesn't make sense to delete a reference that you already know doesn't exist). This is consistent with the behavior of ref_transaction_delete(). Most of the callers of delete_ref() never pass old_sha1=NULL_SHA1 to delete_ref(), and are therefore unaffected by this change. The two exceptions are: * The call in cmd_update_ref(), which passed NULL_SHA1 if the old value passed in on the command line was 0{40} or the empty string. Change that caller to pass NULL in those cases. Arguably, it should be an error to call "update-ref -d" with the old value set to "does not exist", just as it is for the `--stdin` command "delete". But since this usage was accepted until now, continue to accept it. * The call in delete_branches(), which could pass NULL_SHA1 if deleting a broken or symbolic ref. Change it to pass NULL in these cases. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/refs.c b/refs.c
index d5c3f8d..c5086ae 100644
--- a/refs.c
+++ b/refs.c
@@ -2833,14 +2833,6 @@ int delete_ref(const char *refname, const unsigned char *old_sha1,
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
- /*
- * Treat NULL_SHA1 and NULL alike, to mean "we don't care what
- * the old value of the reference was (or even if it didn't
- * exist)":
- */
- if (old_sha1 && is_null_sha1(old_sha1))
- old_sha1 = NULL;
-
transaction = ref_transaction_begin(&err);
if (!transaction ||
ref_transaction_delete(transaction, refname, old_sha1,