Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit c896851

Browse files
dschokasal
authored andcommitted
git grep -O -i: if the pager is 'less', pass the '-I' option
When <command> happens to be the magic string "less", today git grep -O<command> -e<pattern> helpfully passes +/<pattern> to less so you can navigate through the results within a file using the n and shift+n keystrokes. Alas, that doesn't do the right thing for a case-insensitive match, i.e. git grep -i -O<command> -e<pattern> For that case we should pass --IGNORE-CASE to "less" so that n and shift+n can move between results ignoring case in the pattern. The original patch came from msysgit and used "-i", but that was not due to lack of support for "-I" but it merely overlooked that it ought to work even when the pattern contains capital letters. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Stepan Kasal <[email protected]> Helped-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 841ca04 commit c896851

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/grep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
874874
if (len > 4 && is_dir_sep(pager[len - 5]))
875875
pager += len - 4;
876876

877+
if (opt.ignore_case && !strcmp("less", pager))
878+
string_list_append(&path_list, "-I");
879+
877880
if (!strcmp("less", pager) || !strcmp("vi", pager)) {
878881
struct strbuf buf = STRBUF_INIT;
879882
strbuf_addf(&buf, "+/%s%s",

0 commit comments

Comments
 (0)