blob: c268298eaf5672c649ca3e4815dc4f43d71efece [file] [log] [blame]
Junio C Hamano1f7903a2009-01-02 02:55:37 -08001#!/bin/sh
2
3test_description='applying patch with mode bits'
4
5. ./test-lib.sh
Johannes Sixt872f3492009-02-27 22:20:57 +01006
Junio C Hamano1f7903a2009-01-02 02:55:37 -08007test_expect_success setup '
8 echo original >file &&
9 git add file &&
10 test_tick &&
11 git commit -m initial &&
12 git tag initial &&
13 echo modified >file &&
14 git diff --stat -p >patch-0.txt &&
15 chmod +x file &&
16 git diff --stat -p >patch-1.txt
17'
18
Johannes Sixt872f3492009-02-27 22:20:57 +010019test_expect_success FILEMODE 'same mode (no index)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080020 git reset --hard &&
21 chmod +x file &&
22 git apply patch-0.txt &&
23 test -x file
24'
25
Johannes Sixt872f3492009-02-27 22:20:57 +010026test_expect_success FILEMODE 'same mode (with index)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080027 git reset --hard &&
28 chmod +x file &&
29 git add file &&
30 git apply --index patch-0.txt &&
31 test -x file &&
32 git diff --exit-code
33'
34
Johannes Sixt872f3492009-02-27 22:20:57 +010035test_expect_success FILEMODE 'same mode (index only)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080036 git reset --hard &&
37 chmod +x file &&
38 git add file &&
39 git apply --cached patch-0.txt &&
40 git ls-files -s file | grep "^100755"
41'
42
Johannes Sixt872f3492009-02-27 22:20:57 +010043test_expect_success FILEMODE 'mode update (no index)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080044 git reset --hard &&
45 git apply patch-1.txt &&
46 test -x file
47'
48
Johannes Sixt872f3492009-02-27 22:20:57 +010049test_expect_success FILEMODE 'mode update (with index)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080050 git reset --hard &&
51 git apply --index patch-1.txt &&
52 test -x file &&
53 git diff --exit-code
54'
55
Johannes Sixt872f3492009-02-27 22:20:57 +010056test_expect_success FILEMODE 'mode update (index only)' '
Junio C Hamano1f7903a2009-01-02 02:55:37 -080057 git reset --hard &&
58 git apply --cached patch-1.txt &&
59 git ls-files -s file | grep "^100755"
60'
61
62test_done