Skip to content

Commit d828fdb

Browse files
committed
Merge branch 'jc/maint-obsd46' into maint
* jc/maint-obsd46: t4019 "grep" portability fix t1200: work around a bug in some implementations of "find"
2 parents 5717b47 + eca4460 commit d828fdb

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

t/t1200-tutorial.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ test_expect_success 'git repack' 'git repack'
259259
test_expect_success 'git prune-packed' 'git prune-packed'
260260
test_expect_success '-> only packed objects' '
261261
git prune && # Remove conflict marked blobs
262-
! find .git/objects/[0-9a-f][0-9a-f] -type f
262+
test $(find .git/objects/[0-9a-f][0-9a-f] -type f -print 2>/dev/null | wc -l) = 0
263263
'
264264

265265
test_done

t/t4019-diff-wserror.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@ test_expect_success setup '
2020

2121
blue_grep='7;34m' ;# ESC [ 7 ; 3 4 m
2222

23+
printf "\033[%s" "$blue_grep" >check-grep
24+
if (grep "$blue_grep" <check-grep | grep "$blue_grep") >/dev/null 2>&1
25+
then
26+
grep_a=grep
27+
elif (grep -a "$blue_grep" <check-grep | grep -a "$blue_grep") >/dev/null 2>&1
28+
then
29+
grep_a='grep -a'
30+
else
31+
grep_a=grep ;# expected to fail...
32+
fi
33+
rm -f check-grep
34+
35+
prepare_output () {
36+
git diff --color >output
37+
$grep_a "$blue_grep" output >error
38+
$grep_a -v "$blue_grep" output >normal
39+
}
40+
2341
test_expect_success default '
2442
25-
git diff --color >output
26-
grep "$blue_grep" output >error
27-
grep -v "$blue_grep" output >normal
43+
prepare_output
2844
2945
grep Eight normal >/dev/null &&
3046
grep HT error >/dev/null &&
@@ -37,9 +53,7 @@ test_expect_success default '
3753
test_expect_success 'without -trail' '
3854
3955
git config core.whitespace -trail
40-
git diff --color >output
41-
grep "$blue_grep" output >error
42-
grep -v "$blue_grep" output >normal
56+
prepare_output
4357
4458
grep Eight normal >/dev/null &&
4559
grep HT error >/dev/null &&
@@ -53,9 +67,7 @@ test_expect_success 'without -trail (attribute)' '
5367
5468
git config --unset core.whitespace
5569
echo "F whitespace=-trail" >.gitattributes
56-
git diff --color >output
57-
grep "$blue_grep" output >error
58-
grep -v "$blue_grep" output >normal
70+
prepare_output
5971
6072
grep Eight normal >/dev/null &&
6173
grep HT error >/dev/null &&
@@ -69,9 +81,7 @@ test_expect_success 'without -space' '
6981
7082
rm -f .gitattributes
7183
git config core.whitespace -space
72-
git diff --color >output
73-
grep "$blue_grep" output >error
74-
grep -v "$blue_grep" output >normal
84+
prepare_output
7585
7686
grep Eight normal >/dev/null &&
7787
grep HT normal >/dev/null &&
@@ -85,9 +95,7 @@ test_expect_success 'without -space (attribute)' '
8595
8696
git config --unset core.whitespace
8797
echo "F whitespace=-space" >.gitattributes
88-
git diff --color >output
89-
grep "$blue_grep" output >error
90-
grep -v "$blue_grep" output >normal
98+
prepare_output
9199
92100
grep Eight normal >/dev/null &&
93101
grep HT normal >/dev/null &&
@@ -101,9 +109,7 @@ test_expect_success 'with indent-non-tab only' '
101109
102110
rm -f .gitattributes
103111
git config core.whitespace indent,-trailing,-space
104-
git diff --color >output
105-
grep "$blue_grep" output >error
106-
grep -v "$blue_grep" output >normal
112+
prepare_output
107113
108114
grep Eight error >/dev/null &&
109115
grep HT normal >/dev/null &&
@@ -117,9 +123,7 @@ test_expect_success 'with indent-non-tab only (attribute)' '
117123
118124
git config --unset core.whitespace
119125
echo "F whitespace=indent,-trailing,-space" >.gitattributes
120-
git diff --color >output
121-
grep "$blue_grep" output >error
122-
grep -v "$blue_grep" output >normal
126+
prepare_output
123127
124128
grep Eight error >/dev/null &&
125129
grep HT normal >/dev/null &&
@@ -133,9 +137,7 @@ test_expect_success 'with cr-at-eol' '
133137
134138
rm -f .gitattributes
135139
git config core.whitespace cr-at-eol
136-
git diff --color >output
137-
grep "$blue_grep" output >error
138-
grep -v "$blue_grep" output >normal
140+
prepare_output
139141
140142
grep Eight normal >/dev/null &&
141143
grep HT error >/dev/null &&
@@ -149,9 +151,7 @@ test_expect_success 'with cr-at-eol (attribute)' '
149151
150152
git config --unset core.whitespace
151153
echo "F whitespace=trailing,cr-at-eol" >.gitattributes
152-
git diff --color >output
153-
grep "$blue_grep" output >error
154-
grep -v "$blue_grep" output >normal
154+
prepare_output
155155
156156
grep Eight normal >/dev/null &&
157157
grep HT error >/dev/null &&
@@ -195,7 +195,7 @@ test_expect_success 'color new trailing blank lines' '
195195
git add x &&
196196
{ echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x &&
197197
git diff --color x >output &&
198-
cnt=$(grep "${blue_grep}" output | wc -l) &&
198+
cnt=$($grep_a "${blue_grep}" output | wc -l) &&
199199
test $cnt = 2
200200
'
201201

0 commit comments

Comments
 (0)