project patch

diff 和patch是在opensource project常常用到的工具,這裡介紹一下流程和用法

* 建立project

myproject
-> config -> address.inc
-> main.c

* 修改project

> cp -rfv myproject myproject.orig
> cd myproject (開始進行修改)

* 建立差異檔 use diff

> cd .. (離開myproject目錄,此時可看到myproject 與myproject.orig兩目錄同時存在)

此時分辨一下 myproject 是修改完,所以是新的,而myproject.orig則是舊的

> diff -urN myproject.orig myproject > myproject.patch (注意,是從舊到新,不能寫反)
> cat myproject.patch 看一下內容
diff -urN myproject.orig/doc/README myproject/doc/README
--- myproject.orig/doc/README 1970-01-01 08:00:00.000000000 +0800
+++ myproject/doc/README 2011-11-03 18:19:15.000000000 +0800
@@ -0,0 +1 @@
+this is a diff,patch test
diff -urN myproject.orig/main.c myproject/main.c
--- myproject.orig/main.c 2011-11-03 18:18:25.000000000 +0800
+++ myproject/main.c 2011-11-03 18:18:41.000000000 +0800
@@ -1,6 +1,8 @@
#include
+#include

int main()
{
puts("hello world");
+ return 0;
}


* 將myproject.patch分享給別人讓別人套用更新

當其實使用者拿到此patch檔的時候,他將要為他的myproject打上更新,因此在目錄下會存在
home
-> myproject/
-> myproject.patch

與我們建新patch時相同的目錄結構

* 打上myproject.patch更新

> patch -p0 < myproject.patch

* 注意

經過以上流程就已可以打上更新了,但是常常有人會失敗,可能的原因有目錄 錯誤或是-p?路徑不正確,建議使用者可以看一下myproject.patch檔案內容

+++ myproject/doc/README 2011-11-03 18:19:15.000000000 +0800

我們要將舊的myproject更新成新的,因此若要使用-p0的話那myproject.patch目錄下也要存在有一個叫myproject目錄,如此可以正確的打上patch

send-pr log

send-pr -a epdfview.patch

To: FreeBSD-gnats-submit@freebsd.org
From: Anati Chang
Reply-To: Anati Chang
Cc:
X-send-pr-version: 3.113
X-GNATS-Notify:


>Submitter-Id: current-users
>Originator: User &
>Organization:
>Confidential: no
>Synopsis: [PATCH] graphics/epdfview: fix wrong color
>Severity: non-critical
>Priority: low
>Category: ports
>Class: update
>Release: FreeBSD 8.2-STABLE i386
>Environment:
System: FreeBSD cse.tw 8.2-STABLE FreeBSD 8.2-STABLE #6: Wed Oct 5 11:51:25 CST 2011 gaod@cse.tw:/usr/obj/usr/src/sys/GENERIC i386



>Description:
PDF document will get wrong color, when poppler-glib update to 0.18.0.
apply this thread http://trac.emma-soft.com/epdfview/changeset/367
>How-To-Repeat:
apply this patch
>Fix: