summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/branch.c b/branch.c
index 182f1c5a55..01ecb816d5 100644
--- a/branch.c
+++ b/branch.c
@@ -251,6 +251,9 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
.ambiguous_remotes = STRING_LIST_INIT_DUP,
};
+ if (!track)
+ BUG("asked to set up tracking, but tracking is disallowed");
+
memset(&tracking, 0, sizeof(tracking));
tracking.spec.dst = (char *)orig_ref;
tracking.srcs = &tracking_srcs;
@@ -308,7 +311,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
string_list_append(tracking.srcs, orig_ref);
if (install_branch_config_multiple_remotes(config_flags, new_ref,
tracking.remote, tracking.srcs) < 0)
- exit(-1);
+ exit(1);
cleanup:
string_list_clear(&tracking_srcs, 0);
@@ -434,12 +437,10 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
real_ref = NULL;
if (get_oid_mb(start_name, &oid)) {
if (explicit_tracking) {
- if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
- error(_(upstream_missing), start_name);
- advise(_(upstream_advice));
- exit(1);
- }
- die(_(upstream_missing), start_name);
+ int code = die_message(_(upstream_missing), start_name);
+ advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
+ _(upstream_advice));
+ exit(code);
}
die(_("not a valid object name: '%s'"), start_name);
}
@@ -583,8 +584,27 @@ static int submodule_create_branch(struct repository *r,
strvec_push(&child.args, "--quiet");
if (reflog)
strvec_push(&child.args, "--create-reflog");
- if (track == BRANCH_TRACK_ALWAYS || track == BRANCH_TRACK_EXPLICIT)
- strvec_push(&child.args, "--track");
+
+ switch (track) {
+ case BRANCH_TRACK_NEVER:
+ strvec_push(&child.args, "--no-track");
+ break;
+ case BRANCH_TRACK_ALWAYS:
+ case BRANCH_TRACK_EXPLICIT:
+ strvec_push(&child.args, "--track=direct");
+ break;
+ case BRANCH_TRACK_OVERRIDE:
+ BUG("BRANCH_TRACK_OVERRIDE cannot be used when creating a branch.");
+ break;
+ case BRANCH_TRACK_INHERIT:
+ strvec_push(&child.args, "--track=inherit");
+ break;
+ case BRANCH_TRACK_UNSPECIFIED:
+ /* Default for "git checkout". Do not pass --track. */
+ case BRANCH_TRACK_REMOTE:
+ /* Default for "git branch". Do not pass --track. */
+ break;
+ }
strvec_pushl(&child.args, name, start_oid, tracking_name, NULL);
@@ -634,11 +654,13 @@ void create_branches_recursively(struct repository *r, const char *name,
*/
for (i = 0; i < submodule_entry_list.entry_nr; i++) {
if (submodule_entry_list.entries[i].repo == NULL) {
+ int code = die_message(
+ _("submodule '%s': unable to find submodule"),
+ submodule_entry_list.entries[i].submodule->name);
if (advice_enabled(ADVICE_SUBMODULES_NOT_UPDATED))
advise(_("You may try updating the submodules using 'git checkout %s && git submodule update --init'"),
start_commitish);
- die(_("submodule '%s': unable to find submodule"),
- submodule_entry_list.entries[i].submodule->name);
+ exit(code);
}
if (submodule_create_branch(
@@ -663,7 +685,8 @@ void create_branches_recursively(struct repository *r, const char *name,
* tedious to determine whether or not tracking was set up in the
* superproject.
*/
- setup_tracking(name, tracking_name, track, quiet);
+ if (track)
+ setup_tracking(name, tracking_name, track, quiet);
for (i = 0; i < submodule_entry_list.entry_nr; i++) {
if (submodule_create_branch(