Win32: patch Windows environment on startup
[git/mingw/4msysgit/kblees.git] / t / t4120-apply-popt.sh
bloba33d510bf6b27a6bb2c640cfc9d11f462cbdf7a6
1 #!/bin/sh
3 # Copyright (c) 2007 Shawn O. Pearce
6 test_description='git apply -p handling.'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
11 test_expect_success setup '
12 mkdir sub &&
13 echo A >sub/file1 &&
14 cp sub/file1 file1.saved &&
15 git add sub/file1 &&
16 echo B >sub/file1 &&
17 git diff >patch.file &&
18 git checkout -- sub/file1 &&
19 git mv sub süb &&
20 echo B >süb/file1 &&
21 git diff >patch.escaped &&
22 grep "[\]" patch.escaped &&
23 rm süb/file1 &&
24 rmdir süb
27 test_expect_success 'apply git diff with -p2' '
28 cp file1.saved file1 &&
29 git apply -p2 patch.file
32 test_expect_success 'apply with too large -p' '
33 cp file1.saved file1 &&
34 test_must_fail git apply --stat -p3 patch.file 2>err &&
35 grep "removing 3 leading" err
38 test_expect_success 'apply (-p2) traditional diff with funny filenames' '
39 cat >patch.quotes <<-\EOF &&
40 diff -u "a/"sub/file1 "b/"sub/file1
41 --- "a/"sub/file1
42 +++ "b/"sub/file1
43 @@ -1 +1 @@
46 EOF
47 echo B >expected &&
49 cp file1.saved file1 &&
50 git apply -p2 patch.quotes &&
51 test_cmp expected file1
54 test_expect_success 'apply with too large -p and fancy filename' '
55 cp file1.saved file1 &&
56 test_must_fail git apply --stat -p3 patch.escaped 2>err &&
57 grep "removing 3 leading" err
60 test_expect_success 'apply (-p2) diff, mode change only' '
61 cat >patch.chmod <<-\EOF &&
62 diff --git a/sub/file1 b/sub/file1
63 old mode 100644
64 new mode 100755
65 EOF
66 test_chmod -x file1 &&
67 git apply --index -p2 patch.chmod &&
68 case $(git ls-files -s file1) in 100755*) : good;; *) false;; esac
71 test_expect_success FILEMODE 'file mode was changed' '
72 test -x file1
75 test_expect_success 'apply (-p2) diff, rename' '
76 cat >patch.rename <<-\EOF &&
77 diff --git a/sub/file1 b/sub/file2
78 similarity index 100%
79 rename from sub/file1
80 rename to sub/file2
81 EOF
82 echo A >expected &&
84 cp file1.saved file1 &&
85 rm -f file2 &&
86 git apply -p2 patch.rename &&
87 test_cmp expected file2
90 test_done