mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Handle :Gcommit % when working dir isn't Git dir
This commit is contained in:
@@ -634,7 +634,7 @@ function! s:buffer(...) abort
|
|||||||
if buffer.getvar('git_dir') !=# ''
|
if buffer.getvar('git_dir') !=# ''
|
||||||
return buffer
|
return buffer
|
||||||
endif
|
endif
|
||||||
call s:throw('not a git repository: '.expand('%:p'))
|
call s:throw('not a git repository: '.bufname(buffer['#']))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#buffer(...) abort
|
function! fugitive#buffer(...) abort
|
||||||
@@ -1239,7 +1239,14 @@ function! s:Commit(mods, args, ...) abort
|
|||||||
let args = a:args
|
let args = a:args
|
||||||
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-[esp]|--edit|--interactive|--patch|--signoff)%($| )','')
|
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-[esp]|--edit|--interactive|--patch|--signoff)%($| )','')
|
||||||
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-c|--reedit-message|--reuse-message|-F|--file|-m|--message)%(\s+|\=)%(''[^'']*''|"%(\\.|[^"])*"|\\.|\S)*','')
|
let args = s:gsub(args,'%(%(^| )-- )@<!%(^| )@<=%(-c|--reedit-message|--reuse-message|-F|--file|-m|--message)%(\s+|\=)%(''[^'']*''|"%(\\.|[^"])*"|\\.|\S)*','')
|
||||||
let args = s:gsub(args,'%(^| )@<=[%#]%(:\w)*','\=expand(submatch(0))')
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
|
let cwd = getcwd()
|
||||||
|
try
|
||||||
|
exe cd s:fnameescape(repo.tree())
|
||||||
|
let args = s:gsub(args,'\\@<!(\%|##=|#\<=\d+)(:\w)*','\=fnamemodify(FugitivePath(expand(submatch(1))),":." . submatch(2))')
|
||||||
|
finally
|
||||||
|
exe cd cwd
|
||||||
|
endtry
|
||||||
let args = s:sub(args, '\ze -- |$', ' --no-edit --no-interactive --no-signoff')
|
let args = s:sub(args, '\ze -- |$', ' --no-edit --no-interactive --no-signoff')
|
||||||
let args = '-F '.s:shellesc(msgfile).' '.args
|
let args = '-F '.s:shellesc(msgfile).' '.args
|
||||||
if args !~# '\%(^\| \)--cleanup\>'
|
if args !~# '\%(^\| \)--cleanup\>'
|
||||||
|
|||||||
Reference in New Issue
Block a user