Include regex.[ch] in compat/
[git/mingw/4msysgit/wingit-dll.git] / t / t4109-apply-multifrag.sh
blob20f46fc1cac86430e9180c5b70211140985b1e44
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
4 # Copyright (c) 2005 Robert Fitzsimons
7 test_description='git-apply test patches with multiple fragments.
10 . ./test-lib.sh
12 cmp () {
13 diff -w "$@"
16 # setup
18 cat > patch1.patch <<\EOF
19 diff --git a/main.c b/main.c
20 new file mode 100644
21 --- /dev/null
22 +++ b/main.c
23 @@ -0,0 +1,23 @@
24 +#include <stdio.h>
26 +int func(int num);
27 +void print_int(int num);
29 +int main() {
30 + int i;
32 + for (i = 0; i < 10; i++) {
33 + print_int(func(i));
34 + }
36 + return 0;
39 +int func(int num) {
40 + return num * num;
43 +void print_int(int num) {
44 + printf("%d", num);
47 EOF
48 cat > patch2.patch <<\EOF
49 diff --git a/main.c b/main.c
50 --- a/main.c
51 +++ b/main.c
52 @@ -1,7 +1,9 @@
53 +#include <stdlib.h>
54 #include <stdio.h>
56 int func(int num);
57 void print_int(int num);
58 +void print_ln();
60 int main() {
61 int i;
62 @@ -10,6 +12,8 @@
63 print_int(func(i));
66 + print_ln();
68 return 0;
71 @@ -21,3 +25,7 @@
72 printf("%d", num);
75 +void print_ln() {
76 + printf("\n");
79 EOF
80 cat > patch3.patch <<\EOF
81 diff --git a/main.c b/main.c
82 --- a/main.c
83 +++ b/main.c
84 @@ -1,9 +1,7 @@
85 -#include <stdlib.h>
86 #include <stdio.h>
88 int func(int num);
89 void print_int(int num);
90 -void print_ln();
92 int main() {
93 int i;
94 @@ -12,8 +10,6 @@
95 print_int(func(i));
98 - print_ln();
100 return 0;
103 @@ -25,7 +21,3 @@
104 printf("%d", num);
107 -void print_ln() {
108 - printf("\n");
112 cat > patch4.patch <<\EOF
113 diff --git a/main.c b/main.c
114 --- a/main.c
115 +++ b/main.c
116 @@ -1,13 +1,14 @@
117 #include <stdio.h>
119 int func(int num);
120 -void print_int(int num);
121 +int func2(int num);
123 int main() {
124 int i;
126 for (i = 0; i < 10; i++) {
127 - print_int(func(i));
128 + printf("%d", func(i));
129 + printf("%d", func3(i));
132 return 0;
133 @@ -17,7 +18,7 @@
134 return num * num;
137 -void print_int(int num) {
138 - printf("%d", num);
139 +int func2(int num) {
140 + return num * num * num;
145 test_expect_success "S = git-apply (1)" \
146 'git-apply patch1.patch patch2.patch'
147 mv main.c main.c.git
149 test_expect_success "S = patch (1)" \
150 'cat patch1.patch patch2.patch | patch -p1'
152 test_expect_success "S = cmp (1)" \
153 'cmp main.c.git main.c'
155 rm -f main.c main.c.git
157 test_expect_success "S = git-apply (2)" \
158 'git-apply patch1.patch patch2.patch patch3.patch'
159 mv main.c main.c.git
161 test_expect_success "S = patch (2)" \
162 'cat patch1.patch patch2.patch patch3.patch | patch -p1'
164 test_expect_success "S = cmp (2)" \
165 'cmp main.c.git main.c'
167 rm -f main.c main.c.git
169 test_expect_success "S = git-apply (3)" \
170 'git-apply patch1.patch patch4.patch'
171 mv main.c main.c.git
173 test_expect_success "S = patch (3)" \
174 'cat patch1.patch patch4.patch | patch -p1'
176 test_expect_success "S = cmp (3)" \
177 'cmp main.c.git main.c'
179 test_done