blob: 001d678e09bfa6d3e1c7197c27925bb12a71b492 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/bin/sh
test_description='diff function context'
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh
cat <<\EOF >hello.c
#include <stdio.h>
static int a(void)
{
/*
* Dummy.
*/
}
static int hello_world(void)
{
/* Classic. */
printf("Hello world.\n");
/* Success! */
return 0;
}
static int b(void)
{
/*
* Dummy, too.
*/
}
int main(int argc, char **argv)
{
a();
b();
return hello_world();
}
EOF
test_expect_success 'setup' '
git add hello.c &&
test_tick &&
git commit -m initial &&
grep -v Classic <hello.c >hello.c.new &&
mv hello.c.new hello.c
'
cat <<\EOF >expected
diff --git a/hello.c b/hello.c
--- a/hello.c
+++ b/hello.c
@@ -10,8 +10,7 @@ static int a(void)
static int hello_world(void)
{
- /* Classic. */
printf("Hello world.\n");
/* Success! */
return 0;
}
EOF
test_expect_success 'diff -U0 -W' '
git diff -U0 -W >actual &&
compare_diff_patch actual expected
'
cat <<\EOF >expected
diff --git a/hello.c b/hello.c
--- a/hello.c
+++ b/hello.c
@@ -9,9 +9,8 @@ static int a(void)
static int hello_world(void)
{
- /* Classic. */
printf("Hello world.\n");
/* Success! */
return 0;
}
EOF
test_expect_success 'diff -W' '
git diff -W >actual &&
compare_diff_patch actual expected
'
test_done
|