我做了一个git-diff来生成一个补丁文件:
cd
git diff --no-prefix ~/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim ~/compiler.vim > ~/vimlatex.patch得到的修补程序是
diff --git home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim home/rudra/compiler.vim
index 65cd33a..abfcff7 100644
--- home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim
+++ home/rudra/compiler.vim
@@ -434,7 +434,8 @@ function! Tex_ForwardSearchLaTeX()
else
" We must be using a generic UNIX viewer
" syntax is: viewer TARGET_FILE LINE_NUMBER SOURCE_FILE
-
+ let mainfnameRelative = fnameescape(fnamemodify(Tex_GetMainFileName(), ':p:.:r'))
+ let target_file = mainfnameRelative . "." . s:target
let execString .= join([viewer, target_file, linenr, sourcefile])
endif我想把这个补丁应用到/home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim上
但是当我试图应用这个补丁时,它给了我:
patch -p0 < vimlatex.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim home/rudra/compiler.vim
|index 65cd33a..abfcff7 100644
|--- home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim
|+++ home/rudra/compiler.vim
--------------------------
File to patch: /home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim
patching file /home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim问题是,虽然它运行得很好,但我希望它能够理解它应该修补哪个文件,而不要求我对file进行修补:
我怎么能做到这一点?
发布于 2017-04-28 08:02:02
默认情况下,patch从目标文件中剥离路径,因此您可以使用
patch < vimlatex.patch(假设当前目录中有一个compiler.vim文件)。
指定-p0会指示它使用所有目标路径,因此它希望从当前目录中找到一个名为home/rudra/compiler.vim的文件。对此的解释是,用于创建修补程序的命令是在运行diff之前转换的;真正用于创建修补程序的命令被记录为修补程序的第一行(基本上,~变为/home/rudra,并且删除了领先的/ ):
diff --git home/rudra/.vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim home/rudra/compiler.vim因此,patch -p0默认期望找到一个与home/rudra/compiler.vim (目标文件)匹配的文件,如上文所述。
我不认为有一种可靠的方法来生成您想要的补丁,因为patch显式地忽略了绝对路径。我建议只使用带有相对路径的普通diff:
cd
diff -u .vim/bundle/vim-latex-suite/ftplugin/latex-suite/compiler.vim compiler.vim > vimlatex.patch并在适当的目录中应用修补程序。
https://unix.stackexchange.com/questions/361797
复制相似问题