t6031-test-merge-recursive: do not forget to add file to be committed
[git] / t / t6031-merge-recursive.sh
1 #!/bin/sh
2
3 test_description='merge-recursive: handle file mode'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
6
7 test_expect_success 'mode change in one branch: keep changed version' '
8         : >file1 &&
9         git add file1 &&
10         git commit -m initial &&
11         git checkout -b a1 master &&
12         : >dummy &&
13         git add dummy &&
14         git commit -m a &&
15         git checkout -b b1 master &&
16         test_chmod +x file1 &&
17         git add file1 &&
18         git commit -m b1 &&
19         git checkout a1 &&
20         git merge-recursive master -- a1 b1 &&
21         git ls-files -s file1 | grep ^100755
22 '
23
24 test_expect_success FILEMODE 'verify executable bit on file' '
25         test -x file1
26 '
27
28 test_expect_success 'mode change in both branches: expect conflict' '
29         git reset --hard HEAD &&
30         git checkout -b a2 master &&
31         : >file2 &&
32         H=$(git hash-object file2) &&
33         test_chmod +x file2 &&
34         git commit -m a2 &&
35         git checkout -b b2 master &&
36         : >file2 &&
37         git add file2 &&
38         git commit -m b2 &&
39         git checkout a2 &&
40         (
41                 git merge-recursive master -- a2 b2
42                 test $? = 1
43         ) &&
44         git ls-files -u >actual &&
45         (
46                 echo "100755 $H 2       file2"
47                 echo "100644 $H 3       file2"
48         ) >expect &&
49         test_cmp actual expect &&
50         git ls-files -s file2 | grep ^100755
51 '
52
53 test_expect_success FILEMODE 'verify executable bit on file' '
54         test -x file2
55 '
56
57 test_expect_success 'merging with triple rename across D/F conflict' '
58         git reset --hard HEAD &&
59         git checkout -b main &&
60         git rm -rf . &&
61
62         echo "just a file" >sub1 &&
63         mkdir -p sub2 &&
64         echo content1 >sub2/file1 &&
65         echo content2 >sub2/file2 &&
66         echo content3 >sub2/file3 &&
67         mkdir simple &&
68         echo base >simple/bar &&
69         git add -A &&
70         test_tick &&
71         git commit -m base &&
72
73         git checkout -b other &&
74         echo more >>simple/bar &&
75         test_tick &&
76         git commit -a -m changesimplefile &&
77
78         git checkout main &&
79         git rm sub1 &&
80         git mv sub2 sub1 &&
81         test_tick &&
82         git commit -m changefiletodir &&
83
84         test_tick &&
85         git merge other
86 '
87
88 test_done