]>
Commit | Line | Data |
---|---|---|
c4730f35 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='apply same filename' | |
4 | ||
7a98d9ab | 5 | TEST_PASSES_SANITIZE_LEAK=true |
c4730f35 JS |
6 | . ./test-lib.sh |
7 | ||
8 | test_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 | ||
18 | cat > patch << EOF | |
19 | diff 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 | |
25 | EOF | |
26 | ||
f5563887 | 27 | test_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 | 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 && |
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 |
47 | cat > patch << EOF |
48 | diff --git a/newfile b/newfile | |
49 | new file mode 100644 | |
50 | index 0000000..d95f3ad | |
51 | --- /dev/null | |
52 | +++ b/newfile | |
53 | @@ -0,0 +1 @@ | |
54 | +content | |
55 | EOF | |
56 | ||
57 | test_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 |
66 | cat > patch << EOF |
67 | diff --git a/c/newfile2 b/c/newfile2 | |
68 | new file mode 100644 | |
69 | index 0000000..d95f3ad | |
70 | --- /dev/null | |
71 | +++ b/c/newfile2 | |
72 | @@ -0,0 +1 @@ | |
73 | +content | |
74 | EOF | |
75 | ||
76 | test_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 |
85 | cat > patch << EOF |
86 | diff --git a/delfile b/delfile | |
87 | deleted file mode 100644 | |
88 | index d95f3ad..0000000 | |
89 | --- a/delfile | |
90 | +++ /dev/null | |
91 | @@ -1 +0,0 @@ | |
92 | -content | |
93 | EOF | |
94 | ||
95 | test_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 | ||
104 | cat > patch << 'EOF' | |
105 | diff --git "a/qu\157tefile" "b/qu\157tefile" | |
106 | new file mode 100644 | |
107 | index 0000000..d95f3ad | |
108 | --- /dev/null | |
109 | +++ "b/qu\157tefile" | |
110 | @@ -0,0 +1 @@ | |
111 | +content | |
112 | EOF | |
113 | ||
114 | test_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 | 123 | test_done |