grep portability fix: don't use "-e" or "-q"
System V versions of grep (such as Solaris /usr/bin/grep) don't understand either of these options. git's usage of "grep -e pattern" fell into one of two categories: 1. equivalent to "grep pattern". -e is only useful here if the pattern begins with a "-", but all of the patterns are hardcoded and do not begin with a dash. 2. stripping comments and blank lines with grep -v -e "^$" -e "^#" We can fortunately do this in the affirmative as grep '^[^#]' Uses of "-q" can be replaced with redirection to /dev/null. In many tests, however, "grep -q" is used as "if this string is in the expected output, we are OK". In this case, it is fine to just remove the "-q" entirely; it simply makes the "verbose" mode of the test slightly more verbose. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e85fe4d85b
commit
aadbe44f88
@ -78,8 +78,8 @@ mark_action_done () {
|
|||||||
sed -e 1q < "$TODO" >> "$DONE"
|
sed -e 1q < "$TODO" >> "$DONE"
|
||||||
sed -e 1d < "$TODO" >> "$TODO".new
|
sed -e 1d < "$TODO" >> "$TODO".new
|
||||||
mv -f "$TODO".new "$TODO"
|
mv -f "$TODO".new "$TODO"
|
||||||
count=$(($(grep -ve '^$' -e '^#' < "$DONE" | wc -l)))
|
count=$(grep -c '^[^#]' < "$DONE")
|
||||||
total=$(($count+$(grep -ve '^$' -e '^#' < "$TODO" | wc -l)))
|
total=$(($count+$(grep -c '^[^#]' < "$TODO")))
|
||||||
if test "$last_count" != "$count"
|
if test "$last_count" != "$count"
|
||||||
then
|
then
|
||||||
last_count=$count
|
last_count=$count
|
||||||
@ -110,7 +110,7 @@ die_abort () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
has_action () {
|
has_action () {
|
||||||
grep -vqe '^$' -e '^#' "$1"
|
grep '^[^#]' "$1" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
pick_one () {
|
pick_one () {
|
||||||
|
@ -230,7 +230,7 @@ cmd_init()
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
git ls-files --stage -- "$@" | grep -e '^160000 ' |
|
git ls-files --stage -- "$@" | grep '^160000 ' |
|
||||||
while read mode sha1 stage path
|
while read mode sha1 stage path
|
||||||
do
|
do
|
||||||
# Skip already registered paths
|
# Skip already registered paths
|
||||||
@ -284,7 +284,7 @@ cmd_update()
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
git ls-files --stage -- "$@" | grep -e '^160000 ' |
|
git ls-files --stage -- "$@" | grep '^160000 ' |
|
||||||
while read mode sha1 stage path
|
while read mode sha1 stage path
|
||||||
do
|
do
|
||||||
name=$(module_name "$path") || exit
|
name=$(module_name "$path") || exit
|
||||||
@ -367,7 +367,7 @@ cmd_status()
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
git ls-files --stage -- "$@" | grep -e '^160000 ' |
|
git ls-files --stage -- "$@" | grep '^160000 ' |
|
||||||
while read mode sha1 stage path
|
while read mode sha1 stage path
|
||||||
do
|
do
|
||||||
name=$(module_name "$path") || exit
|
name=$(module_name "$path") || exit
|
||||||
|
@ -245,12 +245,12 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text plus spaces without newline at end should not show spaces' '
|
'text plus spaces without newline at end should not show spaces' '
|
||||||
! (printf "$ttt$sss" | git stripspace | grep -q " ") &&
|
! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$ttt$ttt$sss" | git stripspace | grep -q " ") &&
|
! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep -q " ") &&
|
! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$ttt$sss$sss" | git stripspace | grep -q " ") &&
|
! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$ttt$ttt$sss$sss" | git stripspace | grep -q " ") &&
|
! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$ttt$sss$sss$sss" | git stripspace | grep -q " ")
|
! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
@ -282,12 +282,12 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text plus spaces at end should not show spaces' '
|
'text plus spaces at end should not show spaces' '
|
||||||
! (echo "$ttt$sss" | git stripspace | grep -q " ") &&
|
! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (echo "$ttt$ttt$sss" | git stripspace | grep -q " ") &&
|
! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep -q " ") &&
|
! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (echo "$ttt$sss$sss" | git stripspace | grep -q " ") &&
|
! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (echo "$ttt$ttt$sss$sss" | git stripspace | grep -q " ") &&
|
! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (echo "$ttt$sss$sss$sss" | git stripspace | grep -q " ")
|
! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
@ -341,11 +341,11 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'spaces without newline at end should not show spaces' '
|
'spaces without newline at end should not show spaces' '
|
||||||
! (printf "" | git stripspace | grep -q " ") &&
|
! (printf "" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$sss" | git stripspace | grep -q " ") &&
|
! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$sss$sss" | git stripspace | grep -q " ") &&
|
! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$sss$sss$sss" | git stripspace | grep -q " ") &&
|
! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
||||||
! (printf "$sss$sss$sss$sss" | git stripspace | grep -q " ")
|
! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
@ -149,8 +149,7 @@ test_expect_success 'stop on conflicting pick' '
|
|||||||
diff -u expect .git/.dotest-merge/patch &&
|
diff -u expect .git/.dotest-merge/patch &&
|
||||||
diff -u expect2 file1 &&
|
diff -u expect2 file1 &&
|
||||||
test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) &&
|
test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) &&
|
||||||
test 0 = $(grep -ve "^#" -e "^$" < .git/.dotest-merge/git-rebase-todo |
|
test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo)
|
||||||
wc -l)
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'abort' '
|
test_expect_success 'abort' '
|
||||||
|
@ -15,7 +15,7 @@ check_verify_failure () {
|
|||||||
expect="$2"
|
expect="$2"
|
||||||
test_expect_success "$1" '
|
test_expect_success "$1" '
|
||||||
( ! git-mktag <tag.sig 2>message ) &&
|
( ! git-mktag <tag.sig 2>message ) &&
|
||||||
grep -q "$expect" message
|
grep "$expect" message
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ test_expect_success \
|
|||||||
cd .. &&
|
cd .. &&
|
||||||
git-clone parent child && cd child && git-push --all &&
|
git-clone parent child && cd child && git-push --all &&
|
||||||
cd ../parent &&
|
cd ../parent &&
|
||||||
git-branch -a >branches && ! grep -q origin/master branches
|
git-branch -a >branches && ! grep origin/master branches
|
||||||
'
|
'
|
||||||
|
|
||||||
rewound_push_setup() {
|
rewound_push_setup() {
|
||||||
|
@ -33,7 +33,7 @@ test_expect_success 'setup' '
|
|||||||
|
|
||||||
test_expect_success 'status (1)' '
|
test_expect_success 'status (1)' '
|
||||||
|
|
||||||
grep -e "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ test_expect_success 'override config option -n' '
|
|||||||
git merge --summary c2 >diffstat.txt &&
|
git merge --summary c2 >diffstat.txt &&
|
||||||
verify_merge file result.1-5 msg.1-5 &&
|
verify_merge file result.1-5 msg.1-5 &&
|
||||||
verify_parents $c1 $c2 &&
|
verify_parents $c1 $c2 &&
|
||||||
if ! grep -e "^ file | *2 +-$" diffstat.txt
|
if ! grep "^ file | *2 +-$" diffstat.txt
|
||||||
then
|
then
|
||||||
echo "[OOPS] diffstat was not generated"
|
echo "[OOPS] diffstat was not generated"
|
||||||
fi
|
fi
|
||||||
@ -386,7 +386,7 @@ test_expect_success 'override config option --summary' '
|
|||||||
git merge -n c2 >diffstat.txt &&
|
git merge -n c2 >diffstat.txt &&
|
||||||
verify_merge file result.1-5 msg.1-5 &&
|
verify_merge file result.1-5 msg.1-5 &&
|
||||||
verify_parents $c1 $c2 &&
|
verify_parents $c1 $c2 &&
|
||||||
if grep -e "^ file | *2 +-$" diffstat.txt
|
if grep "^ file | *2 +-$" diffstat.txt
|
||||||
then
|
then
|
||||||
echo "[OOPS] diffstat was generated"
|
echo "[OOPS] diffstat was generated"
|
||||||
false
|
false
|
||||||
|
@ -94,7 +94,7 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'pserver authentication' \
|
test_expect_success 'pserver authentication' \
|
||||||
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
|
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'pserver authentication failure (non-anonymous user)' \
|
test_expect_success 'pserver authentication failure (non-anonymous user)' \
|
||||||
'if cat request-git | git-cvsserver pserver >log 2>&1
|
'if cat request-git | git-cvsserver pserver >log 2>&1
|
||||||
@ -103,11 +103,11 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
|
|||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi &&
|
fi &&
|
||||||
tail -n1 log | grep -q "^I HATE YOU$"'
|
tail -n1 log | grep "^I HATE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'pserver authentication (login)' \
|
test_expect_success 'pserver authentication (login)' \
|
||||||
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
|
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
|
test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
|
||||||
'if cat login-git | git-cvsserver pserver >log 2>&1
|
'if cat login-git | git-cvsserver pserver >log 2>&1
|
||||||
@ -116,7 +116,7 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)'
|
|||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi &&
|
fi &&
|
||||||
tail -n1 log | grep -q "^I HATE YOU$"'
|
tail -n1 log | grep "^I HATE YOU$"'
|
||||||
|
|
||||||
|
|
||||||
# misuse pserver authentication for testing of req_Root
|
# misuse pserver authentication for testing of req_Root
|
||||||
@ -146,15 +146,15 @@ test_expect_success 'req_Root failure (relative pathname)' \
|
|||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi &&
|
fi &&
|
||||||
tail log | grep -q "^error 1 Root must be an absolute pathname$"'
|
tail log | grep "^error 1 Root must be an absolute pathname$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root failure (conflicting roots)' \
|
test_expect_success 'req_Root failure (conflicting roots)' \
|
||||||
'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
|
'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
|
||||||
tail log | grep -q "^error 1 Conflicting roots specified$"'
|
tail log | grep "^error 1 Conflicting roots specified$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root (strict paths)' \
|
test_expect_success 'req_Root (strict paths)' \
|
||||||
'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
|
'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root failure (strict-paths)' '
|
test_expect_success 'req_Root failure (strict-paths)' '
|
||||||
! cat request-anonymous |
|
! cat request-anonymous |
|
||||||
@ -163,7 +163,7 @@ test_expect_success 'req_Root failure (strict-paths)' '
|
|||||||
|
|
||||||
test_expect_success 'req_Root (w/o strict-paths)' \
|
test_expect_success 'req_Root (w/o strict-paths)' \
|
||||||
'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
|
'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root failure (w/o strict-paths)' '
|
test_expect_success 'req_Root failure (w/o strict-paths)' '
|
||||||
! cat request-anonymous |
|
! cat request-anonymous |
|
||||||
@ -181,7 +181,7 @@ EOF
|
|||||||
|
|
||||||
test_expect_success 'req_Root (base-path)' \
|
test_expect_success 'req_Root (base-path)' \
|
||||||
'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
|
'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root failure (base-path)' '
|
test_expect_success 'req_Root failure (base-path)' '
|
||||||
! cat request-anonymous |
|
! cat request-anonymous |
|
||||||
@ -192,14 +192,14 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
|
|||||||
|
|
||||||
test_expect_success 'req_Root (export-all)' \
|
test_expect_success 'req_Root (export-all)' \
|
||||||
'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
|
'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
test_expect_success 'req_Root failure (export-all w/o whitelist)' \
|
test_expect_success 'req_Root failure (export-all w/o whitelist)' \
|
||||||
'! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
|
'! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
|
||||||
|
|
||||||
test_expect_success 'req_Root (everything together)' \
|
test_expect_success 'req_Root (everything together)' \
|
||||||
'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
|
'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
|
||||||
tail -n1 log | grep -q "^I LOVE YOU$"'
|
tail -n1 log | grep "^I LOVE YOU$"'
|
||||||
|
|
||||||
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
|
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ test_expect_success 'gitcvs.enabled = false' \
|
|||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi &&
|
fi &&
|
||||||
cat cvs.log | grep -q "GITCVS emulation disabled" &&
|
grep "GITCVS emulation disabled" cvs.log &&
|
||||||
test ! -d cvswork2'
|
test ! -d cvswork2'
|
||||||
|
|
||||||
rm -fr cvswork2
|
rm -fr cvswork2
|
||||||
@ -237,7 +237,7 @@ test_expect_success 'gitcvs.ext.enabled = false' \
|
|||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi &&
|
fi &&
|
||||||
cat cvs.log | grep -q "GITCVS emulation disabled" &&
|
grep "GITCVS emulation disabled" cvs.log &&
|
||||||
test ! -d cvswork2'
|
test ! -d cvswork2'
|
||||||
|
|
||||||
rm -fr cvswork2
|
rm -fr cvswork2
|
||||||
|
Loading…
Reference in New Issue
Block a user