git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches
@ 2008-06-02 14:01 Johannes Sixt
  2008-06-02 15:29 ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2008-06-02 14:01 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches
  2008-06-02 14:01 [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches Johannes Sixt
@ 2008-06-02 15:29 ` Johannes Schindelin
  2008-06-03  2:28   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2008-06-02 15:29 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List, Junio C Hamano

Hi,

On Mon, 2 Jun 2008, Johannes Sixt wrote:

> 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>

Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>

> 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...

It is needed to determine which branch to update after finish.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches
  2008-06-02 15:29 ` Johannes Schindelin
@ 2008-06-03  2:28   ` Junio C Hamano
  2008-06-03 13:55     ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2008-06-03  2:28 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Johannes Sixt, Git Mailing List

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> 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...
>
> It is needed to determine which branch to update after finish.

I'll apply Hannes's patch for now as I do not want to leave an obvious fix
out of -rc1.

I think Hannes is referring to the same issue as the one dealt with with
0cb0664 (rebase [--onto O] A B: omit needless checkout, 2008-03-15) for
the non-interactive codepath.

You certainly "need to determine which branch to update after finish", and
you do need to remember what branch you were on (if you were not called
with the <branch> parameter), or what branch were given from the command
line (if you got one as <branch> parameter) in order to do so, but the way
to remember these values does not have to involve an extra checkout.

By doing an extra checkout of "the original HEAD", before switching to a
detached HEAD state at the $ONTO commit to "clean the slate" to apply the
sequence on top, more work tree entries will be smudged, forcinging more
recompilations than necessary if the tracked contents are "source" files.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches
  2008-06-03  2:28   ` Junio C Hamano
@ 2008-06-03 13:55     ` Johannes Schindelin
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2008-06-03 13:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Git Mailing List

Hi,

On Mon, 2 Jun 2008, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> 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...
> >
> > It is needed to determine which branch to update after finish.
> 
> I'll apply Hannes's patch for now as I do not want to leave an obvious fix
> out of -rc1.
> 
> I think Hannes is referring to the same issue as the one dealt with with
> 0cb0664 (rebase [--onto O] A B: omit needless checkout, 2008-03-15) for
> the non-interactive codepath.
> 
> You certainly "need to determine which branch to update after finish", 
> and you do need to remember what branch you were on (if you were not 
> called with the <branch> parameter), or what branch were given from the 
> command line (if you got one as <branch> parameter) in order to do so, 
> but the way to remember these values does not have to involve an extra 
> checkout.
> 
> By doing an extra checkout of "the original HEAD", before switching to a 
> detached HEAD state at the $ONTO commit to "clean the slate" to apply 
> the sequence on top, more work tree entries will be smudged, forcinging 
> more recompilations than necessary if the tracked contents are "source" 
> files.

Right.  I failed to follow the given hint to the other commit, but it 
makes perfect sense now.

Thanks,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-03 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-02 14:01 [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches Johannes Sixt
2008-06-02 15:29 ` Johannes Schindelin
2008-06-03  2:28   ` Junio C Hamano
2008-06-03 13:55     ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).