如何打補丁

Diff patchvim

# mkdir -pv a/cide

# vim a/c/1spa

Wolaileit

# cp -r a bclass

# vim b/c/1file

Wolaileim

Wozoulemargin

# diff -Nur a btop

diff -Nur a/c/1 b/c/1註釋

--- a/c/12013-09-30 11:17:27.974856750 +0800

+++ b/c/12013-09-30 11:17:46.420855603 +0800

@@ -1 +1,2 @@

wolaile

+wozoule

參數N表示若是某個文件僅在一個目錄中出現,則假定其在另外一個目錄中爲空文件;u表示unified格式,r表示在目錄中嵌套使用。

# diff -Nur a b > /tmp/diff.patch

# patch -p0 < /tmp/diff.patch

patching file a/c/1 打補丁成功

# patch -p0 -R < /tmp/diff.patch 註釋:-R 表示退回一步

patching file a/c/1

# cd a

# patch -p1 < /tmp/diff.patch

patching file c/1

# patch -p1 -R < /tmp/diff.patch 再退回一步

patching file c/1

# cd c

# patch -p2 < /tmp/diff.patch

patching file 1

註釋:-p後邊的數字在不停的變化,補丁卻依舊能夠打成功,結論:數字與「<」後邊的目錄沒有關係,與當前所在的目錄有關,即pwd命令獲得的結果。這也要看diff.patch補丁文件是爲誰建立的,在誰之上打補丁就是-p0,更進一步,若是被打補丁的是一個目錄,進到目錄裏面,就是-p1,依次類推。

相關文章
相關標籤/搜索