git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add option to git-branch to set up automatic rebasing
@ 2008-06-19  0:53 Pieter de Bie
  2008-06-19 14:00 ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Pieter de Bie @ 2008-06-19  0:53 UTC (permalink / raw)
  To: Git Mailinglist, Junio C Hamano; +Cc: Pieter de Bie

This functionality was actually introduced in
 0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the
configuration flag. Now we can also setup auto rebasing using the --rebase
flag in git-branch or git-checkout, similar to how --track works.

Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
---
 Documentation/git-branch.txt   |   12 ++++++++++--
 Documentation/git-checkout.txt |   11 ++++++++---
 builtin-branch.c               |   10 ++++++++--
 builtin-checkout.c             |    9 ++++++++-
 4 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 0fd5808..81144d1 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -11,7 +11,8 @@ SYNOPSIS
 'git-branch' [--color | --no-color] [-r | -a] [--merged | --no-merged]
 	   [-v [--abbrev=<length> | --no-abbrev]]
 	   [--contains <commit>]
-'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
+'git-branch' [--track | --no-track | --rebase] [-l] [-f]
+	   <branchname> [<start-point>]
 'git-branch' (-m | -M) [<oldbranch>] <newbranch>
 'git-branch' (-d | -D) [-r] <branchname>...
 
@@ -40,7 +41,9 @@ When a local branch is started off a remote branch, git sets up the
 branch so that linkgit:git-pull[1] will appropriately merge from
 the remote branch. This behavior may be changed via the global
 `branch.autosetupmerge` configuration flag. That setting can be
-overridden by using the `--track` and `--no-track` options.
+overridden by using the `--track` and `--no-track` options. If you use
+--rebase, the branch will be set up to rebase instead of merge on pull.
+This can also be set to the default by the 'branch.autosetuprebase' flag.
 
 With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.
 If <oldbranch> had a corresponding reflog, it is renamed to match
@@ -121,6 +124,11 @@ OPTIONS
 --no-track::
 	Ignore the branch.autosetupmerge configuration variable.
 
+--rebase::
+	Does the same as --track, with the exception that subsequent pulls
+	will do a rebase, not a pull. This is the same as using "git pull
+	--rebase" to update the branch.
+
 --contains <commit>::
 	Only list branches which contain the specified commit.
 
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 3ad9760..eb114a2 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -8,7 +8,7 @@ git-checkout - Checkout a branch or paths to the working tree
 SYNOPSIS
 --------
 [verse]
-'git-checkout' [-q] [-f] [[--track | --no-track] -b <new_branch> [-l]] [-m] [<branch>]
+'git-checkout' [-q] [-f] [[--track | --no-track | --rebase] -b <new_branch> [-l]] [-m] [<branch>]
 'git-checkout' [<tree-ish>] <paths>...
 
 DESCRIPTION
@@ -18,8 +18,8 @@ When <paths> are not given, this command switches branches by
 updating the index and working tree to reflect the specified
 branch, <branch>, and updating HEAD to be <branch> or, if
 specified, <new_branch>.  Using -b will cause <new_branch> to
-be created; in this case you can use the --track or --no-track
-options, which will be passed to `git branch`.
+be created; in this case you can use the --track, --no-track
+and --rebase options, which will be passed to `git branch`.
 
 When <paths> are given, this command does *not* switch
 branches.  It updates the named paths in the working tree from
@@ -63,6 +63,11 @@ OPTIONS
 --no-track::
 	Ignore the branch.autosetupmerge configuration variable.
 
+--rebase::
+	Does the same as --track, with the exception that subsequent pulls
+	will do a rebase, not a pull. This is the same as using "git pull
+	--rebase" to update the branch.
+
 -l::
 	Create the new branch's reflog.  This activates recording of
 	all changes made to the branch ref, enabling use of date
diff --git a/builtin-branch.c b/builtin-branch.c
index d279702..b1ba920 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -18,7 +18,7 @@ static const char * const builtin_branch_usage[] = {
 	"git-branch [options] [-r | -a] [--merged | --no-merged]",
 	"git-branch [options] [-l] [-f] <branchname> [<start-point>]",
 	"git-branch [options] [-r] (-d | -D) <branchname>",
-	"git-branch [options] (-m | -M) [<oldbranch>] <newbranch>",
+	"git-branch [options] [--track | --no-track | --rebase] (-m | -M) [<oldbranch>] <newbranch>",
 	NULL
 };
 
@@ -425,7 +425,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 {
 	int delete = 0, rename = 0, force_create = 0;
 	int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
-	int reflog = 0;
+	int reflog = 0, rebase = 0;
 	enum branch_track track;
 	int kinds = REF_LOCAL_BRANCH;
 	struct commit_list *with_commit = NULL;
@@ -457,6 +457,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
 		OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
 		OPT_BOOLEAN('f', NULL, &force_create, "force creation (when already exists)"),
+		OPT_BOOLEAN(0, "rebase", &rebase, "Setup automatic rebasing. Implies --track"),
 		OPT_SET_INT(0, "merged", &mergefilter, "list only merged branches", 1),
 		OPT_END(),
 	};
@@ -471,6 +472,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 	if (!!delete + !!rename + !!force_create > 1)
 		usage_with_options(builtin_branch_usage, options);
 
+	if (rebase) {
+		autorebase = AUTOREBASE_ALWAYS;
+		track = BRANCH_TRACK_EXPLICIT;
+	}
+
 	head = resolve_ref("HEAD", head_sha1, 0, NULL);
 	if (!head)
 		die("Failed to resolve HEAD as a valid ref.");
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 93ea69b..ee4fb09 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -500,6 +500,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	struct checkout_opts opts;
 	unsigned char rev[20];
 	const char *arg;
+	int rebase = 0;
 	struct branch_info new;
 	struct tree *source_tree = NULL;
 	struct option options[] = {
@@ -508,6 +509,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"),
 		OPT_SET_INT('t', "track",  &opts.track, "track",
 			BRANCH_TRACK_EXPLICIT),
+		OPT_BOOLEAN(0, "rebase", &rebase, "Setup automatic rebasing. Implies --track"),
 		OPT_BOOLEAN('f', NULL, &opts.force, "force"),
 		OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
 		OPT_END(),
@@ -521,6 +523,11 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	opts.track = git_branch_track;
 
 	argc = parse_options(argc, argv, options, checkout_usage, 0);
+	if (rebase) {
+		autorebase = AUTOREBASE_ALWAYS;
+		opts.track = BRANCH_TRACK_EXPLICIT;
+	}
+
 	if (argc) {
 		arg = argv[0];
 		if (get_sha1(arg, rev))
@@ -548,7 +555,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	}
 
 	if (!opts.new_branch && (opts.track != git_branch_track))
-		die("git checkout: --track and --no-track require -b");
+		die("git checkout: --track, --no-track and --rebase require -b");
 
 	if (opts.force && opts.merge)
 		die("git checkout: -f and -m are incompatible");
-- 
1.5.6.rc1.153.gc1d96

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19  0:53 [PATCH] Add option to git-branch to set up automatic rebasing Pieter de Bie
@ 2008-06-19 14:00 ` Johannes Schindelin
  2008-06-19 14:10   ` Pieter de Bie
  2008-06-19 15:43   ` Björn Steinbrink
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Schindelin @ 2008-06-19 14:00 UTC (permalink / raw)
  To: Pieter de Bie; +Cc: Git Mailinglist, Junio C Hamano

Hi,

On Thu, 19 Jun 2008, Pieter de Bie wrote:

> This functionality was actually introduced in
>  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the
> configuration flag. Now we can also setup auto rebasing using the --rebase
> flag in git-branch or git-checkout, similar to how --track works.

How about "--rebasing"?  I would scratch my head a bit how a new branch 
and a rebase would go together.

Ciao,
Dscho

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19 14:00 ` Johannes Schindelin
@ 2008-06-19 14:10   ` Pieter de Bie
  2008-06-19 15:43   ` Björn Steinbrink
  1 sibling, 0 replies; 7+ messages in thread
From: Pieter de Bie @ 2008-06-19 14:10 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailinglist, Junio C Hamano


On 19 jun 2008, at 16:00, Johannes Schindelin wrote:

> How about "--rebasing"?  I would scratch my head a bit how a new  
> branch
> and a rebase would go together.

Perhaps even --auto-rebase then? I agree it sounds confusing

- Pieter

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19 14:00 ` Johannes Schindelin
  2008-06-19 14:10   ` Pieter de Bie
@ 2008-06-19 15:43   ` Björn Steinbrink
  2008-06-19 19:14     ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Björn Steinbrink @ 2008-06-19 15:43 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Pieter de Bie, Git Mailinglist, Junio C Hamano

On 2008.06.19 15:00:19 +0100, Johannes Schindelin wrote:
> Hi,
> 
> On Thu, 19 Jun 2008, Pieter de Bie wrote:
> 
> > This functionality was actually introduced in
> >  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the
> > configuration flag. Now we can also setup auto rebasing using the --rebase
> > flag in git-branch or git-checkout, similar to how --track works.
> 
> How about "--rebasing"?  I would scratch my head a bit how a new branch 
> and a rebase would go together.

Hm, --rebasing sounds weird to me as well. Maybe --track=merge and
--track=rebase, with --track being equal to --track=merge?

Björn

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19 15:43   ` Björn Steinbrink
@ 2008-06-19 19:14     ` Junio C Hamano
  2008-06-19 22:58       ` Pieter de Bie
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-06-19 19:14 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: Johannes Schindelin, Pieter de Bie, Git Mailinglist

Björn Steinbrink <B.Steinbrink@gmx.de> writes:

> On 2008.06.19 15:00:19 +0100, Johannes Schindelin wrote:
>> Hi,
>> 
>> On Thu, 19 Jun 2008, Pieter de Bie wrote:
>> 
>> > This functionality was actually introduced in
>> >  0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the
>> > configuration flag. Now we can also setup auto rebasing using the --rebase
>> > flag in git-branch or git-checkout, similar to how --track works.
>> 
>> How about "--rebasing"?  I would scratch my head a bit how a new branch 
>> and a rebase would go together.
>
> Hm, --rebasing sounds weird to me as well. Maybe --track=merge and
> --track=rebase, with --track being equal to --track=merge?

That looks like the best wording so far, although I suspect that the true
reason why all of the above sounds confusing may be because the concept
itself is not clear.

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19 19:14     ` Junio C Hamano
@ 2008-06-19 22:58       ` Pieter de Bie
  2008-06-19 23:24         ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Pieter de Bie @ 2008-06-19 22:58 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Björn Steinbrink, Johannes Schindelin, Git Mailinglist


On 19 jun 2008, at 21:14, Junio C Hamano wrote:

>> Hm, --rebasing sounds weird to me as well. Maybe --track=merge and
>> --track=rebase, with --track being equal to --track=merge?
>
> That looks like the best wording so far, although I suspect that the  
> true
> reason why all of the above sounds confusing may be because the  
> concept
> itself is not clear.

That's why I suggested --auto-rebase, which is more verbose in what
it does. Perhaps we should add it as an optional flag for --track, like

   git branch --track --auto-rebase local remote/branch

? That is a bit long though.

I don't think "--track=rebase" makes a lot of sense, since "track" is
still a boolean in my head ;)

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

* Re: [PATCH] Add option to git-branch to set up automatic rebasing
  2008-06-19 22:58       ` Pieter de Bie
@ 2008-06-19 23:24         ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2008-06-19 23:24 UTC (permalink / raw)
  To: Pieter de Bie; +Cc: Björn Steinbrink, Johannes Schindelin, Git Mailinglist

Pieter de Bie <pdebie@ai.rug.nl> writes:

> That's why I suggested --auto-rebase, which is more verbose in what
> it does. Perhaps we should add it as an optional flag for --track, like
>
>   git branch --track --auto-rebase local remote/branch
>
> ? That is a bit long though.

That does not make _any_ sense unless you also have --auto-merge.  And
which part of rebasing is auto anyway?  "git checkout local" won't rebase
onto remote/branch for one thing.

> I don't think "--track=rebase" makes a lot of sense, since "track" is
> still a boolean in my head ;)

Well, track _is_ boolean.  You usually build and develop yourself, but if
you are following somebody else, you say "this is not really a pure
development but is used to trail somebody else (aka "track mode ON"), and
the way for this branch to follow that somebody else specifically is to
merge from it or rebase on top of it (aka "how it tracks")".

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

end of thread, other threads:[~2008-06-19 23:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-19  0:53 [PATCH] Add option to git-branch to set up automatic rebasing Pieter de Bie
2008-06-19 14:00 ` Johannes Schindelin
2008-06-19 14:10   ` Pieter de Bie
2008-06-19 15:43   ` Björn Steinbrink
2008-06-19 19:14     ` Junio C Hamano
2008-06-19 22:58       ` Pieter de Bie
2008-06-19 23:24         ` Junio C Hamano

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 NNTP newsgroup(s).