]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4129-apply-samemode.sh
Merge commit 'b319ef7' into jc/maint-fix-test-perm
[thirdparty/git.git] / t / t4129-apply-samemode.sh
CommitLineData
1f7903a3
JH
1#!/bin/sh
2
3test_description='applying patch with mode bits'
4
5. ./test-lib.sh
6
872f349e
JS
7if test "$(git config --bool core.filemode)" = false
8then
9 say 'filemode disabled on the filesystem'
10else
11 test_set_prereq FILEMODE
12fi
13
1f7903a3
JH
14test_expect_success setup '
15 echo original >file &&
16 git add file &&
17 test_tick &&
18 git commit -m initial &&
19 git tag initial &&
20 echo modified >file &&
21 git diff --stat -p >patch-0.txt &&
22 chmod +x file &&
23 git diff --stat -p >patch-1.txt
24'
25
872f349e 26test_expect_success FILEMODE 'same mode (no index)' '
1f7903a3
JH
27 git reset --hard &&
28 chmod +x file &&
29 git apply patch-0.txt &&
30 test -x file
31'
32
872f349e 33test_expect_success FILEMODE 'same mode (with index)' '
1f7903a3
JH
34 git reset --hard &&
35 chmod +x file &&
36 git add file &&
37 git apply --index patch-0.txt &&
38 test -x file &&
39 git diff --exit-code
40'
41
872f349e 42test_expect_success FILEMODE 'same mode (index only)' '
1f7903a3
JH
43 git reset --hard &&
44 chmod +x file &&
45 git add file &&
46 git apply --cached patch-0.txt &&
47 git ls-files -s file | grep "^100755"
48'
49
872f349e 50test_expect_success FILEMODE 'mode update (no index)' '
1f7903a3
JH
51 git reset --hard &&
52 git apply patch-1.txt &&
53 test -x file
54'
55
872f349e 56test_expect_success FILEMODE 'mode update (with index)' '
1f7903a3
JH
57 git reset --hard &&
58 git apply --index patch-1.txt &&
59 test -x file &&
60 git diff --exit-code
61'
62
872f349e 63test_expect_success FILEMODE 'mode update (index only)' '
1f7903a3
JH
64 git reset --hard &&
65 git apply --cached patch-1.txt &&
66 git ls-files -s file | grep "^100755"
67'
68
69test_done