summaryrefslogtreecommitdiff
path: root/git-rebase--am.sh
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2012-04-20 10:36:17 -0400
committerJunio C Hamano <gitster@pobox.com>2012-04-24 15:24:14 -0700
commit90e1818f9a06015159712e204dd90868e0a6c421 (patch)
tree7f67e462df570c25739263c3f181fff63c129133 /git-rebase--am.sh
parentbedfe86ce6ccee90e2cbecbf8d72e06219a2768a (diff)
downloadgit-90e1818f9a06015159712e204dd90868e0a6c421.tar.gz
git-rebase: add keep_empty flag
Add a command line switch to git-rebase to allow a user the ability to specify that they want to keep any commits in a series that are empty. When git-rebase's type is am, then this option will automatically keep any commit that has a tree object identical to its parent. This patch changes the default behavior of interactive rebases as well. With this patch, git-rebase -i will produce a revision set passed to git-revision-editor, in which empty commits are commented out. Empty commits may be kept manually by uncommenting them. If the new --keep-empty option is used in an interactive rebase the empty commits will automatically all be uncommented in the editor. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--am.sh')
-rw-r--r--git-rebase--am.sh19
1 files changed, 14 insertions, 5 deletions
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index c815a2412c..04d89415fe 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -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