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>
This commit is contained in:
Neil Horman
2012-04-20 10:36:17 -04:00
committed by Junio C Hamano
parent bedfe86ce6
commit 90e1818f9a
4 changed files with 55 additions and 8 deletions

View File

@ -43,6 +43,7 @@ s,strategy=! use the given merge strategy
no-ff! cherry-pick all commits, even if unchanged
m,merge! use merging strategies to rebase
i,interactive! let the user edit the list of commits to rebase
k,keep-empty preserve empty commits during rebase
f,force-rebase! force rebase even if branch is up to date
X,strategy-option=! pass the argument through to the merge strategy
stat! display a diffstat of what changed upstream
@ -97,6 +98,7 @@ state_dir=
action=
preserve_merges=
autosquash=
keep_empty=
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
read_basic_state () {
@ -220,6 +222,9 @@ do
-i)
interactive_rebase=explicit
;;
-k)
keep_empty=yes
;;
-p)
preserve_merges=t
test -z "$interactive_rebase" && interactive_rebase=implied