mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 13:23:52 -05:00
Use unambiguous option keys for subcommand delegation
This commit is contained in:
@@ -2555,7 +2555,7 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
|||||||
let options = {'git': git, 'dir': dir, 'flags': flags}
|
let options = {'git': git, 'dir': dir, 'flags': flags}
|
||||||
if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help'
|
||||||
try
|
try
|
||||||
let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'command': args[0], 'args': args[1:-1]}, options))
|
let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'subcommand': args[0], 'subcommand_args': args[1:-1]}, options))
|
||||||
if type(overrides) == type('')
|
if type(overrides) == type('')
|
||||||
return 'exe ' . string(overrides) . after
|
return 'exe ' . string(overrides) . after
|
||||||
endif
|
endif
|
||||||
@@ -3907,7 +3907,7 @@ function! s:CommitInteractive(line1, line2, range, bang, mods, options, patch) a
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CommitSubcommand(line1, line2, range, bang, mods, options) abort
|
function! s:CommitSubcommand(line1, line2, range, bang, mods, options) abort
|
||||||
let argv = copy(a:options.args)
|
let argv = copy(a:options.subcommand_args)
|
||||||
let i = 0
|
let i = 0
|
||||||
while get(argv, i, '--') !=# '--'
|
while get(argv, i, '--') !=# '--'
|
||||||
if argv[i] =~# '^-[apzsneiovq].'
|
if argv[i] =~# '^-[apzsneiovq].'
|
||||||
@@ -3968,7 +3968,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort
|
function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort
|
||||||
let dir = a:options.dir
|
let dir = a:options.dir
|
||||||
if empty(a:options.args) && (
|
if empty(a:options.subcommand_args) && (
|
||||||
\ filereadable(fugitive#Find('.git/MERGE_MSG', dir)) ||
|
\ filereadable(fugitive#Find('.git/MERGE_MSG', dir)) ||
|
||||||
\ isdirectory(fugitive#Find('.git/rebase-apply', dir)) ||
|
\ isdirectory(fugitive#Find('.git/rebase-apply', dir)) ||
|
||||||
\ !empty(s:TreeChomp(dir, 'diff-files', '--diff-filter=U')))
|
\ !empty(s:TreeChomp(dir, 'diff-files', '--diff-filter=U')))
|
||||||
@@ -3978,7 +3978,7 @@ function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RebaseSubcommand(line1, line2, range, bang, mods, options) abort
|
function! s:RebaseSubcommand(line1, line2, range, bang, mods, options) abort
|
||||||
let args = a:options.args
|
let args = a:options.subcommand_args
|
||||||
if s:HasOpt(args, '--autosquash') && !s:HasOpt(args, '-i', '--interactive')
|
if s:HasOpt(args, '--autosquash') && !s:HasOpt(args, '-i', '--interactive')
|
||||||
return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'insert_args': ['--interactive']}
|
return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'insert_args': ['--interactive']}
|
||||||
endif
|
endif
|
||||||
@@ -4108,7 +4108,7 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab
|
|||||||
endif
|
endif
|
||||||
let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv
|
let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv
|
||||||
if prompt
|
if prompt
|
||||||
let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.command] + a:options.args)
|
let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.subcommand] + a:options.subcommand_args)
|
||||||
return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, a:mods, s:function('s:ToolParse'), a:state)
|
return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, a:mods, s:function('s:ToolParse'), a:state)
|
||||||
else
|
else
|
||||||
let filename = ''
|
let filename = ''
|
||||||
@@ -4139,14 +4139,14 @@ function! s:MergetoolSubcommand(line1, line2, range, bang, mods, options) abort
|
|||||||
let state = {'name_only': 0}
|
let state = {'name_only': 0}
|
||||||
let state.diff = [{'prefix': ':2:', 'module': ':2:'}, {'prefix': ':3:', 'module': ':3:'}, {'prefix': ':(top)'}]
|
let state.diff = [{'prefix': ':2:', 'module': ':2:'}, {'prefix': ':3:', 'module': ':3:'}, {'prefix': ':(top)'}]
|
||||||
call map(state.diff, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})')
|
call map(state.diff, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})')
|
||||||
return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.args, state)
|
return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.subcommand_args, state)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DifftoolSubcommand(line1, line2, range, bang, mods, options) abort
|
function! s:DifftoolSubcommand(line1, line2, range, bang, mods, options) abort
|
||||||
let dir = a:options.dir
|
let dir = a:options.dir
|
||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
let i = 0
|
let i = 0
|
||||||
let argv = copy(a:options.args)
|
let argv = copy(a:options.subcommand_args)
|
||||||
let commits = []
|
let commits = []
|
||||||
let cached = 0
|
let cached = 0
|
||||||
let reverse = 1
|
let reverse = 1
|
||||||
@@ -4277,7 +4277,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
|
|||||||
let listnr = a:line1 == 0 ? a:line1 : a:line2
|
let listnr = a:line1 == 0 ? a:line1 : a:line2
|
||||||
let cmd = ['--no-pager', 'grep', '-n', '--no-color', '--full-name']
|
let cmd = ['--no-pager', 'grep', '-n', '--no-color', '--full-name']
|
||||||
let tree = s:Tree(dir)
|
let tree = s:Tree(dir)
|
||||||
let args = a:options.args
|
let args = a:options.subcommand_args
|
||||||
if get(args, 0, '') =~# '^-O\|--open-files-in-pager$'
|
if get(args, 0, '') =~# '^-O\|--open-files-in-pager$'
|
||||||
let args = args[1:-1]
|
let args = args[1:-1]
|
||||||
endif
|
endif
|
||||||
@@ -5275,7 +5275,7 @@ endfunction
|
|||||||
function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
let flags = copy(a:options.args)
|
let flags = copy(a:options.subcommand_args)
|
||||||
let i = 0
|
let i = 0
|
||||||
let raw = 0
|
let raw = 0
|
||||||
let commits = []
|
let commits = []
|
||||||
@@ -5348,7 +5348,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
|||||||
endif
|
endif
|
||||||
exe s:BlameLeave()
|
exe s:BlameLeave()
|
||||||
try
|
try
|
||||||
let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.command, '--show-number']
|
let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.subcommand, '--show-number']
|
||||||
call extend(cmd, filter(copy(flags), 'v:val !~# "\\v^%(-b|--%(no-)=color-.*|--progress)$"'))
|
call extend(cmd, filter(copy(flags), 'v:val !~# "\\v^%(-b|--%(no-)=color-.*|--progress)$"'))
|
||||||
if a:count > 0 && empty(ranges)
|
if a:count > 0 && empty(ranges)
|
||||||
let cmd += ['-L', (a:line1 ? a:line1 : line('.')) . ',' . (a:line1 ? a:line1 : line('.'))]
|
let cmd += ['-L', (a:line1 ? a:line1 : line('.')) . ',' . (a:line1 ? a:line1 : line('.'))]
|
||||||
@@ -5392,7 +5392,12 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
|||||||
endfor
|
endfor
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
let temp_state = {'dir': dir, 'filetype': (raw ? '' : 'fugitiveblame'), 'options': a:options, 'blame_flags': flags, 'blame_file': file}
|
let temp_state = {
|
||||||
|
\ 'dir': dir,
|
||||||
|
\ 'filetype': (raw ? '' : 'fugitiveblame'),
|
||||||
|
\ 'blame_options': a:options,
|
||||||
|
\ 'blame_flags': flags,
|
||||||
|
\ 'blame_file': file}
|
||||||
if s:HasOpt(flags, '--reverse')
|
if s:HasOpt(flags, '--reverse')
|
||||||
let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*')
|
let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*')
|
||||||
endif
|
endif
|
||||||
@@ -5573,10 +5578,10 @@ function! s:BlameJump(suffix, ...) abort
|
|||||||
let my_bufnr = bufnr('')
|
let my_bufnr = bufnr('')
|
||||||
if blame_bufnr < 0
|
if blame_bufnr < 0
|
||||||
let blame_args = flags + [commit . suffix, '--', path]
|
let blame_args = flags + [commit . suffix, '--', path]
|
||||||
let result = s:BlameSubcommand(0, 0, 0, 0, '', extend({'args': blame_args}, state.options, 'keep'))
|
let result = s:BlameSubcommand(0, 0, 0, 0, '', extend({'subcommand_args': blame_args}, state.blame_options, 'keep'))
|
||||||
else
|
else
|
||||||
let blame_args = flags
|
let blame_args = flags
|
||||||
let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'args': blame_args}, state.options, 'keep'))
|
let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'subcommand_args': blame_args}, state.blame_options, 'keep'))
|
||||||
endif
|
endif
|
||||||
if bufnr('') == my_bufnr
|
if bufnr('') == my_bufnr
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user