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

[PATCH] Fix submodule squashing into unrelated commit

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 27, 2009, 11:42 UTC
Message-ID
<alpine.DEB.1.00.0901271241010.14855@racer>
In-Reply-To
<7vljsxyv58.fsf@gitster.siamese.dyndns.org>

Actually, I think the issue is pretty independent of submodules; when "git commit" gets an empty parameter, it misinterprets it as a file.

So avoid passing an empty parameter to "git commit".

Actually, this is a nice cleanup, as MSG_FILE and EDIT_COMMIT were mutually exclusive; use one variable instead

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	We might want to safeguard "git commit", too.
 git-rebase--interactive.sh    |    9 ++++-----
 t/t3404-rebase-interactive.sh |    2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 002929e..3ac7162 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -373,17 +373,15 @@ do_next () {
 		pick_one -n $sha1 || failed=t
 		case "$(peek_next_command)" in
 		squash|s)
-			EDIT_COMMIT=
 			USE_OUTPUT=output
 			MSG_OPT=-F
-			MSG_FILE="$MSG"
+			EDIT_OR_FILE="$MSG"
 			cp "$MSG" "$SQUASH_MSG"
 			;;
 		*)
-			EDIT_COMMIT=-e
 			USE_OUTPUT=
 			MSG_OPT=
-			MSG_FILE=
+			EDIT_OR_FILE=-e
 			rm -f "$SQUASH_MSG" || exit
 			cp "$MSG" "$GIT_DIR"/SQUASH_MSG
 			rm -f "$GIT_DIR"/MERGE_MSG || exit
@@ -397,7 +395,8 @@ do_next () {
 			GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
 			GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
 			GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
-			$USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t
+			$USE_OUTPUT git commit --no-verify \
+				$MSG_OPT "$EDIT_OR_FILE" || failed=t
 		fi
 		if test $failed = t
 		then
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 6ffb9ad..4becc55 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -484,7 +484,7 @@ test_expect_success 'submodule rebase setup' '
 	git commit -a -m "Three changes submodule"
 '
 
-test_expect_failure 'submodule rebase -i' '
+test_expect_success 'submodule rebase -i' '
 	FAKE_LINES="1 squash 2 3" git rebase -i A
 '
 
-- 
1.6.1.482.g7d54be
Previous: Junio C Hamano
Message 3 of 3 in “[Bug] rebase -i squashes submodule changes into unrelated commit”
  1. Junio C HamanoJan 27, 2009
  2. Junio C HamanoJan 27, 2009
  3. Fix submodule squashing into unrelated commitJohannes Schindelin, Jan 27, 2009

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.