3 test_description
='applying patch with mode bits'
7 test_expect_success setup
'
11 git commit -m initial &&
13 echo modified >file &&
14 git diff --stat -p >patch-0.txt &&
16 git diff --stat -p >patch-1.txt &&
17 sed "s/^\(new mode \).*/\1/" <patch-1.txt >patch-empty-mode.txt &&
18 sed "s/^\(new mode \).*/\1garbage/" <patch-1.txt >patch-bogus-mode.txt
21 test_expect_success FILEMODE
'same mode (no index)' '
24 git apply patch-0.txt &&
28 test_expect_success FILEMODE
'same mode (with index)' '
32 git apply --index patch-0.txt &&
37 test_expect_success FILEMODE
'same mode (index only)' '
41 git apply --cached patch-0.txt &&
42 git ls-files -s file | grep "^100755"
45 test_expect_success FILEMODE
'mode update (no index)' '
47 git apply patch-1.txt &&
51 test_expect_success FILEMODE
'mode update (with index)' '
53 git apply --index patch-1.txt &&
58 test_expect_success FILEMODE
'mode update (index only)' '
60 git apply --cached patch-1.txt &&
61 git ls-files -s file | grep "^100755"
64 test_expect_success FILEMODE
'empty mode is rejected' '
66 test_must_fail git apply patch-empty-mode.txt 2>err &&
67 test_i18ngrep "invalid mode" err
70 test_expect_success FILEMODE
'bogus mode is rejected' '
72 test_must_fail git apply patch-bogus-mode.txt 2>err &&
73 test_i18ngrep "invalid mode" err
76 test_expect_success POSIXPERM
'do not use core.sharedRepository for working tree files' '
78 test_config core.sharedRepository 0666 &&
80 # Remove a default ACL if possible.
81 (setfacl -k . 2>/dev/null || true) &&
84 # Test both files (f1) and leading dirs (d)
88 git diff --staged >patch-f1-and-f2.txt &&
91 git apply patch-f1-and-f2.txt &&
93 echo "-rw-------" >f1_mode.expected &&
94 echo "drwx------" >d_mode.expected &&
95 test_modebits f1 >f1_mode.actual &&
96 test_modebits d >d_mode.actual &&
97 test_cmp f1_mode.expected f1_mode.actual &&
98 test_cmp d_mode.expected d_mode.actual