t1092: stress test 'git sparse-checkout set'
[git/debian.git] / t / t4129-apply-samemode.sh
bloba1c7686519ebb1284d818fd3f5615853082abc01
1 #!/bin/sh
3 test_description='applying patch with mode bits'
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 test_expect_success setup '
10 echo original >file &&
11 git add file &&
12 test_tick &&
13 git commit -m initial &&
14 git tag initial &&
15 echo modified >file &&
16 git diff --stat -p >patch-0.txt &&
17 chmod +x file &&
18 git diff --stat -p >patch-1.txt &&
19 sed "s/^\(new mode \).*/\1/" <patch-1.txt >patch-empty-mode.txt &&
20 sed "s/^\(new mode \).*/\1garbage/" <patch-1.txt >patch-bogus-mode.txt
23 test_expect_success FILEMODE 'same mode (no index)' '
24 git reset --hard &&
25 chmod +x file &&
26 git apply patch-0.txt &&
27 test -x file
30 test_expect_success FILEMODE 'same mode (with index)' '
31 git reset --hard &&
32 chmod +x file &&
33 git add file &&
34 git apply --index patch-0.txt &&
35 test -x file &&
36 git diff --exit-code
39 test_expect_success FILEMODE 'same mode (index only)' '
40 git reset --hard &&
41 chmod +x file &&
42 git add file &&
43 git apply --cached patch-0.txt &&
44 git ls-files -s file | grep "^100755"
47 test_expect_success FILEMODE 'mode update (no index)' '
48 git reset --hard &&
49 git apply patch-1.txt &&
50 test -x file
53 test_expect_success FILEMODE 'mode update (with index)' '
54 git reset --hard &&
55 git apply --index patch-1.txt &&
56 test -x file &&
57 git diff --exit-code
60 test_expect_success FILEMODE 'mode update (index only)' '
61 git reset --hard &&
62 git apply --cached patch-1.txt &&
63 git ls-files -s file | grep "^100755"
66 test_expect_success FILEMODE 'empty mode is rejected' '
67 git reset --hard &&
68 test_must_fail git apply patch-empty-mode.txt 2>err &&
69 test_i18ngrep "invalid mode" err
72 test_expect_success FILEMODE 'bogus mode is rejected' '
73 git reset --hard &&
74 test_must_fail git apply patch-bogus-mode.txt 2>err &&
75 test_i18ngrep "invalid mode" err
78 test_expect_success POSIXPERM 'do not use core.sharedRepository for working tree files' '
79 git reset --hard &&
80 test_config core.sharedRepository 0666 &&
82 # Remove a default ACL if possible.
83 (setfacl -k . 2>/dev/null || true) &&
84 umask 0077 &&
86 # Test both files (f1) and leading dirs (d)
87 mkdir d &&
88 touch f1 d/f2 &&
89 git add f1 d/f2 &&
90 git diff --staged >patch-f1-and-f2.txt &&
92 rm -rf d f1 &&
93 git apply patch-f1-and-f2.txt &&
95 echo "-rw-------" >f1_mode.expected &&
96 echo "drwx------" >d_mode.expected &&
97 test_modebits f1 >f1_mode.actual &&
98 test_modebits d >d_mode.actual &&
99 test_cmp f1_mode.expected f1_mode.actual &&
100 test_cmp d_mode.expected d_mode.actual
104 test_done