@@ -10,58 +10,146 @@ z="$z$z$z$z$z$z$z$z" ;# 512
1010z=" $z$z$z$z " ; # 2048
1111z2047=$( expr " $z " : ' .\(.*\)' ) ; # 2047
1212
13- test_expect_success setup '
14-
15- echo "a$z2047" >file-a &&
16- echo "b" >file-b &&
17- echo "$z2047" >>file-b &&
18- echo "c$z2047" | tr -d "\012" >file-c &&
19- echo "d" >file-d &&
20- echo "$z2047" | tr -d "\012" >>file-d &&
13+ x=zzzzzzzzzz ; # 10
14+ y=" $x$x$x$x$x$x$x$x$x$x " ; # 100
15+ z=" $y$y$y$y$y$y$y$y$y$y " ; # 1000
16+ z1000=$z
17+ z100=$y
18+ z10=$x
2119
22- git add file-a file-b file-c file-d &&
20+ zs () {
21+ count=" $1 "
22+ while test " $count " -ge 1000
23+ do
24+ count=$(( $count - 1000 ))
25+ printf " %s" $z1000
26+ done
27+ while test " $count " -ge 100
28+ do
29+ count=$(( $count - 100 ))
30+ printf " %s" $z100
31+ done
32+ while test " $count " -ge 10
33+ do
34+ count=$(( $count - 10 ))
35+ printf " %s" $z10
36+ done
37+ while test " $count " -ge 1
38+ do
39+ count=$(( $count - 1 ))
40+ printf " z"
41+ done
42+ }
2343
24- echo "A$z2047" >file-a &&
25- echo "B" >file-b &&
26- echo "$z2047" >>file-b &&
27- echo "C$z2047" | tr -d "\012" >file-c &&
28- echo "D" >file-d &&
29- echo "$z2047" | tr -d "\012" >>file-d
30-
31- '
44+ zc () {
45+ sed -e " /^index/d" \
46+ -e " s/$z1000 /Q/g" \
47+ -e " s/QQQQQQQQQ/Z9000/g" \
48+ -e " s/QQQQQQQQ/Z8000/g" \
49+ -e " s/QQQQQQQ/Z7000/g" \
50+ -e " s/QQQQQQ/Z6000/g" \
51+ -e " s/QQQQQ/Z5000/g" \
52+ -e " s/QQQQ/Z4000/g" \
53+ -e " s/QQQ/Z3000/g" \
54+ -e " s/QQ/Z2000/g" \
55+ -e " s/Q/Z1000/g" \
56+ -e " s/$z100 /Q/g" \
57+ -e " s/QQQQQQQQQ/Z900/g" \
58+ -e " s/QQQQQQQQ/Z800/g" \
59+ -e " s/QQQQQQQ/Z700/g" \
60+ -e " s/QQQQQQ/Z600/g" \
61+ -e " s/QQQQQ/Z500/g" \
62+ -e " s/QQQQ/Z400/g" \
63+ -e " s/QQQ/Z300/g" \
64+ -e " s/QQ/Z200/g" \
65+ -e " s/Q/Z100/g" \
66+ -e " s/000Z//g" \
67+ -e " s/$z10 /Q/g" \
68+ -e " s/QQQQQQQQQ/Z90/g" \
69+ -e " s/QQQQQQQQ/Z80/g" \
70+ -e " s/QQQQQQQ/Z70/g" \
71+ -e " s/QQQQQQ/Z60/g" \
72+ -e " s/QQQQQ/Z50/g" \
73+ -e " s/QQQQ/Z40/g" \
74+ -e " s/QQQ/Z30/g" \
75+ -e " s/QQ/Z20/g" \
76+ -e " s/Q/Z10/g" \
77+ -e " s/00Z//g" \
78+ -e " s/z/Q/g" \
79+ -e " s/QQQQQQQQQ/Z9/g" \
80+ -e " s/QQQQQQQQ/Z8/g" \
81+ -e " s/QQQQQQQ/Z7/g" \
82+ -e " s/QQQQQQ/Z6/g" \
83+ -e " s/QQQQQ/Z5/g" \
84+ -e " s/QQQQ/Z4/g" \
85+ -e " s/QQQ/Z3/g" \
86+ -e " s/QQ/Z2/g" \
87+ -e " s/Q/Z1/g" \
88+ -e " s/0Z//g" \
89+ ;
90+ }
3291
33- cat > expect << \EOF
34- diff --git a/file-a b/file-a
35- --- a/file-a
36- +++ b/file-a
92+ expect_pattern () {
93+ cnt=" $1 "
94+ cat << EOF
95+ diff --git a/file-a$cnt b/file-a$cnt
96+ --- a/file-a$cnt
97+ +++ b/file-a$cnt
3798@@ -1 +1 @@
38- -aZ
39- +AZ
40- diff --git a/file-b b/file-b
41- --- a/file-b
42- +++ b/file-b
99+ -Z ${cnt} a
100+ +Z ${cnt} A
101+ diff --git a/file-b$cnt b/file-b$cnt
102+ --- a/file-b$cnt
103+ +++ b/file-b$cnt
43104@@ -1 +1 @@
44105-b
45106+B
46- diff --git a/file-c b/file-c
47- --- a/file-c
48- +++ b/file-c
107+ diff --git a/file-c$cnt b/file-c$cnt
108+ --- a/file-c$cnt
109+ +++ b/file-c$cnt
49110@@ -1 +1 @@
50- -cZ
111+ -cZ$cnt
51112\ No newline at end of file
52- +CZ
113+ +CZ$cnt
53114\ No newline at end of file
54- diff --git a/file-d b/file-d
55- --- a/file-d
56- +++ b/file-d
115+ diff --git a/file-d$cnt b/file-d$cnt
116+ --- a/file-d$cnt
117+ +++ b/file-d$cnt
57118@@ -1 +1 @@
58119-d
59120+D
60121EOF
122+ }
123+
124+ sample=' 1023 1024 1025 2047 4095'
125+
126+ test_expect_success setup '
127+
128+ for n in $sample
129+ do
130+ ( zs $n ; echo a ) >file-a$n &&
131+ ( echo b; zs $n; echo ) >file-b$n &&
132+ ( printf c; zs $n ) >file-c$n &&
133+ ( echo d; zs $n ) >file-d$n &&
134+
135+ git add file-a$n file-b$n file-c$n file-d$n &&
136+
137+ ( zs $n ; echo A ) >file-a$n &&
138+ ( echo B; zs $n; echo ) >file-b$n &&
139+ ( printf C; zs $n ) >file-c$n &&
140+ ( echo D; zs $n ) >file-d$n &&
141+
142+ expect_pattern $n || break
143+
144+ done >expect
145+ '
61146
62147test_expect_success ' diff -U0' '
63148
64- git diff -U0 | sed -e "/^index/d" -e "s/$z2047/Z/g" >actual &&
149+ for n in $sample
150+ do
151+ git diff -U0 file-?$n
152+ done | zc >actual &&
65153 diff -u expect actual
66154
67155'
0 commit comments