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