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

Re: [PATCH] rebase [--onto O] A B: omit needless checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 16, 2008, 03:56 UTC
Message-ID
<7vmyozl3u4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080315222140.GE24845@ins.uni-bonn.de>
Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:
Show 14 quoted lines
> Hello Junio,
>
> * Junio C Hamano wrote on Sat, Mar 15, 2008 at 09:42:11PM CET:
>> This teaches "git rebase [--onto O] A B" to omit an unnecessary checkout
>> of branch B before it goes on.
>
>>  * Almost untested as I do not use this form very often.  Feedback would
>>    be good.
>
> Nice, and seems to do exactly what I meant.  Actually the more important
> speedup gained from this change is that files that have changed in the
> non-common history of A but not in that of B, preserve their old time
> stamps, so the rebuild of my bugfix topic B after having built master
> is really quick now.
Actually, you would need this on top.  Otherwise
	$ git rebase master my-topic~3
would misbehave.
---
 git-rebase.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 9273852..bd55ef6 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -320,7 +320,8 @@ case "$#" in
 	branch_name="$2"
 	switch_to="$2"
 
-	if branch=$(git rev-parse --verify "refs/heads/$2" 2>/dev/null)
+	if git show-ref --verify --quiet -- "refs/heads/$2" &&
+	   branch=$(git rev-parse --verify "refs/heads/$2" 2>/dev/null)
 	then
 		head_name="refs/heads/$2"
 	elif branch=$(git rev-parse --verify "$2" 2>/dev/null)
Previous: Ralf WildenhuesNext: Johannes Sixt
Message 6 of 10 in “optimized checkout+rebase?”
  1. Ralf WildenhuesMar 12, 2008
  2. Johannes SixtMar 13, 2008
  3. Ralf WildenhuesMar 15, 2008
  4. rebase [--onto O] A B: omit needless checkoutJunio C Hamano, Mar 15, 2008
  5. Ralf WildenhuesMar 15, 2008
  6. Junio C HamanoMar 16, 2008
  7. Johannes SixtMar 19, 2008
  8. Junio C HamanoMar 19, 2008
  9. Johannes SixtMar 20, 2008
  10. Junio C HamanoMar 20, 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.