summaryrefslogtreecommitdiff
path: root/t/t7006-pager.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2010-06-12 11:36:51 -0500
committerJunio C Hamano <gitster@pobox.com>2010-06-13 09:16:38 -0700
commit678e484b7d4e6388edeec3470bbbcd206817c148 (patch)
tree27f426c9db30f349d54e56cb28ee91c37ef2a050 /t/t7006-pager.sh
parent685359cf2d1996aed2f1b1e2857528819d27105d (diff)
downloadgit-678e484b7d4e6388edeec3470bbbcd206817c148.tar.gz
grep: Add the option '--open-files-in-pager'
This adds an option to open the matching files in the pager, and if the pager happens to be "less" (or "vi") and there is only one grep pattern, it also jumps to the first match right away. The short option was chose as '-O' to avoid clashes with GNU grep's options (as suggested by Junio). So, 'git grep -O abc' is a short form for 'less +/abc $(grep -l abc)' except that it works also with spaces in file names, and it does not start the pager if there was no matching file. [jn: rebased and added tests; with error handling fix from Junio squashed in] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7006-pager.sh')
-rwxr-xr-xt/t7006-pager.sh16
1 files changed, 4 insertions, 12 deletions
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 3bc7a2a796..fc993fc8c4 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -3,6 +3,7 @@
test_description='Test automatic use of a pager.'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-pager.sh
cleanup_fail() {
echo >&2 cleanup failed
@@ -158,21 +159,12 @@ test_expect_success 'color when writing to a file intended for a pager' '
colorful colorful.log
'
-test_expect_success 'determine default pager' '
- unset PAGER GIT_PAGER &&
- test_might_fail git config --unset core.pager ||
- cleanup_fail &&
-
- less=$(git var GIT_PAGER) &&
- test -n "$less"
-'
-
-if expr "$less" : '^[a-z][a-z]*$' >/dev/null && test_have_prereq TTY
+if test_have_prereq SIMPLEPAGER && test_have_prereq TTY
then
- test_set_prereq SIMPLEPAGER
+ test_set_prereq SIMPLEPAGERTTY
fi
-test_expect_success SIMPLEPAGER 'default pager is used by default' '
+test_expect_success SIMPLEPAGERTTY 'default pager is used by default' '
unset PAGER GIT_PAGER &&
test_might_fail git config --unset core.pager &&
rm -f default_pager_used ||