SubmittingPatches: mention doc-diff
[git/raj.git] / t / t6031-merge-filemode.sh
blob7d06461f1396583f7ec568c9bd5bb17735938e34
1 #!/bin/sh
3 test_description='merge: handle file mode'
4 . ./test-lib.sh
6 test_expect_success 'set up mode change in one branch' '
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 add file1 &&
17 git commit -m b1
20 do_one_mode () {
21 strategy=$1
22 us=$2
23 them=$3
24 test_expect_success "resolve single mode change ($strategy, $us)" '
25 git checkout -f $us &&
26 git merge -s $strategy $them &&
27 git ls-files -s file1 | grep ^100755
30 test_expect_success FILEMODE "verify executable bit on file ($strategy, $us)" '
31 test -x file1
35 do_one_mode recursive a1 b1
36 do_one_mode recursive b1 a1
37 do_one_mode resolve a1 b1
38 do_one_mode resolve b1 a1
40 test_expect_success 'set up mode change in both branches' '
41 git reset --hard HEAD &&
42 git checkout -b a2 master &&
43 : >file2 &&
44 H=$(git hash-object file2) &&
45 test_chmod +x file2 &&
46 git commit -m a2 &&
47 git checkout -b b2 master &&
48 : >file2 &&
49 git add file2 &&
50 git commit -m b2 &&
52 echo "100755 $H 2 file2"
53 echo "100644 $H 3 file2"
54 } >expect
57 do_both_modes () {
58 strategy=$1
59 test_expect_success "detect conflict on double mode change ($strategy)" '
60 git reset --hard &&
61 git checkout -f a2 &&
62 test_must_fail git merge -s $strategy b2 &&
63 git ls-files -u >actual &&
64 test_cmp actual expect &&
65 git ls-files -s file2 | grep ^100755
68 test_expect_success FILEMODE "verify executable bit on file ($strategy)" '
69 test -x file2
73 # both sides are equivalent, so no need to run both ways
74 do_both_modes recursive
75 do_both_modes resolve
77 test_expect_success 'set up delete/modechange scenario' '
78 git reset --hard &&
79 git checkout -b deletion master &&
80 git rm file1 &&
81 git commit -m deletion
84 do_delete_modechange () {
85 strategy=$1
86 us=$2
87 them=$3
88 test_expect_success "detect delete/modechange conflict ($strategy, $us)" '
89 git reset --hard &&
90 git checkout $us &&
91 test_must_fail git merge -s $strategy $them
95 do_delete_modechange recursive b1 deletion
96 do_delete_modechange recursive deletion b1
97 do_delete_modechange resolve b1 deletion
98 do_delete_modechange resolve deletion b1
100 test_done