]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4128-apply-root.sh
The third batch
[thirdparty/git.git] / t / t4128-apply-root.sh
CommitLineData
c4730f35
JS
1#!/bin/sh
2
3test_description='apply same filename'
4
7a98d9ab 5TEST_PASSES_SANITIZE_LEAK=true
c4730f35
JS
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9
10 mkdir -p some/sub/dir &&
11 echo Hello > some/sub/dir/file &&
8ee4a6c2
JH
12 git add some/sub/dir/file &&
13 git commit -m initial &&
14 git tag initial
c4730f35
JS
15
16'
17
18cat > patch << EOF
19diff a/bla/blub/dir/file b/bla/blub/dir/file
20--- a/bla/blub/dir/file
21+++ b/bla/blub/dir/file
22@@ -1,1 +1,1 @@
23-Hello
24+Bello
25EOF
26
f5563887 27test_expect_success 'apply --directory -p (1)' '
f5563887 28 git apply --directory=some/sub -p3 --index patch &&
c4d1d526
ÆAB
29 echo Bello >expect &&
30 git show :some/sub/dir/file >actual &&
31 test_cmp expect actual &&
32 test_cmp expect some/sub/dir/file
c4730f35
JS
33
34'
35
f5563887 36test_expect_success 'apply --directory -p (2) ' '
8ee4a6c2
JH
37
38 git reset --hard initial &&
f5563887 39 git apply --directory=some/sub/ -p3 --index patch &&
c4d1d526
ÆAB
40 echo Bello >expect &&
41 git show :some/sub/dir/file >actual &&
42 test_cmp expect actual &&
43 test_cmp expect some/sub/dir/file
8ee4a6c2
JH
44
45'
46
969c8775
JK
47cat > patch << EOF
48diff --git a/newfile b/newfile
49new file mode 100644
50index 0000000..d95f3ad
51--- /dev/null
52+++ b/newfile
53@@ -0,0 +1 @@
54+content
55EOF
56
57test_expect_success 'apply --directory (new file)' '
58 git reset --hard initial &&
59 git apply --directory=some/sub/dir/ --index patch &&
c4d1d526
ÆAB
60 echo content >expect &&
61 git show :some/sub/dir/newfile >actual &&
62 test_cmp expect actual &&
63 test_cmp expect some/sub/dir/newfile
969c8775
JK
64'
65
ec7fc0b1
JH
66cat > patch << EOF
67diff --git a/c/newfile2 b/c/newfile2
68new file mode 100644
69index 0000000..d95f3ad
70--- /dev/null
71+++ b/c/newfile2
72@@ -0,0 +1 @@
73+content
74EOF
75
76test_expect_success 'apply --directory -p (new file)' '
77 git reset --hard initial &&
78 git apply -p2 --directory=some/sub/dir/ --index patch &&
c4d1d526
ÆAB
79 echo content >expect &&
80 git show :some/sub/dir/newfile2 >actual &&
81 test_cmp expect actual &&
82 test_cmp expect some/sub/dir/newfile2
ec7fc0b1
JH
83'
84
969c8775
JK
85cat > patch << EOF
86diff --git a/delfile b/delfile
87deleted file mode 100644
88index d95f3ad..0000000
89--- a/delfile
90+++ /dev/null
91@@ -1 +0,0 @@
92-content
93EOF
94
95test_expect_success 'apply --directory (delete file)' '
96 git reset --hard initial &&
97 echo content >some/sub/dir/delfile &&
98 git add some/sub/dir/delfile &&
99 git apply --directory=some/sub/dir/ --index patch &&
e19b3199
ÆAB
100 git ls-files >out &&
101 ! grep delfile out
969c8775
JK
102'
103
104cat > patch << 'EOF'
105diff --git "a/qu\157tefile" "b/qu\157tefile"
106new file mode 100644
107index 0000000..d95f3ad
108--- /dev/null
109+++ "b/qu\157tefile"
110@@ -0,0 +1 @@
111+content
112EOF
113
114test_expect_success 'apply --directory (quoted filename)' '
115 git reset --hard initial &&
116 git apply --directory=some/sub/dir/ --index patch &&
c4d1d526
ÆAB
117 echo content >expect &&
118 git show :some/sub/dir/quotefile >actual &&
119 test_cmp expect actual &&
120 test_cmp expect some/sub/dir/quotefile
969c8775
JK
121'
122
c4730f35 123test_done