aboutsummaryrefslogtreecommitdiff
path: root/t/t1400-update-ref.sh
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-12-11 00:47:52 +0100
committerJunio C Hamano <gitster@pobox.com>2014-12-11 11:56:53 -0800
commit0e729c7ed5b3c0c6be38bf8d8405b1b7f5a74a3f (patch)
treecfa87ef159e1839d622ce73648a4b0182f24bd0a /t/t1400-update-ref.sh
parenta46e41fca301be48130cca80b45027eff328903d (diff)
downloadgit-0e729c7ed5b3c0c6be38bf8d8405b1b7f5a74a3f.tar.gz
git-0e729c7ed5b3c0c6be38bf8d8405b1b7f5a74a3f.tar.xz
update-ref: fix "verify" command with missing <oldvalue>
If "git update-ref --stdin" was given a "verify" command with no "<newvalue>" at all (not even zeros), the code was mistakenly setting have_old=0 (and leaving old_sha1 uninitialized). But this is incorrect: this command is supposed to verify that the reference doesn't exist. So in this case we really need old_sha1 to be set to null_sha1 and have_old to be set to 1. Moreover, since have_old was being set to zero, *no* check of the old value was being done, so the new value of the reference was being set unconditionally to the value in new_sha1. new_sha1, in turn, was set to null_sha1 in the expectation that that was the old value and it shouldn't be changed. But because the precondition was not being checked, the result was that the reference was being deleted unconditionally. So, if <oldvalue> is missing, set have_old unconditionally and set old_sha1 to null_sha1. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Acked-by: Brad King <brad.king@kitware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1400-update-ref.sh')
-rwxr-xr-xt/t1400-update-ref.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 6a3cdd1ac..6805b9e6b 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -655,7 +655,7 @@ test_expect_success 'stdin verify fails for mistaken null value' '
test_cmp expect actual
'
-test_expect_failure 'stdin verify fails for mistaken empty value' '
+test_expect_success 'stdin verify fails for mistaken empty value' '
M=$(git rev-parse $m) &&
test_when_finished "git update-ref $m $M" &&
git rev-parse $m >expect &&
@@ -1020,7 +1020,7 @@ test_expect_success 'stdin -z verify fails for mistaken null value' '
test_cmp expect actual
'
-test_expect_failure 'stdin -z verify fails for mistaken empty value' '
+test_expect_success 'stdin -z verify fails for mistaken empty value' '
M=$(git rev-parse $m) &&
test_when_finished "git update-ref $m $M" &&
git rev-parse $m >expect &&