mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Favor :Ggrep over :Git grep
I'm starting to think :Git grep shouldn't be special cased. Occasionally it is desirable to see grep results without clobbering the quickfix list. Reserve -O/--open-files-in-pager to opt into quickfix behavior, as this fits well with Fugitive's use of a temp buffer as the Git pager.
This commit is contained in:
@@ -21,7 +21,6 @@ improvements:
|
|||||||
enter on a line to view the commit where the line changed, or `g?` to see
|
enter on a line to view the commit where the line changed, or `g?` to see
|
||||||
other available maps. Omit the filename argument and the currently edited
|
other available maps. Omit the filename argument and the currently edited
|
||||||
file will be blamed in a vertical, scroll-bound split.
|
file will be blamed in a vertical, scroll-bound split.
|
||||||
* `:Git grep` loads matches into the quickfix list, just like `:grep`.
|
|
||||||
* `:Git mergetool` and `:Git difftool` load their changesets into the quickfix
|
* `:Git mergetool` and `:Git difftool` load their changesets into the quickfix
|
||||||
list.
|
list.
|
||||||
* Called with no arguments, `:Git` opens a summary window with dirty files and
|
* Called with no arguments, `:Git` opens a summary window with dirty files and
|
||||||
@@ -48,6 +47,7 @@ Additional commands are provided for higher level operations:
|
|||||||
* `:Gwrite` writes to both the work tree and index versions of a file, making
|
* `:Gwrite` writes to both the work tree and index versions of a file, making
|
||||||
it like `git add` when called from a work tree file and like `git checkout`
|
it like `git add` when called from a work tree file and like `git checkout`
|
||||||
when called from the index or a blob in history.
|
when called from the index or a blob in history.
|
||||||
|
* `:Ggrep` is `:grep` for `git grep`. `:Glgrep` is `:lgrep` for the same.
|
||||||
* `:GMove` does a `git mv` on the current file and changes the buffer name to
|
* `:GMove` does a `git mv` on the current file and changes the buffer name to
|
||||||
match. `:GRename` does the same with a destination filename relative to the
|
match. `:GRename` does the same with a destination filename relative to the
|
||||||
current file's directory.
|
current file's directory.
|
||||||
|
|||||||
@@ -4136,6 +4136,9 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
|
|||||||
endif
|
endif
|
||||||
let tree = s:Tree(dir)
|
let tree = s:Tree(dir)
|
||||||
let args = a:options.args
|
let args = a:options.args
|
||||||
|
if get(args, 0, '') =~# '^-O\|--open-files-in-pager$'
|
||||||
|
let args = args[1:-1]
|
||||||
|
endif
|
||||||
let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match')
|
let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match')
|
||||||
let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args
|
let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args
|
||||||
if listnr > 0
|
if listnr > 0
|
||||||
|
|||||||
@@ -437,9 +437,9 @@ unlet s:cmd
|
|||||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
|
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
|
||||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
||||||
|
|
||||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep -O " . <q-args>)'
|
||||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep -O " . <q-args>)'
|
||||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#Command(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#Command(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", "grep -O " . <q-args>)'
|
||||||
|
|
||||||
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
|
||||||
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
|
||||||
|
|||||||
Reference in New Issue
Block a user