summaryrefslogtreecommitdiff
path: root/t/lib-pager.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2010-06-12 16:36:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-06-13 16:16:38 (GMT)
commit678e484b7d4e6388edeec3470bbbcd206817c148 (patch)
tree27f426c9db30f349d54e56cb28ee91c37ef2a050 /t/lib-pager.sh
parent685359cf2d1996aed2f1b1e2857528819d27105d (diff)
downloadgit-678e484b7d4e6388edeec3470bbbcd206817c148.zip
git-678e484b7d4e6388edeec3470bbbcd206817c148.tar.gz
git-678e484b7d4e6388edeec3470bbbcd206817c148.tar.bz2
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/lib-pager.sh')
-rw-r--r--t/lib-pager.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/lib-pager.sh b/t/lib-pager.sh
new file mode 100644
index 0000000..f8c6025
--- /dev/null
+++ b/t/lib-pager.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+test_expect_success 'determine default pager' '
+ test_might_fail git config --unset core.pager &&
+ less=$(
+ unset PAGER GIT_PAGER;
+ git var GIT_PAGER
+ ) &&
+ test -n "$less"
+'
+
+if expr "$less" : '^[a-z][a-z]*$' >/dev/null
+then
+ test_set_prereq SIMPLEPAGER
+fi