Emphasize :Glog behavior change

Let's go ahead and embrace :Gclog as a warning free version of the
command.
This commit is contained in:
Tim Pope
2019-08-13 18:12:58 -04:00
parent 1359d620eb
commit 53e5e61afa
3 changed files with 18 additions and 14 deletions

View File

@@ -29,8 +29,9 @@ the buffer.
Use `:Ggrep` to search the work tree (or any arbitrary commit) with Use `:Ggrep` to search the work tree (or any arbitrary commit) with
`git grep`, skipping over that which is not tracked in the repository. `git grep`, skipping over that which is not tracked in the repository.
`:Glog` loads all previous revisions of a file into the quickfix list so `:Gclog` and `:Gllog` load all previous commits into the quickfix or location
you can iterate over them and watch the file evolve. list. Give them a range (e.g., using visual mode and `:'<,'>Gclog`) to
iterate over every change to that portion of the current file.
`:Gread` is a variant of `git checkout -- filename` that operates on the `:Gread` is a variant of `git checkout -- filename` that operates on the
buffer rather than the filename. This means you can use `u` to undo it buffer rather than the filename. This means you can use `u` to undo it

View File

@@ -3804,7 +3804,7 @@ function! s:LogParse(state, target, dir, line) abort
return [] return []
endfunction endfunction
function! s:Log(type, bang, line1, count, args) abort function! s:Log(type, bang, line1, count, args, legacy) abort
let dir = s:Dir() let dir = s:Dir()
exe s:DirCheck(dir) exe s:DirCheck(dir)
let listnr = a:type =~# '^l' ? 0 : -1 let listnr = a:type =~# '^l' ? 0 : -1
@@ -3863,16 +3863,19 @@ function! s:Log(type, bang, line1, count, args) abort
\ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] + \ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] +
\ args + paths + extra) \ args + paths + extra)
let state = {'context': 'init', 'child_found': 0, 'queue': []} let state = {'context': 'init', 'child_found': 0, 'queue': []}
let title = (listnr < 0 ? ':Glog ' : ':Gllog ') . s:fnameescape(args + paths) let title = (listnr < 0 ? ':Gclog ' : ':Gllog ') . s:fnameescape(args + paths)
if empty(paths + extra) && a:legacy && len(s:Relative('/'))
let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after
endif
return s:QuickfixStream(listnr, title, cmd, !a:bang, s:function('s:LogParse'), state, path, dir) . after return s:QuickfixStream(listnr, title, cmd, !a:bang, s:function('s:LogParse'), state, path, dir) . after
endfunction endfunction
call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep", "grep") call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep", "grep")
call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:GrepSubcommand(-1, -1, 0, <bang>0, '<mods>', <q-args>)") call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:GrepSubcommand(-1, -1, 0, <bang>0, '<mods>', <q-args>)")
call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, <bang>0, '<mods>', <q-args>)") call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, <bang>0, '<mods>', <q-args>)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>)") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 1)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>)") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 0)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',<bang>0,<line1>,<count>,<q-args>)") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',<bang>0,<line1>,<count>,<q-args>, 0)")
" Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread " Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread

View File

@@ -78,19 +78,19 @@ that are part of Git repositories).
*fugitive-:Glgrep* *fugitive-:Glgrep*
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. :Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'.
*fugitive-:Glog* *fugitive-:Gclog* *fugitive-:Gclog* *fugitive-:Glog*
:Glog[!] [args] Use git-log [args] to load the commit history into the :Gclog[!] [args] Use git-log [args] to load the commit history into the
|quickfix| list. Jump to the first commit unless [!] :Glog[!] [args] |quickfix| list. Jump to the first commit unless [!]
is given. is given.
:{range}Glog[!] [args] Use git-log -L to load previous revisions of the given :{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list. range of the current file into the |quickfix| list.
The cursor is positioned on the first line of the The cursor is positioned on the first line of the
first diff hunk for each commit. Use :0Glog to target first diff hunk for each commit. Use :0Gclog to
the entire file. target the entire file.
*fugitive-:Gllog* *fugitive-:Gllog*
:Gllog [args] Like |:Glog|, but use the location list instead of the :Gllog [args] Like |:Gclog|, but use the location list instead of the
|quickfix| list. |quickfix| list.
*fugitive-:Gedit* *fugitive-:Ge* *fugitive-:Gedit* *fugitive-:Ge*