Git fork

mask necessary whitespace policy violations in test scripts

All of these violations are necessary parts of the tests
(which are generally checking the behavior of trailing
whitespace, or contain diff fragments with empty lines).

Our solution is two-fold:

1. Process input with whitespace problems using tr. This
has the added bonus that it becomes very obvious where
the bogus whitespace is intended to go.

2. Move large diff fragments into their own supplemental
files. This gets rid of the whitespace problem, since
supplemental files are not checked, and it also makes
the test script a bit easier to read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Jeff King and committed by
Junio C Hamano
74f16b0c 3b2eb186

+131 -136
+2 -2
t/t3800-mktag.sh
··· 241 241 ############################################################ 242 242 # 17. disallow missing tag timestamp 243 243 244 - cat >tag.sig <<EOF 244 + tr '_' ' ' >tag.sig <<EOF 245 245 object $head 246 246 type commit 247 247 tag mytag 248 - tagger T A Gger <tagger@example.com> 248 + tagger T A Gger <tagger@example.com>__ 249 249 250 250 EOF 251 251
+4 -4
t/t4015-diff-whitespace.sh
··· 62 62 63 63 git update-index x 64 64 65 - cat << EOF > x 65 + tr '_' ' ' << EOF > x 66 66 whitespace at beginning 67 67 whitespace change 68 68 white space in the middle 69 - whitespace at end 69 + whitespace at end__ 70 70 unchanged line 71 71 CR at end 72 72 EOF 73 73 74 - tr 'Q' '\015' << EOF > expect 74 + tr 'Q_' '\015 ' << EOF > expect 75 75 diff --git a/x b/x 76 76 index d99af23..8b32fb5 100644 77 77 --- a/x ··· 84 84 + whitespace at beginning 85 85 +whitespace change 86 86 +white space in the middle 87 - +whitespace at end 87 + +whitespace at end__ 88 88 unchanged line 89 89 -CR at endQ 90 90 +CR at end
+4 -128
t/t4109-apply-multifrag.sh
··· 9 9 ' 10 10 . ./test-lib.sh 11 11 12 - # setup 13 - 14 - cat > patch1.patch <<\EOF 15 - diff --git a/main.c b/main.c 16 - new file mode 100644 17 - --- /dev/null 18 - +++ b/main.c 19 - @@ -0,0 +1,23 @@ 20 - +#include <stdio.h> 21 - + 22 - +int func(int num); 23 - +void print_int(int num); 24 - + 25 - +int main() { 26 - + int i; 27 - + 28 - + for (i = 0; i < 10; i++) { 29 - + print_int(func(i)); 30 - + } 31 - + 32 - + return 0; 33 - +} 34 - + 35 - +int func(int num) { 36 - + return num * num; 37 - +} 38 - + 39 - +void print_int(int num) { 40 - + printf("%d", num); 41 - +} 42 - + 43 - EOF 44 - cat > patch2.patch <<\EOF 45 - diff --git a/main.c b/main.c 46 - --- a/main.c 47 - +++ b/main.c 48 - @@ -1,7 +1,9 @@ 49 - +#include <stdlib.h> 50 - #include <stdio.h> 51 - 52 - int func(int num); 53 - void print_int(int num); 54 - +void print_ln(); 55 - 56 - int main() { 57 - int i; 58 - @@ -10,6 +12,8 @@ 59 - print_int(func(i)); 60 - } 61 - 62 - + print_ln(); 63 - + 64 - return 0; 65 - } 66 - 67 - @@ -21,3 +25,7 @@ 68 - printf("%d", num); 69 - } 70 - 71 - +void print_ln() { 72 - + printf("\n"); 73 - +} 74 - + 75 - EOF 76 - cat > patch3.patch <<\EOF 77 - diff --git a/main.c b/main.c 78 - --- a/main.c 79 - +++ b/main.c 80 - @@ -1,9 +1,7 @@ 81 - -#include <stdlib.h> 82 - #include <stdio.h> 83 - 84 - int func(int num); 85 - void print_int(int num); 86 - -void print_ln(); 87 - 88 - int main() { 89 - int i; 90 - @@ -12,8 +10,6 @@ 91 - print_int(func(i)); 92 - } 93 - 94 - - print_ln(); 95 - - 96 - return 0; 97 - } 98 - 99 - @@ -25,7 +21,3 @@ 100 - printf("%d", num); 101 - } 102 - 103 - -void print_ln() { 104 - - printf("\n"); 105 - -} 106 - - 107 - EOF 108 - cat > patch4.patch <<\EOF 109 - diff --git a/main.c b/main.c 110 - --- a/main.c 111 - +++ b/main.c 112 - @@ -1,13 +1,14 @@ 113 - #include <stdio.h> 114 - 115 - int func(int num); 116 - -void print_int(int num); 117 - +int func2(int num); 118 - 119 - int main() { 120 - int i; 121 - 122 - for (i = 0; i < 10; i++) { 123 - - print_int(func(i)); 124 - + printf("%d", func(i)); 125 - + printf("%d", func3(i)); 126 - } 127 - 128 - return 0; 129 - @@ -17,7 +18,7 @@ 130 - return num * num; 131 - } 132 - 133 - -void print_int(int num) { 134 - - printf("%d", num); 135 - +int func2(int num) { 136 - + return num * num * num; 137 - } 138 - 139 - EOF 12 + cp ../t4109/patch1.patch . 13 + cp ../t4109/patch2.patch . 14 + cp ../t4109/patch3.patch . 15 + cp ../t4109/patch4.patch . 140 16 141 17 test_expect_success "S = git apply (1)" \ 142 18 'git apply patch1.patch patch2.patch'
+28
t/t4109/patch1.patch
··· 1 + diff --git a/main.c b/main.c 2 + new file mode 100644 3 + --- /dev/null 4 + +++ b/main.c 5 + @@ -0,0 +1,23 @@ 6 + +#include <stdio.h> 7 + + 8 + +int func(int num); 9 + +void print_int(int num); 10 + + 11 + +int main() { 12 + + int i; 13 + + 14 + + for (i = 0; i < 10; i++) { 15 + + print_int(func(i)); 16 + + } 17 + + 18 + + return 0; 19 + +} 20 + + 21 + +int func(int num) { 22 + + return num * num; 23 + +} 24 + + 25 + +void print_int(int num) { 26 + + printf("%d", num); 27 + +} 28 + +
+30
t/t4109/patch2.patch
··· 1 + diff --git a/main.c b/main.c 2 + --- a/main.c 3 + +++ b/main.c 4 + @@ -1,7 +1,9 @@ 5 + +#include <stdlib.h> 6 + #include <stdio.h> 7 + 8 + int func(int num); 9 + void print_int(int num); 10 + +void print_ln(); 11 + 12 + int main() { 13 + int i; 14 + @@ -10,6 +12,8 @@ 15 + print_int(func(i)); 16 + } 17 + 18 + + print_ln(); 19 + + 20 + return 0; 21 + } 22 + 23 + @@ -21,3 +25,7 @@ 24 + printf("%d", num); 25 + } 26 + 27 + +void print_ln() { 28 + + printf("\n"); 29 + +} 30 + +
+31
t/t4109/patch3.patch
··· 1 + cat > patch3.patch <<\EOF 2 + diff --git a/main.c b/main.c 3 + --- a/main.c 4 + +++ b/main.c 5 + @@ -1,9 +1,7 @@ 6 + -#include <stdlib.h> 7 + #include <stdio.h> 8 + 9 + int func(int num); 10 + void print_int(int num); 11 + -void print_ln(); 12 + 13 + int main() { 14 + int i; 15 + @@ -12,8 +10,6 @@ 16 + print_int(func(i)); 17 + } 18 + 19 + - print_ln(); 20 + - 21 + return 0; 22 + } 23 + 24 + @@ -25,7 +21,3 @@ 25 + printf("%d", num); 26 + } 27 + 28 + -void print_ln() { 29 + - printf("\n"); 30 + -} 31 + -
+30
t/t4109/patch4.patch
··· 1 + diff --git a/main.c b/main.c 2 + --- a/main.c 3 + +++ b/main.c 4 + @@ -1,13 +1,14 @@ 5 + #include <stdio.h> 6 + 7 + int func(int num); 8 + -void print_int(int num); 9 + +int func2(int num); 10 + 11 + int main() { 12 + int i; 13 + 14 + for (i = 0; i < 10; i++) { 15 + - print_int(func(i)); 16 + + printf("%d", func(i)); 17 + + printf("%d", func3(i)); 18 + } 19 + 20 + return 0; 21 + @@ -17,7 +18,7 @@ 22 + return num * num; 23 + } 24 + 25 + -void print_int(int num) { 26 + - printf("%d", num); 27 + +int func2(int num) { 28 + + return num * num * num; 29 + } 30 +
+2 -2
t/t4119-apply-config.sh
··· 19 19 ' 20 20 21 21 # Also handcraft GNU diff output; note this has trailing whitespace. 22 - cat >gpatch.file <<\EOF && 22 + tr '_' ' ' >gpatch.file <<\EOF && 23 23 --- file1 2007-02-21 01:04:24.000000000 -0800 24 24 +++ file1+ 2007-02-21 01:07:44.000000000 -0800 25 25 @@ -1 +1 @@ 26 26 -A 27 - +B 27 + +B_ 28 28 EOF 29 29 30 30 sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file &&