Skip to content

Commit 6696601

Browse files
chooglengitster
authored andcommitted
branch.c: simplify advice-and-die sequence
In the dwim_branch_start(), when we cannot find an appropriate upstream, we will die with the same message anyway, whether we issue an advice message. Flip the code around a bit and simplify the flow using advise_if_enabled() function. Helped-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f88828 commit 6696601

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

branch.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,10 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
383383
real_ref = NULL;
384384
if (get_oid_mb(start_name, &oid)) {
385385
if (explicit_tracking) {
386-
if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
387-
int code = die_message(_(upstream_missing),
388-
start_name);
389-
advise(_(upstream_advice));
390-
exit(code);
391-
}
392-
die(_(upstream_missing), start_name);
386+
int code = die_message(_(upstream_missing), start_name);
387+
advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
388+
_(upstream_advice));
389+
exit(code);
393390
}
394391
die(_("Not a valid object name: '%s'."), start_name);
395392
}

0 commit comments

Comments
 (0)