git-diff로 생성된 패치 파일을 적용합니다.

git-diff로 생성된 패치 파일을 적용합니다.

패치 파일을 생성하기 위해 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

패치를 적절한 디렉토리에 적용하십시오.

관련 정보