2

この問題に関する git ドキュメントに関する説明が見つかりませんでした:

ダミーの差分を使用してダミーのコミットを作成すると、実行時に通常のパッチが取得されます

git format-patch -1 -o outgoing/ -p -k

ただし、最後のコミットが空のコミットである場合、によって生成されます

git commit --allow-empty "Some commit message"

その場合、フォーマット パッチの出力は空のパッチになります。最初のケースが次のようなものを生成する場合:

From 08cfdb2994554d834b89309ca96d9bf513e26a90 Mon Sep 17 00:00:00 2001
From: User <mail@example.com>
Date: Fri, 8 Jan 2016 12:44:57 +0000
Subject: dummy commit


diff --git a/lol.txt b/lol.txt
new file mode 100644
index 0000000..f944b38
--- /dev/null
+++ b/lol.txt
@@ -0,0 +1 @@
+:)
--
2.5.4 (Apple Git-61)

2番目のケースでは、代わりにこのようなものを生成すべきではありませんか?

From 2d486f25c48780e2e132047e681929fcccb7e60c Mon Sep 17 00:00:00 2001
From: User <mail@example.com>
Date: Fri Jan 8 12:43:55 2016 +0000
Subject: Some commit message


2.5.4 (Apple Git-61)
4

2 に答える 2

3

更新 2022: Git 2.35 (2022 年第 1 四半期) では、" git am" ( man )は学習--empty=(stop|drop|keep)"し、--allow-emptyオプションを使用して、パッチが含まれていない電子メールに対して行われたことを微調整します。

「カバーレターが含まれている場合、メールボックスパッチを使用した git-am が失敗する」を参照してください。


2016: 元の回答:

注: 空のコミットが最後ではない場合、それは機能します (「空のコミットの Git パッチ」で述べたように)。

2010 年に、このスレッドで空のコミット パッチについて議論がありました。

半分良いニュースは、空のコミットからメッセージを生成するコマンド ライン オプションがformat-patch既に使用されていることです--alwaysが、" " で適用できないため、amかなり無意味です。

(--alwaysは に渡さgit diff-treeます)

いくつかのテストを行う必要がありますが、デフォルトでは、空のコミットは実際には含まれていません。

于 2016-01-09T10:40:16.173 に答える
1

gitメーリングリストから抽出:

ジェフ・キングは次のように述べています。

I'm not sure if this is a bug or not.

In the beginning, git's revision-traversal machinery generally does not show 
commits which have no diff. Over the years, commands like "git log"
learned to set the "always_show_header" option to show even empty commits. 
But format-patch never did.

そして、Junio C Hamano は次のように付け加えました。

The patch based workflow support is geared towards helping the recipient 
of the patches a lot more than the contributors, and to prevent mistakes while 
applying the patches, "am" would stop when it sees such an empty e-mail as you saw 
(in the later part of message I am not quoting). After all, a "format-patch" output 
that does not have any patch would be indistinguishable from discussion e-mail 
messages and the recipient would not want to end up with no-op commits 
that record such messages.

So I think skipping no-op commit from the output was done pretty much deliberately 
and it is definitely not a bug.  I however do not think it is incorrect 
to say that it is a lack of feature that nobody 
so far found necessary or beneficial.

I would not refuse to consider adding a new option to "format-patch" 
to emit such a no-op message, and add a "having no patch is OK, just record a 
no-op commit" option to "am", though.  But I do not see a clear benefit from 
such change--it sounds more like a set of"because we could" not 
"because we need to" changes to me.

スレッドはhttp://git.661346.n2.nabble.com/git-format-patch-on-empty-commit-td7645342.html で入手できます

于 2016-01-12T00:33:54.457 に答える