Closed ptn closed 4 years ago
What's the correct way to complete the patch operation?
What you did seems correct but I'm not sure while I have no idea what you did in detail.
Could you give me a minimum vimrc and a step by step procedure to reproduce the error on my computer?
a minimum vimrc is something like https://github.com/lambdalisue/fern.vim/issues/83#issuecomment-586678722
I thought this would be a quick question kind of issue, apologies for the incomplete report! Here you go:
Commands I ran in the terminal:
dotfiles - master $ cat ~/.vimrc.min
" How to use this vimrc.min
" vim -u ~/vimrc.min
" nvim -u ~/vimrc.min
if has('vim_starting')
set nocompatible
endif
" Rewrite it to path/to/your/fern.vim
set runtimepath+=~/code/gina.vim
filetype plugin indent on
syntax on
dotfiles - master $ pwd
/Users/ptorres/code/dotfiles
dotfiles - master $ git status -s -b
## master...origin/master [ahead 4]
M gitconfig
dotfiles - master $ nvim -u ~/.vimrc.min
Inside nvim:
:e ~/code/dotfiles/gitconfig
:Gina patch
]c
dor
:w
I got this:
And same result with vim -u ~/.vimrc.min
.
@lambdalisue just noticed something: the git apply
command reports it wants to apply /var/folders/.../2
, but the error message says that /var/folders/.../1
does not exist. Those numbers are different, and I get that off-by-one difference every single time here.
From the code, those filenames should really be the same, correct?
function! s:apply(git, content) abort
let tempfile = tempname()
try
if writefile(a:content, tempfile) == -1
return
endif
let result = gina#process#call_or_fail(a:git, [
\ 'apply',
\ '--verbose',
\ '--cached',
\ '--',
\ tempfile,
\])
call gina#core#emitter#emit('command:called:patch')
return result
finally
silent! call delete(tempfile)
endtry
endfunction
I commented out that finally
and saw that it is the file with the greater number that exists.
I tried setting $TMPDIR to /tmp and it didn't help; I still saw the same off-by-one difference though.
Nailed it. s:replace_filenames_in_diff
is not replacing anything. This screenshot shows the first line of the diff before and after running all those substitute
s in that function:
I'll see if I can fix it, but I wanted to document the root cause.
The problem was that I had this in my git config: diff.noprefix = true. That setting confuses even git itself: you can't do git diff > patch
and then git apply patch
with that on (you need to use git apply -p0 patch
). It's a popular issue, it seems.
No issues without that setting in git. I think this can be closed then.
I see. Thanks for the information 👍
After a couple of
dor
s anddol
s, I do:w
from the middle buffer, and see this message:What's the correct way to complete the patch operation?