summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2008-05-10 15:36:29 -0700
committerJunio C Hamano <gitster@pobox.com>2008-05-11 09:28:52 -0700
commitc998ae9baa1cc5f507646da9850731de634d2ee7 (patch)
tree0df6f1a71d2a6e5de4737c4ea784d67cdd760340 /branch.c
parentd1a8d0ea5fb2d4d43d0ea8f2fe45ec1fce7ec4bc (diff)
downloadgit-c998ae9baa1cc5f507646da9850731de634d2ee7.tar.gz
Allow tracking branches to set up rebase by default.
Change cd67e4d4 introduced a new configuration parameter that told pull to automatically perform a rebase instead of a merge. This change provides a configuration option to enable this feature automatically when creating a new branch. If the variable branch.autosetuprebase applies for a branch that's being created, that branch will have branch.<name>.rebase set to true. Signed-off-by: Dustin Sallings <dustin@spy.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/branch.c b/branch.c
index daf862e728..56e949232c 100644
--- a/branch.c
+++ b/branch.c
@@ -32,6 +32,21 @@ static int find_tracked_branch(struct remote *remote, void *priv)
return 0;
}
+static int should_setup_rebase(const struct tracking *tracking)
+{
+ switch (autorebase) {
+ case AUTOREBASE_NEVER:
+ return 0;
+ case AUTOREBASE_LOCAL:
+ return tracking->remote == NULL;
+ case AUTOREBASE_REMOTE:
+ return tracking->remote != NULL;
+ case AUTOREBASE_ALWAYS:
+ return 1;
+ }
+ return 0;
+}
+
/*
* This is called when new_ref is branched off of orig_ref, and tries
* to infer the settings for branch.<new_ref>.{remote,merge} from the
@@ -69,9 +84,14 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
git_config_set(key, tracking.remote ? tracking.remote : ".");
sprintf(key, "branch.%s.merge", new_ref);
git_config_set(key, tracking.src ? tracking.src : orig_ref);
- free(tracking.src);
printf("Branch %s set up to track %s branch %s.\n", new_ref,
tracking.remote ? "remote" : "local", orig_ref);
+ if (should_setup_rebase(&tracking)) {
+ sprintf(key, "branch.%s.rebase", new_ref);
+ git_config_set(key, "true");
+ printf("This branch will rebase on pull.\n");
+ }
+ free(tracking.src);
return 0;
}