Since 0fbb95d (am: don't call mailinfo if $rebasing, 2012-06-26), the
patch body to apply when running 'git am --rebasing' is not taken from
the mbox, but directly from the commit. If such a commit is "empty",
'git am --rebasing' still happily applies it and commits. However,
since the input to 'git am --rebasing' only ever comes from 'git
format-patch', which completely leaves the commit out from its output
if it's empty, no empty commits are ever created by 'git am
--rebasing'. By teaching 'git am --rebasing' a --keep-empty option and
letting the caller decide whether or not to keep empty commits, we can
unify the two different mechanisms that uses for
---         | 10 +++++++++- | 20 ++++++--------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ b/
index b6a5300..37641b7 100755
--- a/
+++ b/
@@ -37,7 +37,8 @@ abort           restore the original branch and abort the 
patching operation.
 committer-date-is-author-date    lie about committer date
 ignore-date     use current timestamp for author date
 rerere-autoupdate update the index with reused conflict resolution if possible
-rebasing*       (internal use for git-rebase)"
+rebasing*       (internal use for git-rebase)
+keep-empty*     (internal use for git-rebase)"
 . git-sh-setup
 . git-sh-i18n
@@ -375,6 +376,7 @@ git_apply_opt=
 if test "$(git config --bool --get am.keepcr)" = true
@@ -414,6 +416,8 @@ do
                abort=t ;;
                rebasing=t threeway=t ;;
+       --keep-empty)
+               keep_empty=t ;;
                die "$(gettext "-d option is no longer supported.  Do not 
@@ -669,6 +673,10 @@ do
                        echo "$commit" >"$dotest/original-commit"
                        get_author_ident_from_commit "$commit" 
                        git diff-tree --root --binary "$commit" >"$dotest/patch"
+                       test -s "$dotest/patch" || test -n "$keep_empty" || {
+                               go_next
+                               continue
+                       }
                        git mailinfo $keep $no_inbody_headers $scissors $utf8 
"$dotest/msg" "$dotest/patch" \
                                <"$dotest/$msgnum" >"$dotest/info" ||
diff --git a/ b/
index 392ebc9..37c1b23 100644
--- a/
+++ b/
@@ -17,20 +17,12 @@ skip)
 test -n "$rebase_root" && root_flag=--root
-if test -n "$keep_empty"
-       # we have to do this the hard way.  git format-patch completely squashes
-       # empty commits and even if it didn't the format doesn't really lend
-       # itself well to recording empty patches.  fortunately, cherry-pick
-       # makes this easy
-       git cherry-pick --allow-empty "$revisions"
-       git format-patch -k --stdout --full-index --ignore-if-in-upstream \
-               --src-prefix=a/ --dst-prefix=b/ \
-               --no-renames $root_flag "$revisions" |
-       git am $git_am_opt --rebasing --resolvemsg="$resolvemsg"
-fi && move_to_original_branch
+test -n "$keep_empty" && git_am_opt="$git_am_opt --keep-empty"
+git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+       --src-prefix=a/ --dst-prefix=b/ \
+       --no-renames $root_flag "$revisions" |
+git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
 test 0 != $ret -a -d "$state_dir" && write_basic_state

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to