diff --git a/content/developer/packaging/package-styling-manual.md b/content/developer/packaging/package-styling-manual.md index 574952f..4c99d50 100644 --- a/content/developer/packaging/package-styling-manual.md +++ b/content/developer/packaging/package-styling-manual.md @@ -212,17 +212,19 @@ Patches should follow a uniform and ordered format, before they are included in When dealing with Git-based sources, it is possible to create numbered patches from the following command: ``` -git format-patch -n $HASH +git format-patch --full-index -n $HASH ``` Where `n` defines the amount of commits from the specific commit `$HASH`, including the specified commit. Alternatively, you can omit the `$HASH`... ``` -git format-patch -n +git format-patch --full-index -n ``` To create a series of patches from `n` commits to the branch `HEAD`. +The `--full-index` flag in the commands above instructs Git to record the full hashes of the modified object in the generated patches. These can aid Git in three-way merging and rebasing. + These commands generate a series patches like the following... ``` @@ -233,6 +235,14 @@ These commands generate a series patches like the following... 0005-autobuild-aoscarchive-adapt-to-new-workflow.patch ``` +If the situation allows, `--base=` can be used to instruct Git to record the base commit of the patch series as well. For example: + +``` +git format-patch --full-index --base=$BASE_COMMIT $BASE_COMMIT +``` + +This command generates a patch series from `$BASE_COMMIT` (excl.) to the current HEAD (incl.), and append a `base-commit:` marker to the first patch in the series. + ## Other Sources Without an automatic mean to generate patches, patches should be named in the following format. diff --git a/content/developer/packaging/package-styling-manual.zh.md b/content/developer/packaging/package-styling-manual.zh.md index ab810a2..3de77a4 100644 --- a/content/developer/packaging/package-styling-manual.zh.md +++ b/content/developer/packaging/package-styling-manual.zh.md @@ -210,17 +210,19 @@ SUBDIR=. 对于基于 Git 的源码仓库,可以通过以下命令创建带有编号的补丁: ``` -git format-patch -n $HASH +git format-patch --full-index -n $HASH ``` `n` 定义了自 `$HASH` 这个提交前选取多少个提交(含)。您还可以省略 `$HASH`: ``` -git format-patch -n +git format-patch --full-index -n ``` 以从 `HEAD` 往前选取 `n` 个提交(含)制作补丁。 +上述命令中的 `--full-index` 要求 Git 在创建补丁文件时,记录被修改对象的完整哈希值。该信息可在三路合并和变基操作中为 Git 提供帮助。 + 生成的补丁的名字大致是这样子的: ``` @@ -231,6 +233,14 @@ git format-patch -n 0005-autobuild-aoscarchive-adapt-to-new-workflow.patch ``` +若条件允许,可以使用 `--base=` 参数要求 Git 记录补丁的基提交,如: + +``` +git format-patch --full-index --base=$BASE_COMMIT $BASE_COMMIT +``` + +该命令会生成以 `$BASE_COMMIT`(不含)为基、到当前 HEAD(含)为止的补丁集文件,并在第一个补丁尾部添加 `base-commit:` 标记。 + ## 其它情形 如果上面自动生成补丁的方式不适用,那么应以下面的格式为您的补丁命名: