Skip to content

Commit

Permalink
branch --set-upstream-to: be consistent when advising
Browse files Browse the repository at this point in the history
"git branch --set-upstream-to" behaves differently when advice is
enabled/disabled:

|                 | error prefix | exit code |
|-----------------+--------------+-----------|
| advice enabled  | error:       |         1 |
| advice disabled | fatal:       |       128 |

Make both cases consistent by using die_message() when advice is
enabled (this was first proposed in [1]).

[1] https://lore.kernel.org/git/211210.86ee6ldwlc.gmgdl@evledraar.gmail.com

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
chooglen authored and gitster committed Mar 30, 2022
1 parent cfbda6b commit ac59c74
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
if (get_oid_mb(start_name, &oid)) {
if (explicit_tracking) {
if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
error(_(upstream_missing), start_name);
int code = die_message(_(upstream_missing),
start_name);
advise(_(upstream_advice));
exit(1);
exit(code);
}
die(_(upstream_missing), start_name);
}
Expand Down

0 comments on commit ac59c74

Please sign in to comment.