Skip to content

Commit 40672a1

Browse files
kwiberggitster
authored andcommitted
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>
1 parent 3beb56b commit 40672a1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

t/t1400-update-ref.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ test_expect_success \
3232
"create $m" \
3333
"git update-ref $m $B $A &&
3434
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+
'
3543
rm -f .git/$m
3644

3745
test_expect_success \
@@ -49,6 +57,14 @@ test_expect_success \
4957
"create $m (by HEAD)" \
5058
"git update-ref HEAD $B $A &&
5159
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+
'
5268
rm -f .git/$m
5369

5470
test_expect_success '(not) create HEAD with old sha1' "

0 commit comments

Comments
 (0)