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