resolve-undo: "checkout -m path" uses resolve-undo information
[git/dscho.git] / t / t2030-unresolve-info.sh
blobea65f391c1671b141d2d071aad0f7df7ca4ea4ac
1 #!/bin/sh
3 test_description='undoing resolution'
5 . ./test-lib.sh
7 check_resolve_undo () {
8 msg=$1
9 shift
10 while case $# in
11 0) break ;;
12 1|2|3) die "Bug in check-resolve-undo test" ;;
13 esac
15 path=$1
16 shift
17 for stage in 1 2 3
19 sha1=$1
20 shift
21 case "$sha1" in
22 '') continue ;;
23 esac
24 sha1=$(git rev-parse --verify "$sha1")
25 printf "100644 %s %s\t%s\n" $sha1 $stage $path
26 done
27 done >"$msg.expect" &&
28 git ls-files --resolve-undo >"$msg.actual" &&
29 test_cmp "$msg.expect" "$msg.actual"
32 prime_resolve_undo () {
33 git reset --hard &&
34 git checkout second^0 &&
35 test_tick &&
36 test_must_fail git merge third^0 &&
37 echo merge does not leave anything &&
38 check_resolve_undo empty &&
39 echo different >file &&
40 git add 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 &&
47 git branch side &&
48 git branch another &&
49 test_commit second file second &&
50 git checkout side &&
51 test_commit third file third &&
52 git checkout another &&
53 test_commit fourth file fourth &&
54 git checkout master
57 test_expect_success 'add records switch clears' '
58 prime_resolve_undo &&
59 test_tick &&
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' '
69 prime_resolve_undo &&
70 test_tick &&
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 &&
79 git rm -f file &&
80 echo resolving records &&
81 check_resolve_undo recorded file initial:file HEAD:file fourth:file &&
83 git reset --hard &&
84 echo resetting discards &&
85 check_resolve_undo discarded
88 test_expect_success 'plumbing clears' '
89 prime_resolve_undo &&
90 test_tick &&
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 &&
102 git diff HEAD &&
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 &&
107 git diff >actual &&
108 grep "^++<<<<<<<" actual
111 test_done