3 test_description
='Test git update-ref with D/F conflicts'
6 test_update_rejected
() {
12 printf "create $prefix/%s $C\n" $before |
13 git update-ref
--stdin &&
14 git for-each-ref
$prefix >unchanged
&&
19 printf "create $prefix/%s $C\n" $create >input
&&
20 test_must_fail git update-ref
--stdin <input
2>output.err
&&
21 grep -F "$error" output.err
&&
22 git for-each-ref
$prefix >actual
&&
23 test_cmp unchanged actual
28 test_expect_success
'setup' '
30 git commit --allow-empty -m Initial &&
31 C=$(git rev-parse HEAD)
35 test_expect_success
'existing loose ref is a simple prefix of new' '
38 test_update_rejected $prefix "a c e" false "b c/x d" \
39 "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
43 test_expect_success
'existing packed ref is a simple prefix of new' '
46 test_update_rejected $prefix "a c e" true "b c/x d" \
47 "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"
51 test_expect_success
'existing loose ref is a deeper prefix of new' '
54 test_update_rejected $prefix "a c e" false "b c/x/y d" \
55 "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
59 test_expect_success
'existing packed ref is a deeper prefix of new' '
62 test_update_rejected $prefix "a c e" true "b c/x/y d" \
63 "$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"
67 test_expect_success
'new ref is a simple prefix of existing loose' '
70 test_update_rejected $prefix "a c/x e" false "b c d" \
71 "$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
75 test_expect_success
'new ref is a simple prefix of existing packed' '
78 test_update_rejected $prefix "a c/x e" true "b c d" \
79 "$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"
83 test_expect_success
'new ref is a deeper prefix of existing loose' '
86 test_update_rejected $prefix "a c/x/y e" false "b c d" \
87 "$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
91 test_expect_success
'new ref is a deeper prefix of existing packed' '
94 test_update_rejected $prefix "a c/x/y e" true "b c d" \
95 "$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"
99 test_expect_success
'one new ref is a simple prefix of another' '
102 test_update_rejected $prefix "a e" false "b c c/x d" \
103 "cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time"