Code

Move commit_list_count() to commit.c
[git.git] / t / t1400-update-ref.sh
index 71ab2dd0eedd5fa79300fe84fbd168b538dfd36c..f387d46f1a17ac9f9d3319c4da7e30a6c6326c67 100755 (executable)
@@ -32,6 +32,22 @@ test_expect_success \
        "create $m" \
        "git update-ref $m $B $A &&
         test $B"' = $(cat .git/'"$m"')'
+test_expect_success "fail to delete $m with stale ref" '
+       test_must_fail git update-ref -d $m $A &&
+       test $B = "$(cat .git/$m)"
+'
+test_expect_success "delete $m" '
+       git update-ref -d $m $B &&
+       ! test -f .git/$m
+'
+rm -f .git/$m
+
+test_expect_success "delete $m without oldvalue verification" "
+       git update-ref $m $A &&
+       test $A = \$(cat .git/$m) &&
+       git update-ref -d $m &&
+       ! test -f .git/$m
+"
 rm -f .git/$m
 
 test_expect_success \
@@ -49,25 +65,33 @@ test_expect_success \
        "create $m (by HEAD)" \
        "git update-ref HEAD $B $A &&
         test $B"' = $(cat .git/'"$m"')'
+test_expect_success "fail to delete $m (by HEAD) with stale ref" '
+       test_must_fail git update-ref -d HEAD $A &&
+       test $B = $(cat .git/$m)
+'
+test_expect_success "delete $m (by HEAD)" '
+       git update-ref -d HEAD $B &&
+       ! test -f .git/$m
+'
 rm -f .git/$m
 
-test_expect_failure \
-       '(not) create HEAD with old sha1' \
-       "git update-ref HEAD $A $B"
-test_expect_failure \
-       "(not) prior created .git/$m" \
-       "test -f .git/$m"
+test_expect_success '(not) create HEAD with old sha1' "
+       ! git update-ref HEAD $A $B
+"
+test_expect_success "(not) prior created .git/$m" "
+       ! test -f .git/$m
+"
 rm -f .git/$m
 
 test_expect_success \
        "create HEAD" \
        "git update-ref HEAD $A"
-test_expect_failure \
-       '(not) change HEAD with wrong SHA1' \
-       "git update-ref HEAD $B $Z"
-test_expect_failure \
-       "(not) changed .git/$m" \
-       "test $B"' = $(cat .git/'"$m"')'
+test_expect_success '(not) change HEAD with wrong SHA1' "
+       ! git update-ref HEAD $B $Z
+"
+test_expect_success "(not) changed .git/$m" "
+       ! test $B"' = $(cat .git/'"$m"')
+'
 rm -f .git/$m
 
 : a repository with working tree always has reflog these days...