builtin-am: support --keep-cr, am.keepcr
[git.git] / t / t1404-update-ref-df-conflicts.sh
blob66bafb5cf41775a27abf6f9de3eeca4f01887e79
1 #!/bin/sh
3 test_description='Test git update-ref with D/F conflicts'
4 . ./test-lib.sh
6 test_update_rejected () {
7 prefix="$1" &&
8 before="$2" &&
9 pack="$3" &&
10 create="$4" &&
11 error="$5" &&
12 printf "create $prefix/%s $C\n" $before |
13 git update-ref --stdin &&
14 git for-each-ref $prefix >unchanged &&
15 if $pack
16 then
17 git pack-refs --all
18 fi &&
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
26 Q="'"
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' '
37 prefix=refs/1l &&
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' '
45 prefix=refs/1p &&
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' '
53 prefix=refs/2l &&
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' '
61 prefix=refs/2p &&
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' '
69 prefix=refs/3l &&
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' '
77 prefix=refs/3p &&
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' '
85 prefix=refs/4l &&
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' '
93 prefix=refs/4p &&
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' '
101 prefix=refs/5 &&
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"
107 test_done