From: Junio C Hamano <gitster@pobox.com>
Date: Sun, 30 Dec 2007 20:37:59 +0000 (-0800)
Subject: git-rebase -i behaves better on commits with incomplete messages
X-Git-Tag: v1.5.4-rc3~69
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ad1065e580c03035c583e2d237cc5b76f90cee4;p=git

git-rebase -i behaves better on commits with incomplete messages

The commit message template when squashing multiple commits is
prepared by concatenating the messages of existing commits
together.  If the messages from some of them end with incomplete
lines, this would result in a suboptimal message template.  Make
sure that we add a terminating LF after each commit message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 090c3e5143..d0d83c35e6 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -215,15 +215,17 @@ make_squash_message () {
 		COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
 			< "$SQUASH_MSG" | tail -n 1)+1))
 		echo "# This is a combination of $COUNT commits."
-		sed -n "2,\$p" < "$SQUASH_MSG"
+		sed -e 1d -e '2,/^./{
+			/^$/d
+		}' <"$SQUASH_MSG"
 	else
 		COUNT=2
 		echo "# This is a combination of two commits."
 		echo "# The first commit's message is:"
 		echo
 		git cat-file commit HEAD | sed -e '1,/^$/d'
-		echo
 	fi
+	echo
 	echo "# This is the $(nth_string $COUNT) commit message:"
 	echo
 	git cat-file commit $1 | sed -e '1,/^$/d'