Patch
The computer tool patch is a Unix program that updates text files according to instructions contained in a separate file, called a patch file. The patch file (also called a patch for short) is a text file that consists of a list of differences and is produced by running the related diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.
Options
-
-p[숫자]
- Parent 경로를 제거하여 적용한다. 만약
-p0
로 입력하면 Parent 경로가 하나도 지워지지 않고,-p1
를 입력하면 Parent 경로가 1개 제거된 후 적용된다.
Example
최상단 Parent 경로 1개를 제거한 후 패치를 적용한다.
Troubleshooting
patch와 관련된 문제점에 대하여 정리한다.
Hunk FAILED
아래와 같은 에러 메시지가 출력될 경우 공백과 관련된 문제가 발생될 경우 나타날 가능성이 크다.
$ patch -p0 < foo.diff
patching file user.php
Hunk #1 FAILED at 1140.
1 out of 1 hunk FAILED -- saving rejects to file user.php.rej
이 경우 아래와 같이 -l
옵션을 추가한다.