From: Jeff King Date: Tue, 30 Sep 2008 08:03:55 +0000 (-0400) Subject: tests: grep portability fixes X-Git-Tag: v1.6.1-rc1~190 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=87539416fd25bfa62122ddf4f7a7b8794d5d5aa2;p=git.git tests: grep portability fixes We try to avoid using the "-q" or "-e" options, as they are largely useless, as explained in aadbe44f. 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 Tested-by: Mike Ralphson Tested-by: Johannes Sixt Signed-off-by: Shawn O. Pearce --- diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh index 4db4ac44c..cb144258c 100755 --- a/t/t0002-gitfile.sh +++ b/t/t0002-gitfile.sh @@ -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 @@ -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 diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index c039ee3fd..f6a6f839a 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -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 diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 2ac93a346..9f6454d2f 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -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 ) ' diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 1be5fb3f9..796f79526 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -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' ' diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index aac212e93..ba9060190 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -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' ' @@ -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 ' diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 5e359cb56..18fe6f2d5 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -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 diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index 531dac060..b48046e26 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -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 && @@ -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 && diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index 46ba19be7..07117a8b7 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -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 }