]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6411-merge-filemode.sh
Sync with 2.36.3
[thirdparty/git.git] / t / t6411-merge-filemode.sh
CommitLineData
f78d1fe2
JK
1#!/bin/sh
2
3test_description='merge: handle file mode'
5902f5f4 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
f78d1fe2
JK
7. ./test-lib.sh
8
9test_expect_success 'set up mode change in one branch' '
10 : >file1 &&
11 git add file1 &&
12 git commit -m initial &&
5902f5f4 13 git checkout -b a1 main &&
f78d1fe2
JK
14 : >dummy &&
15 git add dummy &&
16 git commit -m a &&
5902f5f4 17 git checkout -b b1 main &&
f78d1fe2
JK
18 test_chmod +x file1 &&
19 git add file1 &&
20 git commit -m b1
21'
22
23do_one_mode () {
24 strategy=$1
25 us=$2
26 them=$3
27 test_expect_success "resolve single mode change ($strategy, $us)" '
28 git checkout -f $us &&
29 git merge -s $strategy $them &&
30 git ls-files -s file1 | grep ^100755
31 '
32
33 test_expect_success FILEMODE "verify executable bit on file ($strategy, $us)" '
34 test -x file1
35 '
36}
37
38do_one_mode recursive a1 b1
39do_one_mode recursive b1 a1
40do_one_mode resolve a1 b1
41do_one_mode resolve b1 a1
42
43test_expect_success 'set up mode change in both branches' '
44 git reset --hard HEAD &&
5902f5f4 45 git checkout -b a2 main &&
f78d1fe2
JK
46 : >file2 &&
47 H=$(git hash-object file2) &&
48 test_chmod +x file2 &&
49 git commit -m a2 &&
5902f5f4 50 git checkout -b b2 main &&
f78d1fe2
JK
51 : >file2 &&
52 git add file2 &&
53 git commit -m b2 &&
020b813f
ES
54 cat >expect <<-EOF
55 100755 $H 2 file2
56 100644 $H 3 file2
57 EOF
f78d1fe2
JK
58'
59
60do_both_modes () {
61 strategy=$1
62 test_expect_success "detect conflict on double mode change ($strategy)" '
63 git reset --hard &&
64 git checkout -f a2 &&
65 test_must_fail git merge -s $strategy b2 &&
66 git ls-files -u >actual &&
dcbaa0b3 67 test_cmp expect actual &&
f78d1fe2
JK
68 git ls-files -s file2 | grep ^100755
69 '
70
71 test_expect_success FILEMODE "verify executable bit on file ($strategy)" '
72 test -x file2
73 '
74}
75
76# both sides are equivalent, so no need to run both ways
77do_both_modes recursive
78do_both_modes resolve
79
72fac66b
JK
80test_expect_success 'set up delete/modechange scenario' '
81 git reset --hard &&
5902f5f4 82 git checkout -b deletion main &&
72fac66b
JK
83 git rm file1 &&
84 git commit -m deletion
85'
86
87do_delete_modechange () {
88 strategy=$1
89 us=$2
90 them=$3
91 test_expect_success "detect delete/modechange conflict ($strategy, $us)" '
92 git reset --hard &&
93 git checkout $us &&
94 test_must_fail git merge -s $strategy $them
95 '
96}
97
98do_delete_modechange recursive b1 deletion
99do_delete_modechange recursive deletion b1
100do_delete_modechange resolve b1 deletion
101do_delete_modechange resolve deletion b1
102
f78d1fe2 103test_done