Git 1.7.2-rc2
[git/mingw/4msysgit/kblees.git] / t / t4033-diff-patience.sh
blob1eb14989df0bffe7d41111607d67da6a90c1fbf5
1 #!/bin/sh
3 test_description='patience diff algorithm'
5 . ./test-lib.sh
7 cat >file1 <<\EOF
8 #include <stdio.h>
10 // Frobs foo heartily
11 int frobnitz(int foo)
13 int i;
14 for(i = 0; i < 10; i++)
16 printf("Your answer is: ");
17 printf("%d\n", foo);
21 int fact(int n)
23 if(n > 1)
25 return fact(n-1) * n;
27 return 1;
30 int main(int argc, char **argv)
32 frobnitz(fact(10));
34 EOF
36 cat >file2 <<\EOF
37 #include <stdio.h>
39 int fib(int n)
41 if(n > 2)
43 return fib(n-1) + fib(n-2);
45 return 1;
48 // Frobs foo heartily
49 int frobnitz(int foo)
51 int i;
52 for(i = 0; i < 10; i++)
54 printf("%d\n", foo);
58 int main(int argc, char **argv)
60 frobnitz(fib(10));
62 EOF
64 cat >expect <<\EOF
65 diff --git a/file1 b/file2
66 index 6faa5a3..e3af329 100644
67 --- a/file1
68 +++ b/file2
69 @@ -1,26 +1,25 @@
70 #include <stdio.h>
72 +int fib(int n)
74 + if(n > 2)
75 + {
76 + return fib(n-1) + fib(n-2);
77 + }
78 + return 1;
81 // Frobs foo heartily
82 int frobnitz(int foo)
84 int i;
85 for(i = 0; i < 10; i++)
87 - printf("Your answer is: ");
88 printf("%d\n", foo);
92 -int fact(int n)
94 - if(n > 1)
95 - {
96 - return fact(n-1) * n;
97 - }
98 - return 1;
101 int main(int argc, char **argv)
103 - frobnitz(fact(10));
104 + frobnitz(fib(10));
108 test_expect_success 'patience diff' '
110 test_must_fail git diff --no-index --patience file1 file2 > output &&
111 test_cmp expect output
115 test_expect_success 'patience diff output is valid' '
117 mv file2 expect &&
118 git apply < output &&
119 test_cmp expect file2
123 cat >uniq1 <<\EOF
132 cat >uniq2 <<\EOF
141 cat >expect <<\EOF
142 diff --git a/uniq1 b/uniq2
143 index b414108..0fdf397 100644
144 --- a/uniq1
145 +++ b/uniq2
146 @@ -1,6 +1,6 @@
161 test_expect_success 'completely different files' '
163 test_must_fail git diff --no-index --patience uniq1 uniq2 > output &&
164 test_cmp expect output
168 test_done