Add some tests for git update-ref -d
Signed-off-by: Karl Hasselström <kha@treskal.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karl Hasselström committed
May 25, 2008 at 18:14 UTC
40672a19042e618019cb4f7ba78ae25e554ce756
1 file changed
+16
t/t1400-update-ref.sh
+16
@@ -32,6 +32,14 @@ test_expect_success \
32
"create $m" \
33
"git update-ref $m $B $A &&
34
test $B"' = $(cat .git/'"$m"')'
35
+test_expect_success "fail to delete $m with stale ref" '
36
+ test_must_fail git update-ref -d $m $A &&
37
+ test $B = "$(cat .git/$m)"
38
+'
39
+test_expect_success "delete $m" '
40
+ git update-ref -d $m $B &&
41
+ ! test -f .git/$m
42
+'
43
rm -f .git/$m
44
45
test_expect_success \
@@ -49,6 +57,14 @@ test_expect_success \
57
"create $m (by HEAD)" \
58
"git update-ref HEAD $B $A &&
59
test $B"' = $(cat .git/'"$m"')'
60
+test_expect_success "fail to delete $m (by HEAD) with stale ref" '
61
+ test_must_fail git update-ref -d HEAD $A &&
62
+ test $B = $(cat .git/$m)
63
+'
64
+test_expect_success "delete $m (by HEAD)" '
65
+ git update-ref -d HEAD $B &&
66
+ ! test -f .git/$m
67
+'
68
rm -f .git/$m
69
70
test_expect_success '(not) create HEAD with old sha1' "