Merge branch 'master' of git://git.kernel.org/pub/scm/git/git
[git/jnareb-git.git] / t / t4129-apply-samemode.sh
blob0d36ebdc8653d7d22ab5831c1f154db452e4558e
1 #!/bin/sh
3 test_description='applying patch with mode bits'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
8 test_expect_success setup '
9 echo original >file &&
10 git add file &&
11 test_tick &&
12 git commit -m initial &&
13 git tag initial &&
14 echo modified >file &&
15 git diff --stat -p >patch-0.txt &&
16 chmod +x file &&
17 git diff --stat -p >patch-1.txt
20 test_expect_success FILEMODE 'same mode (no index)' '
21 git reset --hard &&
22 chmod +x file &&
23 git apply patch-0.txt &&
24 test -x file
27 test_expect_success FILEMODE 'same mode (with index)' '
28 git reset --hard &&
29 chmod +x file &&
30 git add file &&
31 git apply --index patch-0.txt &&
32 test -x file &&
33 git diff --exit-code
36 test_expect_success FILEMODE 'same mode (index only)' '
37 git reset --hard &&
38 chmod +x file &&
39 git add file &&
40 git apply --cached patch-0.txt &&
41 git ls-files -s file | grep "^100755"
44 test_expect_success FILEMODE 'mode update (no index)' '
45 git reset --hard &&
46 git apply patch-1.txt &&
47 test -x file
50 test_expect_success FILEMODE 'mode update (with index)' '
51 git reset --hard &&
52 git apply --index patch-1.txt &&
53 test -x file &&
54 git diff --exit-code
57 test_expect_success FILEMODE 'mode update (index only)' '
58 git reset --hard &&
59 git apply --cached patch-1.txt &&
60 git ls-files -s file | grep "^100755"
63 test_done