Skip to content
Snippets Groups Projects
Commit db72f829 authored by Jerome Reybert's avatar Jerome Reybert
Browse files

plugin/magit.vim: fix issue of some rare hunk staging (because of some whitespaces)

parent 4a2e8b18
Branches
Tags
No related merge requests found
......@@ -545,12 +545,17 @@ function! s:mg_git_apply(selection)
if ( selection[-1] !~ '^\s*$' )
let selection += [ '' ]
endif
silent let git_result=<SID>mg_system("git apply --cached -", selection)
" when passing List to system as input, there are some rare and
" difficultly reproductable cases failing because of whitespaces
let tmp=tempname()
call writefile(selection, tmp)
silent let git_result=<SID>mg_system("git apply --cached - < " . tmp)
if ( v:shell_error != 0 )
echoerr "Git error: " . git_result
echoerr "Tried to aply this"
echoerr string(a:selection)
endif
call delete(tmp)
endfunction
" s:mg_git_unapply: helper function to unstage a selection
......@@ -568,12 +573,17 @@ function! s:mg_git_unapply(selection, mode)
if ( selection[-1] !~ '^\s*$' )
let selection += [ '' ]
endif
silent let git_result=<SID>mg_system("git apply " . cached_flag . " --reverse - ", selection)
" when passing List to system as input, there are some rare and
" difficultly reproductable cases failing because of whitespaces
let tmp=tempname()
call writefile(selection, tmp)
silent let git_result=<SID>mg_system("git apply " . cached_flag . " --reverse - < " . tmp)
if ( v:shell_error != 0 )
echoerr "Git error: " . git_result
echoerr "Tried to unaply this"
echoerr string(a:selection)
endif
call delete(tmp)
endfunction
" s:mg_get_section: helper function to get the current section, according to
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment