commit 7c66d544e511bc9529a851e2a8c8d3bb3f6d5b4b (tree)
parent c8ac43422e4bb5d96d94b8979a0275911c946825
Author: Tim Pope <code@tpope.net>
Date: Sat, 29 Jun 2019 19:55:16 -0400
Only target current file if range is given to :Glog
Diffstat:
2 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -3111,24 +3111,19 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
let before = substitute(args, ' --\S\@!.*', '', '')
let after = strpart(args, len(before))
let path = s:Relative('/')
- let relative = path[1:-1]
- if path =~# '^/\.git\%(/\|$\)' || len(after)
+ if path =~# '^/\.git\%(/\|$\)' || a:line2 < 0
let path = ''
+ elseif a:line2 > 0
+ let before .= ' -L ' . s:shellesc(a:line1 . ',' . a:line2 . ':' . path[1:-1])
+ else
+ let after = (len(after) > 3 ? after : ' -- ') . path[1:-1]
endif
- if before !~# '\s[^[:space:]-]'
+ if len(path) && before !~# '\s[^[:space:]-]'
let owner = s:Owner(@%)
if len(owner)
let before .= ' ' . s:shellesc(owner)
endif
endif
- if relative =~# '^\.git\%(/\|$\)'
- let relative = ''
- endif
- if len(relative) && a:line2 > 0
- let before .= ' -L ' . s:shellesc(a:line1 . ',' . a:line2 . ':' . relative)
- elseif len(relative) && (empty(after) || a:line2 == 0)
- let after = (len(after) > 3 ? after : ' -- ') . relative
- endif
let grepformat = &grepformat
let grepprg = &grepprg
try
@@ -3138,12 +3133,6 @@ function! s:Log(cmd, bang, line1, line2, ...) abort
\ s:shellesc('--pretty=format:fugitive://'.s:Dir().'//%H'.path.'::'.format), '%#')
let &grepformat = '%Cdiff %.%#,%C--- %.%#,%C+++ %.%#,%Z@@ -%\d%\+\,%\d%\+ +%l\,%\d%\+ @@,%-G-%.%#,%-G+%.%#,%-G %.%#,%A%f::%m,%-G%.%#'
exe a:cmd . (a:bang ? '! ' : ' ') . s:ShellExpand(before . after)
- if len(path) && a:line2 == -1
- redraw
- echohl WarningMsg
- echo ':Glog will soon default to all files. Use :0Glog to target current file'
- echohl NONE
- endif
finally
let &grepformat = grepformat
let &grepprg = grepprg
diff --git a/doc/fugitive.txt b/doc/fugitive.txt
@@ -75,14 +75,11 @@ that are part of Git repositories).
:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'.
*fugitive-:Glog*
-:Glog [args] Load the commit history into the |quickfix| list.
- Additional git-log arguments can be given (for
- example, --reverse). Provide "--" in the argument
- list to target all commits. Otherwise, only commits
- changing the current file will be targeted. This
- special casing is slated to be removed.
-
-:{range}Glog [args] Use git-log -L to load previous revisions of the given
+:Glog[!] [args] Use git-log [args] to load the commit history into the
+ |quickfix| list. Jump to the first commit unless [!]
+ is given.
+
+:{range}Glog[!] [args] Use git-log -L to load previous revisions of the given
range of the current file into the |quickfix| list.
The cursor is positioned on the first line of the
first diff hunk for each commit. Use :0Glog to target