Skip to content

Commit 1b1cdd5

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. 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 1b1cdd5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

autoload/fugitive.vim

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,10 +3759,27 @@ 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+
return has('win32') ? 0 : 1
3779+
else
3780+
" unknown help format, assume pager
3781+
return 1
3782+
endif
37663783
endif
37673784
if args[0] ==# 'config' && (s:HasOpt(args, '-e', '--edit') ||
37683785
\ !s:HasOpt(args, '--list', '--get-all', '--get-regexp', '--get-urlmatch')) ||
@@ -3772,7 +3789,6 @@ function! fugitive#PagerFor(argv, ...) abort
37723789
\ !s:HasOpt(args, '--contains', '--no-contains', '--merged', '--no-merged', '--points-at'))
37733790
return 0
37743791
endif
3775-
let config = a:0 ? a:1 : fugitive#Config()
37763792
let value = get(fugitive#ConfigGetAll('pager.' . args[0], config), 0, -1)
37773793
if value =~# '^\%(true\|yes\|on\|1\)$'
37783794
return 1

0 commit comments

Comments
 (0)