branch --set-upstream-to: be consistent when advising

"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>

Glen Choo committed Mar 29, 2022 at 20:01 UTC ac59c742de5f548ed07735fb212cc87129383bcd
1 file changed +3 -2
branch.c
+3 -2
@@ -384,9 +384,10 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
384 if (get_oid_mb(start_name, &oid)) {
385 if (explicit_tracking) {
386 if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
387 - error(_(upstream_missing), start_name);
387 + int code = die_message(_(upstream_missing),
388 + start_name);
389 advise(_(upstream_advice));
389 - exit(1);
390 + exit(code);
391 }
392 die(_(upstream_missing), start_name);
393 }