]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2023-checkout-m.sh
l10n: fr v2.23.0 round 2
[thirdparty/git.git] / t / t2023-checkout-m.sh
CommitLineData
3d0b0517
PH
1#!/bin/sh
2
3test_description='checkout -m -- <conflicted path>
4
5Ensures that checkout -m on a resolved file restores the conflicted file'
6
7. ./test-lib.sh
8
9test_expect_success setup '
10 test_tick &&
11 test_commit both.txt both.txt initial &&
12 git branch topic &&
13 test_commit modified_in_master both.txt in_master &&
14 test_commit added_in_master each.txt in_master &&
15 git checkout topic &&
16 test_commit modified_in_topic both.txt in_topic &&
17 test_commit added_in_topic each.txt in_topic
18'
19
5cd7fadc
ÆAB
20test_expect_success 'git merge master' '
21 test_must_fail git merge master
22'
3d0b0517
PH
23
24clean_branchnames () {
25 # Remove branch names after conflict lines
26 sed 's/^\([<>]\{5,\}\) .*$/\1/'
27}
28
29test_expect_success '-m restores 2-way conflicted+resolved file' '
30 cp each.txt each.txt.conflicted &&
31 echo resolved >each.txt &&
32 git add each.txt &&
33 git checkout -m -- each.txt &&
34 clean_branchnames <each.txt >each.txt.cleaned &&
35 clean_branchnames <each.txt.conflicted >each.txt.conflicted.cleaned &&
36 test_cmp each.txt.conflicted.cleaned each.txt.cleaned
37'
38
39test_expect_success '-m restores 3-way conflicted+resolved file' '
40 cp both.txt both.txt.conflicted &&
41 echo resolved >both.txt &&
42 git add both.txt &&
43 git checkout -m -- both.txt &&
44 clean_branchnames <both.txt >both.txt.cleaned &&
45 clean_branchnames <both.txt.conflicted >both.txt.conflicted.cleaned &&
46 test_cmp both.txt.conflicted.cleaned both.txt.cleaned
47'
48
ab5af825
NTND
49test_expect_success 'force checkout a conflict file creates stage zero entry' '
50 git init co-force &&
51 (
52 cd co-force &&
53 echo a >a &&
54 git add a &&
55 git commit -ama &&
56 A_OBJ=$(git rev-parse :a) &&
57 git branch topic &&
58 echo b >a &&
59 git commit -amb &&
60 B_OBJ=$(git rev-parse :a) &&
61 git checkout topic &&
62 echo c >a &&
63 C_OBJ=$(git hash-object a) &&
64 git checkout -m master &&
65 test_cmp_rev :1:a $A_OBJ &&
66 test_cmp_rev :2:a $B_OBJ &&
67 test_cmp_rev :3:a $C_OBJ &&
68 git checkout -f topic &&
69 test_cmp_rev :0:a $A_OBJ
70 )
71'
72
3d0b0517 73test_done