Interested in helping open source friends on HP-UX?
[git/mjg.git] / t / t4051-diff-function-context.sh
blob001d678e09bfa6d3e1c7197c27925bb12a71b492
1 #!/bin/sh
3 test_description='diff function context'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/diff-lib.sh
9 cat <<\EOF >hello.c
10 #include <stdio.h>
12 static int a(void)
15 * Dummy.
19 static int hello_world(void)
21 /* Classic. */
22 printf("Hello world.\n");
24 /* Success! */
25 return 0;
27 static int b(void)
30 * Dummy, too.
34 int main(int argc, char **argv)
36 a();
37 b();
38 return hello_world();
40 EOF
42 test_expect_success 'setup' '
43 git add hello.c &&
44 test_tick &&
45 git commit -m initial &&
47 grep -v Classic <hello.c >hello.c.new &&
48 mv hello.c.new hello.c
51 cat <<\EOF >expected
52 diff --git a/hello.c b/hello.c
53 --- a/hello.c
54 +++ b/hello.c
55 @@ -10,8 +10,7 @@ static int a(void)
56 static int hello_world(void)
58 - /* Classic. */
59 printf("Hello world.\n");
61 /* Success! */
62 return 0;
64 EOF
66 test_expect_success 'diff -U0 -W' '
67 git diff -U0 -W >actual &&
68 compare_diff_patch actual expected
71 cat <<\EOF >expected
72 diff --git a/hello.c b/hello.c
73 --- a/hello.c
74 +++ b/hello.c
75 @@ -9,9 +9,8 @@ static int a(void)
77 static int hello_world(void)
79 - /* Classic. */
80 printf("Hello world.\n");
82 /* Success! */
83 return 0;
85 EOF
87 test_expect_success 'diff -W' '
88 git diff -W >actual &&
89 compare_diff_patch actual expected
92 test_done