Anonymous committed 793ad04

Fix git-rebase -i to allow squashing of fast-forwardable commits

Without this change the commits will be left standalone, with
duplicated commit message.

Signed-off-by: Alex Riesen <>
Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits 9a4cbdc

Comments (0)

Files changed (1)

 	current_sha1=$(git rev-parse --verify HEAD)
 	if [ $current_sha1 = $parent_sha1 ]; then
 		git reset --hard $sha1
+		test "a$1" = a-n && git reset --soft $current_sha1
 		sha1=$(git rev-parse --short $sha1)
 		warn Fast forward to $sha1
 			die "Cannot 'squash' without a previous commit"
-		failed=f
-		pick_one -n $sha1 || failed=t
 		echo "# This is a combination of two commits." > "$MSG"
 		echo "# The first commit's message is:" >> "$MSG"
 		echo >> "$MSG"
 		git cat-file commit HEAD | sed -e '1,/^$/d' >> "$MSG"
 		echo >> "$MSG"
+		failed=f
+		pick_one -n $sha1 || failed=t
 		echo "# And this is the 2nd commit message:" >> "$MSG"
 		echo >> "$MSG"
 		git cat-file commit $sha1 | sed -e '1,/^$/d' >> "$MSG"