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

Re: [RFC] checkout --rebase

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jul 19, 2013, 11:33 UTC
Message-ID
<CALkWK0kVNw3Ko3+_Y-KDF=pdha6wxyMmQmLtOOr5tQYzgUr_Mw@mail.gmail.com>
In-Reply-To
<CALkWK0nM4fkCPNJo_c3Rpwh1azsGRdGvM3S80vcuRiRXDT0vOQ@mail.gmail.com>
Ramkumar Ramachandra wrote:
Show 6 quoted lines
> Sebastian Staudt wrote:
>> Isn't this what you want?
>>
>>  $ git rebase master um-build
>
> Ha, yes.  Sorry about the stupidity.

Hm, I'm not entirely sure how to optimize the codepath to eliminate the checkout. It seems to be absolutely necessary atleast in the -i codepath.

Let's inspect when $switch_to is set:
	# Is it "rebase other $branchname" or "rebase other $commit"?
	branch_name="$1"
	switch_to="$1"

$revisions seems to be set correctly, and rebase--am does a move_to_original_branch as the last step. So, I wonder if this will work:

diff --git a/git-rebase.sh b/git-rebase.sh
index 0039ecf..7405d9a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -542,9 +542,15 @@ then
 	if test -z "$force_rebase"
 	then
 		# Lazily switch to the target branch if needed...
-		test -z "$switch_to" ||
-		GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
-			git checkout "$switch_to" --
+		if ! test -z "$switch_to"; then
+			if "$type" = am; then
+				GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout -b $switch_to-2" \
+					git checkout -b "$switch_to-2" --
+			else
+				GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
+					git checkout "$switch_to" --
+			fi
+		fi
 		say "$(eval_gettext "Current branch \$branch_name is up to date.")"
 		finish_rebase
 		exit 0

(ofcourse, we still need a mechanism to remove this temporary
$switch_to-2 branch)

What about rebase--merge?  Can we eliminate the checkout then?
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 4 of 6 in “[RFC] checkout --rebase”
  1. Ramkumar RamachandraJul 19, 2013
  2. Sebastian StaudtJul 19, 2013
  3. Ramkumar RamachandraJul 19, 2013
  4. Ramkumar RamachandraJul 19, 2013
  5. Ramkumar RamachandraJul 19, 2013
  6. Ramkumar RamachandraJul 19, 2013

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.