Anonymous committed 69e66f5

rebase --interactive: Compute upstream SHA1 before switching branches

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 <>
Acked-by: Johannes Schindelin <>
Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (1)

+		UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
+		test -z "$ONTO" && ONTO=$UPSTREAM
 		if test ! -z "$2"
 			output git show-ref --verify --quiet "refs/heads/$2" ||
 		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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.