mirror of
https://github.com/git/git.git
synced 2024-11-20 14:13:58 +01:00
678e484b7d
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>
16 lines
271 B
Bash
16 lines
271 B
Bash
#!/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
|