Skip to content

Commit da2987d

Browse files
committed
Merge branch 'ph/rebase-preserve-all-merges' into maint
"git rebase --preserve-merges" lost empty merges in recent versions of Git. * ph/rebase-preserve-all-merges: rebase --preserve-merges: keep all merge commits including empty ones
2 parents 33b29fd + 9869778 commit da2987d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-rebase--interactive.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ is_empty_commit() {
190190
test "$tree" = "$ptree"
191191
}
192192

193+
is_merge_commit()
194+
{
195+
git rev-parse --verify --quiet "$1"^2 >/dev/null 2>&1
196+
}
197+
193198
# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
194199
# GIT_AUTHOR_DATE exported from the current environment.
195200
do_with_author () {
@@ -874,7 +879,7 @@ git rev-list $merges_option --pretty=oneline --abbrev-commit \
874879
while read -r shortsha1 rest
875880
do
876881

877-
if test -z "$keep_empty" && is_empty_commit $shortsha1
882+
if test -z "$keep_empty" && is_empty_commit $shortsha1 && ! is_merge_commit $shortsha1
878883
then
879884
comment_out="# "
880885
else

0 commit comments

Comments
 (0)