
패치 파일을 생성하기 위해 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
문제는 잘 작동하는 동안 나에게 묻지 않고 어떤 파일을 패치해야 하는지 이해하고 싶다는 것입니다.패치할 파일:
어떻게 이를 달성할 수 있나요?
답변1
기본적으로 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
적절한 디렉토리에 패치를 적용합니다.