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

[PATCH] rebase -i: fix for optional [branch] parameter

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 1, 2007, 22:31 UTC
Message-ID
<Pine.LNX.4.64.0708012329560.14781@racer.site>
In-Reply-To
<20070801214556.GA2911@steel.home>

When calling "git rebase -i <upstream> <branch>", git should switch to <branch> first. This worked before, but I broke it by my "Shut git rebase -i up" patch.

Fix that, and add a test to make sure that it does not break again.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Wed, 1 Aug 2007, Alex Riesen wrote:
	> Johannes Schindelin, Wed, Aug 01, 2007 17:57:25 +0200:
	> > On Fri, 13 Jul 2007, Alex Riesen wrote:
	> >
	> > > Could we also have "git rebase <base> <branch>"?
	> > 
	> > Don't we do that already?  AFAICT it is already in the 
	> > synopsis, ever since rebase -i was introduced into the "next" 
	> > branch, on June 25...
	> > 
	> 
	> Err... "git rebase -i <base> <branch>"
	> 
	> Does not work, just checked:
	> 
	>     $ git rebase -i base branch
	>     /usr/local/bin/git-rebase--interactive: 482: cannot create /home/user/projects/tmp/.git/.dotest-merge/output: Directory nonexistent
	>     cat: /home/user/projects/tmp/.git/.dotest-merge/output: No such file or directory
	>     Invalid branchname: branch
	Sorry...
 git-rebase--interactive.sh    |    2 +-
 t/t3404-rebase-interactive.sh |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d3addd4..bdec462 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -405,6 +405,7 @@ do
 
 		require_clean_work_tree
 
+		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 		if test ! -z "$2"
 		then
 			output git show-ref --verify --quiet "refs/heads/$2" ||
@@ -418,7 +419,6 @@ do
 
 		test -z "$ONTO" && ONTO=$UPSTREAM
 
-		mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 		: > "$DOTEST"/interactive || die "Could not mark as interactive"
 		git symbolic-ref HEAD > "$DOTEST"/head-name ||
 			die "Could not get HEAD"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index dc436d7..a9b552f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -98,6 +98,14 @@ test_expect_success 'no changes are a nop' '
 	test $(git rev-parse I) = $(git rev-parse HEAD)
 '
 
+test_expect_success 'test the [branch] option' '
+	git checkout -b dead-end &&
+	git rm file6 &&
+	git commit -m "stop here" &&
+	git rebase -i F branch2 &&
+	test $(git rev-parse I) = $(git rev-parse HEAD)
+'
+
 test_expect_success 'rebase on top of a non-conflicting commit' '
 	git checkout branch1 &&
 	git tag original-branch1 &&
-- 
1.5.3.rc3.112.gf60b6
Previous: Alex RiesenNext: Alex Riesen
Message 6 of 9 in “rebase -i: handle --continue more like non-interactive rebase”
  1. 1/3 rebase -i: handle --continue more like non-interactive rebaseJohannes Schindelin, Jul 8, 2007
  2. Johannes SchindelinJul 8, 2007
  3. Alex RiesenJul 12, 2007
  4. Johannes SchindelinAug 1, 2007
  5. Alex RiesenAug 1, 2007
  6. rebase -i: fix for optional [branch] parameterJohannes Schindelin, Aug 1, 2007
  7. Fix rebase interactive to allow specifying branch to rebase along with the baseAlex Riesen, Aug 1, 2007
  8. Johannes SchindelinAug 1, 2007
  9. Alex RiesenAug 1, 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.