X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=branch.c;h=56e949232cac1fe9dbe23aa93b50fe2f7c55c07d;hb=3f4d1c639347317788f2c5080f89de53772499ce;hp=daf862e728622f9a59a2721e5cd297394be6c9da;hpb=5736a3747120d6215de4fdfcf45f4a168a8d024e;p=git.git diff --git a/branch.c b/branch.c index daf862e72..56e949232 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..{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; }