{"thread":{"id":"13764","subject":"[PATCH] rebase --interactive: Compute upstream SHA1 before switching branches","startedAt":"2008-06-02T14:01:40Z","lastAt":"2008-06-03T13:55:22Z","messageCount":4,"participants":["Johannes Sixt","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78364","messageId":"4843FD44.90905@viscovery.net","threadId":"13764","inReplyTo":null,"subject":"[PATCH] rebase --interactive: Compute upstream SHA1 before switching branches","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-06-02T14:01:40Z","receivedAt":"2008-06-02T14:01:40Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nIf the upstream argument to rebase (the first argument) was relative to\nHEAD and the name of the branch to rebase (the second argument) was given,\nthe upstream would have been interpreted relative to the second argument.\nIn particular, this command\n\n    git rebase -i HEAD topic\n\nwould always finish with \"Nothing to do\". (a1bf91e fixed the same issue\nfor non-interactive rebase.)\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n\nI made this with -U5 so that you can see the checkout in the context.\n\nBTW, methinks, this checkout is unnecessary, since before the rebase\nbegins, there is a 'git checkout $ONTO', and the branch switching is\ncertainly not needed to compute the todo list...\n\n-- Hannes\n\n git-rebase--interactive.sh |    7 +++----\n 1 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8ee08ff..0ca986f 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -473,25 +473,24 @@ do\n \t\t\t;;\n \t\tesac\n\n \t\trequire_clean_work_tree\n\n+\t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n+\t\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n+\n \t\tif test ! -z \"$2\"\n \t\tthen\n \t\t\toutput git show-ref --verify --quiet \"refs/heads/$2\" ||\n \t\t\t\tdie \"Invalid branchname: $2\"\n \t\t\toutput git checkout \"$2\" ||\n \t\t\t\tdie \"Could not checkout $2\"\n \t\tfi\n\n \t\tHEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-\t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\n \t\tmkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n\n-\t\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n-\n \t\t: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n \t\tgit symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n \t\t\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n\n \t\techo $HEAD > \"$DOTEST\"/head\n-- \n1.5.6.rc0.885.gdf17.dirty\n"},{"id":"78372","messageId":"alpine.DEB.1.00.0806021628260.13507@racer.site.net","threadId":"13764","inReplyTo":"4843FD44.90905@viscovery.net","subject":"Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-02T15:29:17Z","receivedAt":"2008-06-02T15:29:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 2 Jun 2008, Johannes Sixt wrote:\n\n> From: Johannes Sixt <johannes.sixt@telecom.at>\n> \n> If the upstream argument to rebase (the first argument) was relative to\n> HEAD and the name of the branch to rebase (the second argument) was given,\n> the upstream would have been interpreted relative to the second argument.\n> In particular, this command\n> \n>     git rebase -i HEAD topic\n> \n> would always finish with \"Nothing to do\". (a1bf91e fixed the same issue\n> for non-interactive rebase.)\n> \n> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n\nAcked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\n> I made this with -U5 so that you can see the checkout in the context.\n> \n> BTW, methinks, this checkout is unnecessary, since before the rebase \n> begins, there is a 'git checkout $ONTO', and the branch switching is \n> certainly not needed to compute the todo list...\n\nIt is needed to determine which branch to update after finish.\n\nCiao,\nDscho\n"},{"id":"78453","messageId":"7vbq2j5k0u.fsf@gitster.siamese.dyndns.org","threadId":"13764","inReplyTo":"alpine.DEB.1.00.0806021628260.13507@racer.site.net","subject":"Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-03T02:28:49Z","receivedAt":"2008-06-03T02:28:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> BTW, methinks, this checkout is unnecessary, since before the rebase \n>> begins, there is a 'git checkout $ONTO', and the branch switching is \n>> certainly not needed to compute the todo list...\n>\n> It is needed to determine which branch to update after finish.\n\nI'll apply Hannes's patch for now as I do not want to leave an obvious fix\nout of -rc1.\n\nI think Hannes is referring to the same issue as the one dealt with with\n0cb0664 (rebase [--onto O] A B: omit needless checkout, 2008-03-15) for\nthe non-interactive codepath.\n\nYou certainly \"need to determine which branch to update after finish\", and\nyou do need to remember what branch you were on (if you were not called\nwith the <branch> parameter), or what branch were given from the command\nline (if you got one as <branch> parameter) in order to do so, but the way\nto remember these values does not have to involve an extra checkout.\n\nBy doing an extra checkout of \"the original HEAD\", before switching to a\ndetached HEAD state at the $ONTO commit to \"clean the slate\" to apply the\nsequence on top, more work tree entries will be smudged, forcinging more\nrecompilations than necessary if the tracked contents are \"source\" files.\n"},{"id":"78501","messageId":"alpine.DEB.1.00.0806031454350.13507@racer.site.net","threadId":"13764","inReplyTo":"7vbq2j5k0u.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] rebase --interactive: Compute upstream SHA1 before switching branches","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-03T13:55:22Z","receivedAt":"2008-06-03T13:55:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 2 Jun 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> BTW, methinks, this checkout is unnecessary, since before the rebase \n> >> begins, there is a 'git checkout $ONTO', and the branch switching is \n> >> certainly not needed to compute the todo list...\n> >\n> > It is needed to determine which branch to update after finish.\n> \n> I'll apply Hannes's patch for now as I do not want to leave an obvious fix\n> out of -rc1.\n> \n> I think Hannes is referring to the same issue as the one dealt with with\n> 0cb0664 (rebase [--onto O] A B: omit needless checkout, 2008-03-15) for\n> the non-interactive codepath.\n> \n> You certainly \"need to determine which branch to update after finish\", \n> and you do need to remember what branch you were on (if you were not \n> called with the <branch> parameter), or what branch were given from the \n> command line (if you got one as <branch> parameter) in order to do so, \n> but the way to remember these values does not have to involve an extra \n> checkout.\n> \n> By doing an extra checkout of \"the original HEAD\", before switching to a \n> detached HEAD state at the $ONTO commit to \"clean the slate\" to apply \n> the sequence on top, more work tree entries will be smudged, forcinging \n> more recompilations than necessary if the tracked contents are \"source\" \n> files.\n\nRight.  I failed to follow the given hint to the other commit, but it \nmakes perfect sense now.\n\nThanks,\nDscho\n"}]}