git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Alex Riesen <raa.lkml@gmail.com>
Date
Jul 12, 2007, 22:30 UTC
Message-ID
<20070712223035.GB30532@steel.home>

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

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Noticed when trying to blend the second commit in a branch into the first. Squash didn't work at all (apart from commit message duplication).

 git-rebase--interactive.sh |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d9563ec..f395076 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -84,6 +84,7 @@ pick_one () {
 	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
 	else
@@ -193,14 +194,14 @@ do_next () {
 			die "Cannot 'squash' without a previous commit"
 
 		mark_action_done
-		failed=f
-		pick_one -n $sha1 || failed=t
 		MSG="$DOTEST"/message
 		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"
-- 
1.5.3.rc0.116.gc35c1-dirty
Next: Junio C Hamano
Message 1 of 4 in “Fix git-rebase -i to allow squashing of fast-forwardable commits”
  1. Fix git-rebase -i to allow squashing of fast-forwardable commitsAlex Riesen, Jul 12, 2007
  2. Junio C HamanoJul 14, 2007
  3. Andy ParkinsJul 14, 2007
  4. Johannes SchindelinJul 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.