3 # Copyright (c) 2005 Junio C Hamano
4 # Copyright (c) 2005 Robert Fitzsimons
7 test_description
='git-apply test patches with multiple fragments.
14 cat > patch1.
patch <<\EOF
15 diff --git a
/main.c b
/main.c
23 +void print_int
(int num
);
28 + for (i
= 0; i
< 10; i
++) {
39 +void print_int
(int num
) {
44 cat > patch2.
patch <<\EOF
45 diff --git a
/main.c b
/main.c
53 void print_int
(int num
);
76 cat > patch3.
patch <<\EOF
77 diff --git a
/main.c b
/main.c
85 void print_int
(int num
);
108 cat > patch4.
patch <<\EOF
109 diff --git a
/main.c b
/main.c
116 -void print_int
(int num
);
122 for (i
= 0; i
< 10; i
++) {
123 - print_int
(func
(i
));
124 + printf("%d", func
(i
));
125 + printf("%d", func3
(i
));
133 -void print_int
(int num
) {
135 +int func2
(int num
) {
136 + return num
* num
* num
;
141 test_expect_success
"S = git-apply (1)" \
142 'git-apply patch1.patch patch2.patch'
145 test_expect_success
"S = patch (1)" \
146 'cat patch1.patch patch2.patch | patch -p1'
148 test_expect_success
"S = cmp (1)" \
149 'cmp main.c.git main.c'
151 rm -f main.c main.c.git
153 test_expect_success
"S = git-apply (2)" \
154 'git-apply patch1.patch patch2.patch patch3.patch'
157 test_expect_success
"S = patch (2)" \
158 'cat patch1.patch patch2.patch patch3.patch | patch -p1'
160 test_expect_success
"S = cmp (2)" \
161 'cmp main.c.git main.c'
163 rm -f main.c main.c.git
165 test_expect_success
"S = git-apply (3)" \
166 'git-apply patch1.patch patch4.patch'
169 test_expect_success
"S = patch (3)" \
170 'cat patch1.patch patch4.patch | patch -p1'
172 test_expect_success
"S = cmp (3)" \
173 'cmp main.c.git main.c'