]>
Commit | Line | Data |
---|---|---|
c4730f35 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='apply same filename' | |
4 | ||
f54f48fc ÆAB |
5 | |
6 | TEST_PASSES_SANITIZE_LEAK=true | |
c4730f35 JS |
7 | . ./test-lib.sh |
8 | ||
9 | test_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 | ||
19 | cat > patch << EOF | |
20 | diff 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 | |
26 | EOF | |
27 | ||
f5563887 | 28 | test_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 | 36 | test_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 |
45 | cat > patch << EOF |
46 | diff --git a/newfile b/newfile | |
47 | new file mode 100644 | |
48 | index 0000000..d95f3ad | |
49 | --- /dev/null | |
50 | +++ b/newfile | |
51 | @@ -0,0 +1 @@ | |
52 | +content | |
53 | EOF | |
54 | ||
55 | test_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 |
62 | cat > patch << EOF |
63 | diff --git a/c/newfile2 b/c/newfile2 | |
64 | new file mode 100644 | |
65 | index 0000000..d95f3ad | |
66 | --- /dev/null | |
67 | +++ b/c/newfile2 | |
68 | @@ -0,0 +1 @@ | |
69 | +content | |
70 | EOF | |
71 | ||
72 | test_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 |
79 | cat > patch << EOF |
80 | diff --git a/delfile b/delfile | |
81 | deleted file mode 100644 | |
82 | index d95f3ad..0000000 | |
83 | --- a/delfile | |
84 | +++ /dev/null | |
85 | @@ -1 +0,0 @@ | |
86 | -content | |
87 | EOF | |
88 | ||
89 | test_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 | ||
97 | cat > patch << 'EOF' | |
98 | diff --git "a/qu\157tefile" "b/qu\157tefile" | |
99 | new file mode 100644 | |
100 | index 0000000..d95f3ad | |
101 | --- /dev/null | |
102 | +++ "b/qu\157tefile" | |
103 | @@ -0,0 +1 @@ | |
104 | +content | |
105 | EOF | |
106 | ||
107 | test_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 | 114 | test_done |