Skip to content

Commit cb4dab6

Browse files
Do not show empty split for Git help <cmd> on Windows
Git for Windows shows help for its subcommands in a browser by default; so `Git help rebase`, for example, brings up empty split. Git for MinGW behaves the same way. If Git configuration option `help.format` is defined, it takes precedence over default behavior. This commit covers notable exceptions to that: `git help`, `git -h`, `git help -a`, `git help -g`, `git help --man` and `git --help`. Also, `git <cmd> -h` and `git <cmd> --help` behave differently.
1 parent 61b51c0 commit cb4dab6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

autoload/fugitive.vim

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,10 +3759,29 @@ endfunction
37593759

37603760
function! fugitive#PagerFor(argv, ...) abort
37613761
let args = a:argv
3762+
let config = a:0 ? a:1 : fugitive#Config()
37623763
if empty(args)
37633764
return 0
3764-
elseif (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web')
3765+
elseif len(args) == 1 && args[0] =~# '\v^(--help|help|-h)$'
3766+
return 1
3767+
elseif len(args) == 2 && args[0] ==# 'help' && args[1] =~# '\v^(-[ag]|--man)$'
37653768
return 1
3769+
elseif len(args) == 2 && args[1] ==# '-h'
3770+
return 1
3771+
elseif (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web')
3772+
let helpFormat = get(fugitive#ConfigGetAll('help.format', config), 0, '')
3773+
if helpFormat ==# 'man' || helpFormat ==# 'info'
3774+
return 1
3775+
elseif helpFormat ==# 'web' || helpFormat ==# 'html'
3776+
return 0
3777+
elseif helpFormat ==# ''
3778+
" let isWinGit = has('win32')
3779+
let isWinGit = fugitive#GitVersion() =~# '\.\(windows\|msysgit\)\>'
3780+
return isWinGit ? 0 : 1
3781+
else
3782+
" unknown help format, assume pager
3783+
return 1
3784+
endif
37663785
endif
37673786
if args[0] ==# 'config' && (s:HasOpt(args, '-e', '--edit') ||
37683787
\ !s:HasOpt(args, '--list', '--get-all', '--get-regexp', '--get-urlmatch')) ||
@@ -3772,7 +3791,6 @@ function! fugitive#PagerFor(argv, ...) abort
37723791
\ !s:HasOpt(args, '--contains', '--no-contains', '--merged', '--no-merged', '--points-at'))
37733792
return 0
37743793
endif
3775-
let config = a:0 ? a:1 : fugitive#Config()
37763794
let value = get(fugitive#ConfigGetAll('pager.' . args[0], config), 0, -1)
37773795
if value =~# '^\%(true\|yes\|on\|1\)$'
37783796
return 1

0 commit comments

Comments
 (0)