3 test_description
='undoing resolution'
7 check_resolve_undo
() {
12 1|
2|
3) die
"Bug in check-resolve-undo test" ;;
24 sha1
=$
(git rev-parse
--verify "$sha1")
25 printf "100644 %s %s\t%s\n" $sha1 $stage $path
27 done >"$msg.expect" &&
28 git ls-files
--resolve-undo >"$msg.actual" &&
29 test_cmp
"$msg.expect" "$msg.actual"
32 prime_resolve_undo
() {
34 git checkout second^
0 &&
36 test_must_fail git merge third^
0 &&
37 echo merge does not leave anything
&&
38 check_resolve_undo empty
&&
39 echo different
>file &&
41 echo resolving records
&&
42 check_resolve_undo recorded
file initial
:file second
:file third
:file
45 test_expect_success setup
'
46 test_commit initial file first &&
49 test_commit second file second &&
51 test_commit third file third &&
52 git checkout another &&
53 test_commit fourth file fourth &&
57 test_expect_success
'add records switch clears' '
60 git commit -m merged &&
61 echo committing keeps &&
62 check_resolve_undo kept file initial:file second:file third:file &&
63 git checkout second^0 &&
64 echo switching clears &&
65 check_resolve_undo cleared
68 test_expect_success
'rm records reset clears' '
71 git commit -m merged &&
72 echo committing keeps &&
73 check_resolve_undo kept file initial:file second:file third:file &&
75 echo merge clears upfront &&
76 test_must_fail git merge fourth^0 &&
77 check_resolve_undo nuked &&
80 echo resolving records &&
81 check_resolve_undo recorded file initial:file HEAD:file fourth:file &&
84 echo resetting discards &&
85 check_resolve_undo discarded
88 test_expect_success
'plumbing clears' '
91 git commit -m merged &&
92 echo committing keeps &&
93 check_resolve_undo kept file initial:file second:file third:file &&
95 echo plumbing clear &&
96 git update-index --clear-resolve-undo &&
97 check_resolve_undo cleared
100 test_expect_success
'add records checkout -m undoes' '
101 prime_resolve_undo &&
103 git checkout --conflict=merge file &&
104 echo checkout used the record and removed it &&
105 check_resolve_undo removed &&
106 echo the index and the work tree is unmerged again &&
108 grep "^++<<<<<<<" actual
111 test_expect_success
'unmerge with plumbing' '
112 prime_resolve_undo &&
113 git update-index --unresolve file &&
114 git ls-files -u >actual &&
115 test $(wc -l <actual) = 3
118 test_expect_success
'rerere and rerere --forget' '
119 mkdir .git/rr-cache &&
120 prime_resolve_undo &&
121 echo record the resolution &&
123 rerere_id=$(cd .git/rr-cache && echo */postimage) &&
124 rerere_id=${rerere_id%/postimage} &&
125 test -f .git/rr-cache/$rerere_id/postimage &&
126 git checkout -m file &&
127 echo resurrect the conflict &&
128 grep "^=======" file &&
129 echo reresolve the conflict &&
131 test "z$(cat file)" = zdifferent &&
132 echo register the resolution again &&
134 check_resolve_undo kept file initial:file second:file third:file &&
135 test -z "$(git ls-files -u)" &&
136 git rerere forget file &&
137 ! test -f .git/rr-cache/$rerere_id/postimage &&
138 tr "\0" "\n" <.git/MERGE_RR >actual &&
139 echo "$rerere_id file" >expect &&
140 test_cmp expect actual