{"thread":{"id":"34488","subject":"[RFC] checkout --rebase","startedAt":"2013-07-19T10:21:41Z","lastAt":"2013-07-19T12:31:39Z","messageCount":6,"participants":["Ramkumar Ramachandra","Sebastian Staudt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"223743","messageId":"CALkWK0m-ZpVvvgAB_yzooah0=veeNDudahs=4ur2YHN03h-h4g@mail.gmail.com","threadId":"34488","inReplyTo":null,"subject":"[RFC] checkout --rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T10:21:41Z","receivedAt":"2013-07-19T10:21:41Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nI'm often work on small topic branches, and find myself doing this quite often:\n\n  # on branch master\n  $ git checkout um-build\n  $ git rebase master\n\nThis is horribly inefficient; the first operation takes a _really_\nlong time to complete, since master updates itself very often and I\nhave to check out an old worktree.  So, I work around this issue by\ndoing:\n\n  # on branch master\n  $ git checkout -b um-build-2\n  $ git cherry-pick ..um-build\n  $ git branch -M um-build\n\n... and I scripted it.  Perhaps we should get this functionality in\ncore, as `git checkout --rebase` (or something)?\n\nThanks.\n"},{"id":"223745","messageId":"CA+xP2SbHD+MU4K0JBbZdA6bWQFQerBi5mWA+7G9=tBksjp+LXw@mail.gmail.com","threadId":"34488","inReplyTo":"CALkWK0m-ZpVvvgAB_yzooah0=veeNDudahs=4ur2YHN03h-h4g@mail.gmail.com","subject":"Re: [RFC] checkout --rebase","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2013-07-19T10:48:22Z","receivedAt":"2013-07-19T10:48:22Z","isPatch":false,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"Isn't this what you want?\n\n $ git rebase master um-build\n\n\n2013/7/19 Ramkumar Ramachandra <artagnon@gmail.com>:\n> Hi,\n>\n> I'm often work on small topic branches, and find myself doing this quite often:\n>\n>   # on branch master\n>   $ git checkout um-build\n>   $ git rebase master\n>\n> This is horribly inefficient; the first operation takes a _really_\n> long time to complete, since master updates itself very often and I\n> have to check out an old worktree.  So, I work around this issue by\n> doing:\n>\n>   # on branch master\n>   $ git checkout -b um-build-2\n>   $ git cherry-pick ..um-build\n>   $ git branch -M um-build\n>\n> ... and I scripted it.  Perhaps we should get this functionality in\n> core, as `git checkout --rebase` (or something)?\n>\n> Thanks.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"223746","messageId":"CALkWK0nM4fkCPNJo_c3Rpwh1azsGRdGvM3S80vcuRiRXDT0vOQ@mail.gmail.com","threadId":"34488","inReplyTo":"CA+xP2SbHD+MU4K0JBbZdA6bWQFQerBi5mWA+7G9=tBksjp+LXw@mail.gmail.com","subject":"Re: [RFC] checkout --rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T11:10:41Z","receivedAt":"2013-07-19T11:10:41Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Sebastian Staudt wrote:\n> Isn't this what you want?\n>\n>  $ git rebase master um-build\n\nHa, yes.  Sorry about the stupidity.\n"},{"id":"223747","messageId":"CALkWK0kVNw3Ko3+_Y-KDF=pdha6wxyMmQmLtOOr5tQYzgUr_Mw@mail.gmail.com","threadId":"34488","inReplyTo":"CALkWK0nM4fkCPNJo_c3Rpwh1azsGRdGvM3S80vcuRiRXDT0vOQ@mail.gmail.com","subject":"Re: [RFC] checkout --rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T11:33:27Z","receivedAt":"2013-07-19T11:33:27Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n> Sebastian Staudt wrote:\n>> Isn't this what you want?\n>>\n>>  $ git rebase master um-build\n>\n> Ha, yes.  Sorry about the stupidity.\n\nHm, I'm not entirely sure how to optimize the codepath to eliminate\nthe checkout.  It seems to be absolutely necessary atleast in the -i\ncodepath.\n\nLet's inspect when $switch_to is set:\n\n\t# Is it \"rebase other $branchname\" or \"rebase other $commit\"?\n\tbranch_name=\"$1\"\n\tswitch_to=\"$1\"\n\n$revisions seems to be set correctly, and rebase--am does a\nmove_to_original_branch as the last step.  So, I wonder if this will\nwork:\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 0039ecf..7405d9a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -542,9 +542,15 @@ then\n \tif test -z \"$force_rebase\"\n \tthen\n \t\t# Lazily switch to the target branch if needed...\n-\t\ttest -z \"$switch_to\" ||\n-\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\" \\\n-\t\t\tgit checkout \"$switch_to\" --\n+\t\tif ! test -z \"$switch_to\"; then\n+\t\t\tif \"$type\" = am; then\n+\t\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout -b $switch_to-2\" \\\n+\t\t\t\t\tgit checkout -b \"$switch_to-2\" --\n+\t\t\telse\n+\t\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\" \\\n+\t\t\t\t\tgit checkout \"$switch_to\" --\n+\t\t\tfi\n+\t\tfi\n \t\tsay \"$(eval_gettext \"Current branch \\$branch_name is up to date.\")\"\n \t\tfinish_rebase\n \t\texit 0\n\n(ofcourse, we still need a mechanism to remove this temporary\n$switch_to-2 branch)\n\nWhat about rebase--merge?  Can we eliminate the checkout then?\n"},{"id":"223748","messageId":"CALkWK0mp=2xuQwSjMPRBvwRUEnAbM2=r_hZu=ZKc8wxZYxgSVA@mail.gmail.com","threadId":"34488","inReplyTo":"CALkWK0kVNw3Ko3+_Y-KDF=pdha6wxyMmQmLtOOr5tQYzgUr_Mw@mail.gmail.com","subject":"Re: [RFC] checkout --rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T11:36:59Z","receivedAt":"2013-07-19T11:36:59Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index 0039ecf..7405d9a 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n\nEr, sorry.  I think it suffices to check that $branch_name equals\nHEAD, for this optimization.\n"},{"id":"223754","messageId":"CALkWK0=vpTHfVsa1QiM75cQL7Ou-_=2=_e-++ZLeeo-d8hqhOw@mail.gmail.com","threadId":"34488","inReplyTo":"CALkWK0mp=2xuQwSjMPRBvwRUEnAbM2=r_hZu=ZKc8wxZYxgSVA@mail.gmail.com","subject":"Re: [RFC] checkout --rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T12:31:39Z","receivedAt":"2013-07-19T12:31:39Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Damn it: checkout doesn't get executed at all because the $mb = $onto\ncondition fails; I was looking in the wrong place.  It's format-patch\nand am that are slowing things down terribly.  Has anyone looked into\nstripping out the dependency?  Why is cherry-pick deficient?\n\nMy current workaround is to use the faster `--keep-empty` codepath,\nbut it doesn't persist state on conflict.  Isn't this an undocumented\nfact (aka. bug)?\n\nThanks.\n"}]}