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