]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4120-apply-popt.sh
i18n: avoid parenthesized string as array initializer
[thirdparty/git.git] / t / t4120-apply-popt.sh
CommitLineData
79ee194e
SP
1#!/bin/sh
2#
3# Copyright (c) 2007 Shawn O. Pearce
4#
5
5be60078 6test_description='git apply -p handling.'
79ee194e
SP
7
8. ./test-lib.sh
97a853d3 9. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
79ee194e
SP
10
11test_expect_success setup '
12 mkdir sub &&
13 echo A >sub/file1 &&
bb7306b5 14 cp sub/file1 file1.saved &&
79ee194e
SP
15 git add sub/file1 &&
16 echo B >sub/file1 &&
17 git diff >patch.file &&
bb7306b5
JN
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
79ee194e
SP
25'
26
27test_expect_success 'apply git diff with -p2' '
bb7306b5 28 cp file1.saved file1 &&
79ee194e
SP
29 git apply -p2 patch.file
30'
31
15862087 32test_expect_success 'apply with too large -p' '
bb7306b5 33 cp file1.saved file1 &&
15862087
AG
34 test_must_fail git apply --stat -p3 patch.file 2>err &&
35 grep "removing 3 leading" err
36'
37
bb7306b5
JN
38test_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 @@
44 -A
45 +B
46 EOF
47 echo B >expected &&
48
49 cp file1.saved file1 &&
50 git apply -p2 patch.quotes &&
51 test_cmp expected file1
52'
53
54test_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
58'
59
aae1f6ac
JH
60test_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
97a853d3
JS
66 test_chmod -x file1 &&
67 git apply --index -p2 patch.chmod &&
68 case $(git ls-files -s file1) in 100755*) : good;; *) false;; esac
69'
70
71test_expect_success FILEMODE 'file mode was changed' '
aae1f6ac
JH
72 test -x file1
73'
74
75test_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 &&
83
84 cp file1.saved file1 &&
85 rm -f file2 &&
86 git apply -p2 patch.rename &&
87 test_cmp expected file2
88'
89
79ee194e 90test_done