{"thread":{"id":"14026","subject":"[PATCH] Add option to git-branch to set up automatic rebasing","startedAt":"2008-06-19T00:53:22Z","lastAt":"2008-06-19T23:24:10Z","messageCount":7,"participants":["Pieter de Bie","Johannes Schindelin","Björn Steinbrink","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"80278","messageId":"1213836802-3163-1-git-send-email-pdebie@ai.rug.nl","threadId":"14026","inReplyTo":null,"subject":"[PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-06-19T00:53:22Z","receivedAt":"2008-06-19T00:53:22Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"This functionality was actually introduced in\n 0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the\nconfiguration flag. Now we can also setup auto rebasing using the --rebase\nflag in git-branch or git-checkout, similar to how --track works.\n\nSigned-off-by: Pieter de Bie <pdebie@ai.rug.nl>\n---\n Documentation/git-branch.txt   |   12 ++++++++++--\n Documentation/git-checkout.txt |   11 ++++++++---\n builtin-branch.c               |   10 ++++++++--\n builtin-checkout.c             |    9 ++++++++-\n 4 files changed, 34 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 0fd5808..81144d1 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -11,7 +11,8 @@ SYNOPSIS\n 'git-branch' [--color | --no-color] [-r | -a] [--merged | --no-merged]\n \t   [-v [--abbrev=<length> | --no-abbrev]]\n \t   [--contains <commit>]\n-'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]\n+'git-branch' [--track | --no-track | --rebase] [-l] [-f]\n+\t   <branchname> [<start-point>]\n 'git-branch' (-m | -M) [<oldbranch>] <newbranch>\n 'git-branch' (-d | -D) [-r] <branchname>...\n \n@@ -40,7 +41,9 @@ When a local branch is started off a remote branch, git sets up the\n branch so that linkgit:git-pull[1] will appropriately merge from\n the remote branch. This behavior may be changed via the global\n `branch.autosetupmerge` configuration flag. That setting can be\n-overridden by using the `--track` and `--no-track` options.\n+overridden by using the `--track` and `--no-track` options. If you use\n+--rebase, the branch will be set up to rebase instead of merge on pull.\n+This can also be set to the default by the 'branch.autosetuprebase' flag.\n \n With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.\n If <oldbranch> had a corresponding reflog, it is renamed to match\n@@ -121,6 +124,11 @@ OPTIONS\n --no-track::\n \tIgnore the branch.autosetupmerge configuration variable.\n \n+--rebase::\n+\tDoes the same as --track, with the exception that subsequent pulls\n+\twill do a rebase, not a pull. This is the same as using \"git pull\n+\t--rebase\" to update the branch.\n+\n --contains <commit>::\n \tOnly list branches which contain the specified commit.\n \ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex 3ad9760..eb114a2 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -8,7 +8,7 @@ git-checkout - Checkout a branch or paths to the working tree\n SYNOPSIS\n --------\n [verse]\n-'git-checkout' [-q] [-f] [[--track | --no-track] -b <new_branch> [-l]] [-m] [<branch>]\n+'git-checkout' [-q] [-f] [[--track | --no-track | --rebase] -b <new_branch> [-l]] [-m] [<branch>]\n 'git-checkout' [<tree-ish>] <paths>...\n \n DESCRIPTION\n@@ -18,8 +18,8 @@ When <paths> are not given, this command switches branches by\n updating the index and working tree to reflect the specified\n branch, <branch>, and updating HEAD to be <branch> or, if\n specified, <new_branch>.  Using -b will cause <new_branch> to\n-be created; in this case you can use the --track or --no-track\n-options, which will be passed to `git branch`.\n+be created; in this case you can use the --track, --no-track\n+and --rebase options, which will be passed to `git branch`.\n \n When <paths> are given, this command does *not* switch\n branches.  It updates the named paths in the working tree from\n@@ -63,6 +63,11 @@ OPTIONS\n --no-track::\n \tIgnore the branch.autosetupmerge configuration variable.\n \n+--rebase::\n+\tDoes the same as --track, with the exception that subsequent pulls\n+\twill do a rebase, not a pull. This is the same as using \"git pull\n+\t--rebase\" to update the branch.\n+\n -l::\n \tCreate the new branch's reflog.  This activates recording of\n \tall changes made to the branch ref, enabling use of date\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex d279702..b1ba920 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -18,7 +18,7 @@ static const char * const builtin_branch_usage[] = {\n \t\"git-branch [options] [-r | -a] [--merged | --no-merged]\",\n \t\"git-branch [options] [-l] [-f] <branchname> [<start-point>]\",\n \t\"git-branch [options] [-r] (-d | -D) <branchname>\",\n-\t\"git-branch [options] (-m | -M) [<oldbranch>] <newbranch>\",\n+\t\"git-branch [options] [--track | --no-track | --rebase] (-m | -M) [<oldbranch>] <newbranch>\",\n \tNULL\n };\n \n@@ -425,7 +425,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n {\n \tint delete = 0, rename = 0, force_create = 0;\n \tint verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;\n-\tint reflog = 0;\n+\tint reflog = 0, rebase = 0;\n \tenum branch_track track;\n \tint kinds = REF_LOCAL_BRANCH;\n \tstruct commit_list *with_commit = NULL;\n@@ -457,6 +457,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_BIT('M', NULL, &rename, \"move/rename a branch, even if target exists\", 2),\n \t\tOPT_BOOLEAN('l', NULL, &reflog, \"create the branch's reflog\"),\n \t\tOPT_BOOLEAN('f', NULL, &force_create, \"force creation (when already exists)\"),\n+\t\tOPT_BOOLEAN(0, \"rebase\", &rebase, \"Setup automatic rebasing. Implies --track\"),\n \t\tOPT_SET_INT(0, \"merged\", &mergefilter, \"list only merged branches\", 1),\n \t\tOPT_END(),\n \t};\n@@ -471,6 +472,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tif (!!delete + !!rename + !!force_create > 1)\n \t\tusage_with_options(builtin_branch_usage, options);\n \n+\tif (rebase) {\n+\t\tautorebase = AUTOREBASE_ALWAYS;\n+\t\ttrack = BRANCH_TRACK_EXPLICIT;\n+\t}\n+\n \thead = resolve_ref(\"HEAD\", head_sha1, 0, NULL);\n \tif (!head)\n \t\tdie(\"Failed to resolve HEAD as a valid ref.\");\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 93ea69b..ee4fb09 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -500,6 +500,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tstruct checkout_opts opts;\n \tunsigned char rev[20];\n \tconst char *arg;\n+\tint rebase = 0;\n \tstruct branch_info new;\n \tstruct tree *source_tree = NULL;\n \tstruct option options[] = {\n@@ -508,6 +509,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN('l', NULL, &opts.new_branch_log, \"log for new branch\"),\n \t\tOPT_SET_INT('t', \"track\",  &opts.track, \"track\",\n \t\t\tBRANCH_TRACK_EXPLICIT),\n+\t\tOPT_BOOLEAN(0, \"rebase\", &rebase, \"Setup automatic rebasing. Implies --track\"),\n \t\tOPT_BOOLEAN('f', NULL, &opts.force, \"force\"),\n \t\tOPT_BOOLEAN('m', NULL, &opts.merge, \"merge\"),\n \t\tOPT_END(),\n@@ -521,6 +523,11 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \topts.track = git_branch_track;\n \n \targc = parse_options(argc, argv, options, checkout_usage, 0);\n+\tif (rebase) {\n+\t\tautorebase = AUTOREBASE_ALWAYS;\n+\t\topts.track = BRANCH_TRACK_EXPLICIT;\n+\t}\n+\n \tif (argc) {\n \t\targ = argv[0];\n \t\tif (get_sha1(arg, rev))\n@@ -548,7 +555,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (!opts.new_branch && (opts.track != git_branch_track))\n-\t\tdie(\"git checkout: --track and --no-track require -b\");\n+\t\tdie(\"git checkout: --track, --no-track and --rebase require -b\");\n \n \tif (opts.force && opts.merge)\n \t\tdie(\"git checkout: -f and -m are incompatible\");\n-- \n1.5.6.rc1.153.gc1d96\n"},{"id":"80315","messageId":"alpine.DEB.1.00.0806191459150.6439@racer","threadId":"14026","inReplyTo":"1213836802-3163-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-19T14:00:19Z","receivedAt":"2008-06-19T14:00:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 19 Jun 2008, Pieter de Bie wrote:\n\n> This functionality was actually introduced in\n>  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the\n> configuration flag. Now we can also setup auto rebasing using the --rebase\n> flag in git-branch or git-checkout, similar to how --track works.\n\nHow about \"--rebasing\"?  I would scratch my head a bit how a new branch \nand a rebase would go together.\n\nCiao,\nDscho\n"},{"id":"80316","messageId":"FCE0735F-3CF9-4F7D-AA1B-FA9D8EA8C593@ai.rug.nl","threadId":"14026","inReplyTo":"alpine.DEB.1.00.0806191459150.6439@racer","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-06-19T14:10:22Z","receivedAt":"2008-06-19T14:10:22Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"\nOn 19 jun 2008, at 16:00, Johannes Schindelin wrote:\n\n> How about \"--rebasing\"?  I would scratch my head a bit how a new  \n> branch\n> and a rebase would go together.\n\nPerhaps even --auto-rebase then? I agree it sounds confusing\n\n- Pieter\n"},{"id":"80324","messageId":"20080619154350.GA21625@atjola.homenet","threadId":"14026","inReplyTo":"alpine.DEB.1.00.0806191459150.6439@racer","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-06-19T15:43:50Z","receivedAt":"2008-06-19T15:43:50Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.06.19 15:00:19 +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Thu, 19 Jun 2008, Pieter de Bie wrote:\n> \n> > This functionality was actually introduced in\n> >  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the\n> > configuration flag. Now we can also setup auto rebasing using the --rebase\n> > flag in git-branch or git-checkout, similar to how --track works.\n> \n> How about \"--rebasing\"?  I would scratch my head a bit how a new branch \n> and a rebase would go together.\n\nHm, --rebasing sounds weird to me as well. Maybe --track=merge and\n--track=rebase, with --track being equal to --track=merge?\n\nBjörn\n"},{"id":"80355","messageId":"7vr6attey8.fsf@gitster.siamese.dyndns.org","threadId":"14026","inReplyTo":"20080619154350.GA21625@atjola.homenet","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-19T19:14:23Z","receivedAt":"2008-06-19T19:14:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Björn Steinbrink <B.Steinbrink@gmx.de> writes:\n\n> On 2008.06.19 15:00:19 +0100, Johannes Schindelin wrote:\n>> Hi,\n>> \n>> On Thu, 19 Jun 2008, Pieter de Bie wrote:\n>> \n>> > This functionality was actually introduced in\n>> >  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the\n>> > configuration flag. Now we can also setup auto rebasing using the --rebase\n>> > flag in git-branch or git-checkout, similar to how --track works.\n>> \n>> How about \"--rebasing\"?  I would scratch my head a bit how a new branch \n>> and a rebase would go together.\n>\n> Hm, --rebasing sounds weird to me as well. Maybe --track=merge and\n> --track=rebase, with --track being equal to --track=merge?\n\nThat looks like the best wording so far, although I suspect that the true\nreason why all of the above sounds confusing may be because the concept\nitself is not clear.\n"},{"id":"80397","messageId":"12AB50C8-6CBF-4D96-8FAB-90234A9006D0@ai.rug.nl","threadId":"14026","inReplyTo":"7vr6attey8.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-06-19T22:58:06Z","receivedAt":"2008-06-19T22:58:06Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"\nOn 19 jun 2008, at 21:14, Junio C Hamano wrote:\n\n>> Hm, --rebasing sounds weird to me as well. Maybe --track=merge and\n>> --track=rebase, with --track being equal to --track=merge?\n>\n> That looks like the best wording so far, although I suspect that the  \n> true\n> reason why all of the above sounds confusing may be because the  \n> concept\n> itself is not clear.\n\nThat's why I suggested --auto-rebase, which is more verbose in what\nit does. Perhaps we should add it as an optional flag for --track, like\n\n   git branch --track --auto-rebase local remote/branch\n\n? That is a bit long though.\n\nI don't think \"--track=rebase\" makes a lot of sense, since \"track\" is\nstill a boolean in my head ;)\n"},{"id":"80415","messageId":"7vabhhroth.fsf@gitster.siamese.dyndns.org","threadId":"14026","inReplyTo":"12AB50C8-6CBF-4D96-8FAB-90234A9006D0@ai.rug.nl","subject":"Re: [PATCH] Add option to git-branch to set up automatic rebasing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-19T23:24:10Z","receivedAt":"2008-06-19T23:24:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pieter de Bie <pdebie@ai.rug.nl> writes:\n\n> That's why I suggested --auto-rebase, which is more verbose in what\n> it does. Perhaps we should add it as an optional flag for --track, like\n>\n>   git branch --track --auto-rebase local remote/branch\n>\n> ? That is a bit long though.\n\nThat does not make _any_ sense unless you also have --auto-merge.  And\nwhich part of rebasing is auto anyway?  \"git checkout local\" won't rebase\nonto remote/branch for one thing.\n\n> I don't think \"--track=rebase\" makes a lot of sense, since \"track\" is\n> still a boolean in my head ;)\n\nWell, track _is_ boolean.  You usually build and develop yourself, but if\nyou are following somebody else, you say \"this is not really a pure\ndevelopment but is used to trail somebody else (aka \"track mode ON\"), and\nthe way for this branch to follow that somebody else specifically is to\nmerge from it or rebase on top of it (aka \"how it tracks\")\".\n"}]}