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