blob: 984480271c0deef50dddae215a59aa62471c0e47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#!/bin/sh
test_description='undoing resolution'
. ./test-lib.sh
check_resolve_undo () {
msg=$1
shift
while case $# in
0) break ;;
1|2|3) die "Bug in check-resolve-undo test" ;;
esac
do
path=$1
shift
for stage in 1 2 3
do
sha1=$1
shift
case "$sha1" in
'') continue ;;
esac
sha1=$(git rev-parse --verify "$sha1")
printf "100644 %s %s\t%s\n" $sha1 $stage $path
done
done >"$msg.expect" &&
git ls-files --resolve-undo >"$msg.actual" &&
test_cmp "$msg.expect" "$msg.actual"
}
prime_resolve_undo () {
git reset --hard &&
git checkout second^0 &&
test_tick &&
test_must_fail git merge third^0 &&
echo merge does not leave anything &&
check_resolve_undo empty &&
echo different >file &&
git add file &&
echo resolving records &&
check_resolve_undo recorded file initial:file second:file third:file
}
test_expect_success setup '
test_commit initial file first &&
git branch side &&
git branch another &&
test_commit second file second &&
git checkout side &&
test_commit third file third &&
git checkout another &&
test_commit fourth file fourth &&
git checkout master
'
test_expect_success 'add records switch clears' '
prime_resolve_undo &&
test_tick &&
git commit -m merged &&
echo committing keeps &&
check_resolve_undo kept file initial:file second:file third:file &&
git checkout second^0 &&
echo switching clears &&
check_resolve_undo cleared
'
test_expect_success 'rm records reset clears' '
prime_resolve_undo &&
test_tick &&
git commit -m merged &&
echo committing keeps &&
check_resolve_undo kept file initial:file second:file third:file &&
echo merge clears upfront &&
test_must_fail git merge fourth^0 &&
check_resolve_undo nuked &&
git rm -f file &&
echo resolving records &&
check_resolve_undo recorded file initial:file HEAD:file fourth:file &&
git reset --hard &&
echo resetting discards &&
check_resolve_undo discarded
'
test_expect_success 'plumbing clears' '
prime_resolve_undo &&
test_tick &&
git commit -m merged &&
echo committing keeps &&
check_resolve_undo kept file initial:file second:file third:file &&
echo plumbing clear &&
git update-index --clear-resolve-undo &&
check_resolve_undo cleared
'
test_done
|