Skip to content

Commit

Permalink
tests: grep portability fixes
Browse files Browse the repository at this point in the history
We try to avoid using the "-q" or "-e" options, as they are
largely useless, as explained in aadbe44.

There is one exception for "-e" here, which is in t7701 used
to produce an "or" of patterns. This can be rewritten as an
egrep pattern.

This patch also removes use of "grep -F" in favor of the
more widely available "fgrep".

[sp: Tested on AIX 5.3 by Mike Ralphson,
     Tested on MinGW by Johannes Sixt]

Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Mike Ralphson <mike@abacus.co.uk>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
peff authored and spearce committed Sep 30, 2008
1 parent c33912a commit 8753941
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions t/t0002-gitfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_expect_success 'bad setup: invalid .git file format' '
echo "git rev-parse accepted an invalid .git file"
false
fi &&
if ! grep -qe "Invalid gitfile format" .err
if ! grep "Invalid gitfile format" .err
then
echo "git rev-parse returned wrong error"
false
Expand All @@ -46,7 +46,7 @@ test_expect_success 'bad setup: invalid .git file path' '
echo "git rev-parse accepted an invalid .git file path"
false
fi &&
if ! grep -qe "Not a git repository" .err
if ! grep "Not a git repository" .err
then
echo "git rev-parse returned wrong error"
false
Expand Down
2 changes: 1 addition & 1 deletion t/t1501-worktree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ test_expect_success 'git diff' '

test_expect_success 'git grep' '
(cd repo.git/work/sub &&
GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep -q dir/tracked)
GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked)
'

test_done
2 changes: 1 addition & 1 deletion t/t3700-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
git reset --hard &&
touch fo\[ou\]bar foobar &&
git add '\''fo\[ou\]bar'\'' &&
git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
git ls-files fo\[ou\]bar | fgrep fo\[ou\]bar &&
! ( git ls-files foobar | grep foobar )
'

Expand Down
2 changes: 1 addition & 1 deletion t/t4150-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test_expect_success 'am --keep really keeps the subject' '
git am --keep patch4 &&
! test -d .git/rebase-apply &&
git cat-file commit HEAD |
grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third"
fgrep "Re: Re: Re: [PATCH 1/5 v2] third"
'

test_expect_success 'am -3 falls back to 3-way merge' '
Expand Down
4 changes: 2 additions & 2 deletions t/t6040-tracking-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test_expect_success 'checkout' '
(
cd test && git checkout b1
) >actual &&
grep -e "have 1 and 1 different" actual
grep "have 1 and 1 different" actual
'

test_expect_success 'status' '
Expand All @@ -63,7 +63,7 @@ test_expect_success 'status' '
# reports nothing to commit
test_must_fail git status
) >actual &&
grep -e "have 1 and 1 different" actual
grep "have 1 and 1 different" actual
'


Expand Down
2 changes: 1 addition & 1 deletion t/t7002-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ do
'

test_expect_success "grep -c $L (no /dev/null)" '
! git grep -c test $H | grep -q /dev/null
! git grep -c test $H | grep /dev/null
'

done
Expand Down
4 changes: 2 additions & 2 deletions t/t7701-repack-unpack-unreachable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
git repack -A -d -l &&
# verify objects are packed in repository
test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
egrep "^($fsha1|$csha1|$tsha1) " |
sort | uniq | wc -l) &&
git show $fsha1 &&
git show $csha1 &&
Expand All @@ -41,7 +41,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
git repack -A -d -l &&
# verify objects are retained unpacked
test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
egrep "^($fsha1|$csha1|$tsha1) " |
sort | uniq | wc -l) &&
git show $fsha1 &&
git show $csha1 &&
Expand Down
2 changes: 1 addition & 1 deletion t/t9500-gitweb-standalone-no-errors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ gitweb_run () {
rm -f gitweb.log &&
perl -- "$TEST_DIRECTORY/../gitweb/gitweb.perl" \
>/dev/null 2>gitweb.log &&
if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
if grep "^[[]" gitweb.log >/dev/null 2>&1; then false; else true; fi

# gitweb.log is left for debugging
}
Expand Down

0 comments on commit 8753941

Please sign in to comment.