git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rebase --preserve-merges keeps empty merge commits
@ 2013-01-12 20:46 Phil Hord
  2013-01-14 14:02 ` Neil Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Phil Hord @ 2013-01-12 20:46 UTC (permalink / raw)
  To: git
  Cc: phil.hord, Neil Horman, Martin von Zweigbergk, Junio C Hamano,
	Phil Hord

Since 90e1818f9a  (git-rebase: add keep_empty flag, 2012-04-20)
'git rebase --preserve-merges' fails to preserve empty merge commits
unless --keep-empty is also specified.  Merge commits should be
preserved in order to preserve the structure of the rebased graph,
even if the merge commit does not introduce changes to the parent.

Teach rebase not to drop merge commits only because they are empty.

A special case which is not handled by this change is for a merge commit
whose parents are now the same commit because all the previous different
parents have been dropped as a result of this rebase or some previous
operation.
---
 git-rebase--interactive.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 44901d5..8ed7fcc 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -190,6 +190,11 @@ is_empty_commit() {
 	test "$tree" = "$ptree"
 }
 
+is_merge_commit()
+{
+	git rev-parse --verify --quiet "$1"^2 >/dev/null 2>&1
+}
+
 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
 # GIT_AUTHOR_DATE exported from the current environment.
 do_with_author () {
@@ -874,7 +879,7 @@ git rev-list $merges_option --pretty=oneline --abbrev-commit \
 while read -r shortsha1 rest
 do
 
-	if test -z "$keep_empty" && is_empty_commit $shortsha1
+	if test -z "$keep_empty" && is_empty_commit $shortsha1 && ! is_merge_commit $shortsha1
 	then
 		comment_out="# "
 	else
-- 
1.8.1.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-02-25  6:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-12 20:46 [PATCH] rebase --preserve-merges keeps empty merge commits Phil Hord
2013-01-14 14:02 ` Neil Horman
2013-01-14 14:12 ` Matthieu Moy
2013-01-14 17:15   ` Junio C Hamano
2013-01-14 17:50     ` Phil Hord
2013-02-01 19:15 ` Martin von Zweigbergk
2013-02-01 21:05   ` Phil Hord
2013-02-02  8:21     ` Martin von Zweigbergk
2013-02-25  6:44   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).