Merge branch 'ef/maint-rebase-error-message'
[gitweb.git] / git-rebase--am.sh
index c815a2412c2f33556ad712d328eaa80241c07bda..04d89415fe8ca1634fa362c66ea9569794dcadd5 100644 (file)
@@ -20,11 +20,20 @@ esac
 
 test -n "$rebase_root" && root_flag=--root
 
-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" &&
-move_to_original_branch
+if test -n "$keep_empty"
+then
+       # 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"
+else
+       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
+
 ret=$?
 test 0 != $ret -a -d "$state_dir" && write_basic_state
 exit $ret