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

[PATCH] rebase --interactive: Compute upstream SHA1 before switching branches

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jun 2, 2008, 14:01 UTC
Message-ID
<4843FD44.90905@viscovery.net>
From: Johannes Sixt <johannes.sixt@telecom.at>

If the upstream argument to rebase (the first argument) was relative to HEAD and the name of the branch to rebase (the second argument) was given, the upstream would have been interpreted relative to the second argument. In particular, this command

    git rebase -i HEAD topic

would always finish with "Nothing to do". (a1bf91e fixed the same issue for non-interactive rebase.)

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
I made this with -U5 so that you can see the checkout in the context.

BTW, methinks, this checkout is unnecessary, since before the rebase begins, there is a 'git checkout $ONTO', and the branch switching is certainly not needed to compute the todo list...

-- Hannes
 git-rebase--interactive.sh |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 8ee08ff..0ca986f 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -473,25 +473,24 @@ do
 			;;
 		esac

 		require_clean_work_tree

+		UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
+		test -z "$ONTO" && ONTO=$UPSTREAM
+
 		if test ! -z "$2"
 		then
 			output git show-ref --verify --quiet "refs/heads/$2" ||
 				die "Invalid branchname: $2"
 			output git checkout "$2" ||
 				die "Could not checkout $2"
 		fi

 		HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
-		UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
-
 		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"

-		test -z "$ONTO" && ONTO=$UPSTREAM
-
 		: > "$DOTEST"/interactive || die "Could not mark as interactive"
 		git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
 			echo "detached HEAD" > "$DOTEST"/head-name

 		echo $HEAD > "$DOTEST"/head
-- 
1.5.6.rc0.885.gdf17.dirty
Next: Johannes Schindelin
Message 1 of 4 in “rebase --interactive: Compute upstream SHA1 before switching branches”
  1. rebase --interactive: Compute upstream SHA1 before switching branchesJohannes Sixt, Jun 2, 2008
  2. Johannes SchindelinJun 2, 2008
  3. Junio C HamanoJun 3, 2008
  4. Johannes SchindelinJun 3, 2008

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.