author | Johannes Schindelin <johannes.schindelin@gmx.de> | |
Sat, 12 Jun 2010 16:36:51 +0000 (11:36 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 13 Jun 2010 16:16:38 +0000 (09:16 -0700) | ||
commit | 678e484b7d4e6388edeec3470bbbcd206817c148 | |
tree | 27f426c9db30f349d54e56cb28ee91c37ef2a050 | tree | snapshot |
parent | 685359cf2d1996aed2f1b1e2857528819d27105d | commit | diff |
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>
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>
Documentation/git-grep.txt | diff | blob | history | |
builtin/grep.c | diff | blob | history | |
git.c | diff | blob | history | |
t/lib-pager.sh | [new file with mode: 0644] | blob |
t/t7002-grep.sh | [deleted file] | blob | history |
t/t7006-pager.sh | diff | blob | history | |
t/t7810-grep.sh | [new file with mode: 0755] | blob |
t/t7811-grep-open.sh | [new file with mode: 0755] | blob |