使用git给项目打patch

升级了ff51让vimperator不能用了,顿时感觉生活不能自理,按着issue给的方法给vimperator打patch重新make一下。

使用git支持两种patch,对应着不同的打patch方法。

通过git diff生成的patch

生成patch

$git diff master > patch

patch格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/common/content/tabs.js b/common/content/tabs.js
index 8410e32..89f8fea 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -52,7 +52,7 @@ const Tabs = Module("tabs", {
* @property {Iterator(Object)} A genenerator that returns all browsers
* in the current window.
*/
- get browsers() {
+ browsers: function*() {
let browsers = config.tabbrowser.browsers;
for (let i = 0; i < browsers.length; i++)
yield [i, browsers[i]];
@@ -66,7 +66,7 @@ const Tabs = Module("tabs", {
/**
* @property {Object} The local options store for the current tab.
*/
- get options() {
+ options: function*() {
let store = this.localStore;
if (!("options" in store))
store.options = {};

使用patch

$git apply patch

Note: 一般打patch前都是先再建一个branch,不会直接在master上应用patch。

通过git format-patch生成的git专用补丁

生成patch

git format-patch -M master
当前分支所有超前master的提交

patch格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
From 273a41fe2b8af9e4033d4d84202162277daeddff Mon Sep 17 00:00:00 2001
From: Thomas Lee <thomaslee@cecid.org>
Date: Wed, 14 Dec 2016 18:02:15 +0800
Subject: [PATCH 09/23] revised up to AS2 Web Service Usage Sample
---
docs/source/installation.rst | 417 +++++++++++++++++++++----------------------
1 file changed, 200 insertions(+), 217 deletions(-)
diff --git a/docs/source/installation.rst b/docs/source/installation.rst
index 131f662..ab4182b 100644
--- a/docs/source/installation.rst
+++ b/docs/source/installation.rst
@@ -5,29 +5,23 @@ Hermes 2 Installation Guide
© CECID
-Produced by the Center for E-Commerce Infrastructure Development The University of Hong Kong
+Produced by the Center for E-Commerce Infrastructure Development The University of Hong Kong.

比单纯的git diff内容多,有提交者信息各种

使用patch

git am 0009-revised-up-to-AS2-Web-Service-Usage-Sample.patch