]>
Commit | Line | Data |
---|---|---|
2344d47f JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Johannes E. Schindelin | |
4 | # | |
5 | ||
6 | test_description='Test special whitespace in diff engine. | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
10 | . ../diff-lib.sh | |
11 | ||
12 | # Ray Lehtiniemi's example | |
13 | ||
14 | cat << EOF > x | |
15 | do { | |
16 | nothing; | |
17 | } while (0); | |
18 | EOF | |
19 | ||
5be60078 | 20 | git update-index --add x |
2344d47f JS |
21 | |
22 | cat << EOF > x | |
23 | do | |
24 | { | |
25 | nothing; | |
26 | } | |
27 | while (0); | |
28 | EOF | |
29 | ||
30 | cat << EOF > expect | |
31 | diff --git a/x b/x | |
32 | index adf3937..6edc172 100644 | |
33 | --- a/x | |
34 | +++ b/x | |
35 | @@ -1,3 +1,5 @@ | |
36 | -do { | |
37 | +do | |
38 | +{ | |
39 | nothing; | |
40 | -} while (0); | |
41 | +} | |
42 | +while (0); | |
43 | EOF | |
44 | ||
5be60078 | 45 | git diff > out |
5bd74506 | 46 | test_expect_success "Ray's example without options" 'git diff expect out' |
2344d47f | 47 | |
5be60078 | 48 | git diff -w > out |
5bd74506 | 49 | test_expect_success "Ray's example with -w" 'git diff expect out' |
2344d47f | 50 | |
5be60078 | 51 | git diff -b > out |
5bd74506 | 52 | test_expect_success "Ray's example with -b" 'git diff expect out' |
2344d47f | 53 | |
4035b46e | 54 | tr 'Q' '\015' << EOF > x |
2344d47f JS |
55 | whitespace at beginning |
56 | whitespace change | |
57 | whitespace in the middle | |
58 | whitespace at end | |
59 | unchanged line | |
4035b46e | 60 | CR at endQ |
2344d47f JS |
61 | EOF |
62 | ||
5be60078 | 63 | git update-index x |
2344d47f JS |
64 | |
65 | cat << EOF > x | |
66 | whitespace at beginning | |
67 | whitespace change | |
68 | white space in the middle | |
69 | whitespace at end | |
70 | unchanged line | |
71 | CR at end | |
72 | EOF | |
73 | ||
4035b46e | 74 | tr 'Q' '\015' << EOF > expect |
2344d47f JS |
75 | diff --git a/x b/x |
76 | index d99af23..8b32fb5 100644 | |
77 | --- a/x | |
78 | +++ b/x | |
79 | @@ -1,6 +1,6 @@ | |
80 | -whitespace at beginning | |
81 | -whitespace change | |
82 | -whitespace in the middle | |
83 | -whitespace at end | |
84 | + whitespace at beginning | |
85 | +whitespace change | |
86 | +white space in the middle | |
87 | +whitespace at end | |
88 | unchanged line | |
4035b46e | 89 | -CR at endQ |
2344d47f JS |
90 | +CR at end |
91 | EOF | |
5be60078 | 92 | git diff > out |
5bd74506 | 93 | test_expect_success 'another test, without options' 'git diff expect out' |
2344d47f JS |
94 | |
95 | cat << EOF > expect | |
96 | diff --git a/x b/x | |
97 | index d99af23..8b32fb5 100644 | |
98 | EOF | |
5be60078 | 99 | git diff -w > out |
5bd74506 | 100 | test_expect_success 'another test, with -w' 'git diff expect out' |
2344d47f | 101 | |
4035b46e | 102 | tr 'Q' '\015' << EOF > expect |
2344d47f JS |
103 | diff --git a/x b/x |
104 | index d99af23..8b32fb5 100644 | |
105 | --- a/x | |
106 | +++ b/x | |
107 | @@ -1,6 +1,6 @@ | |
108 | -whitespace at beginning | |
109 | + whitespace at beginning | |
110 | whitespace change | |
111 | -whitespace in the middle | |
2344d47f | 112 | +white space in the middle |
c7c24889 | 113 | whitespace at end |
2344d47f | 114 | unchanged line |
c7c24889 | 115 | CR at endQ |
2344d47f | 116 | EOF |
5be60078 | 117 | git diff -b > out |
5bd74506 | 118 | test_expect_success 'another test, with -b' 'git diff expect out' |
2344d47f | 119 | |
86f8c236 WC |
120 | |
121 | test_expect_success 'check mixed spaces and tabs in indent' ' | |
122 | ||
123 | # This is indented with SP HT SP. | |
124 | echo " foo();" > x && | |
125 | git diff --check | grep "space before tab" | |
126 | ||
127 | ' | |
128 | ||
2344d47f | 129 | test_done |