]> git.ipfire.org Git - thirdparty/git.git/commitdiff
branch --set-upstream-to: be consistent when advising
authorGlen Choo <chooglen@google.com>
Tue, 29 Mar 2022 20:01:18 +0000 (20:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Mar 2022 21:15:54 +0000 (14:15 -0700)
"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>
branch.c

index 50459c432c0dbebf9948994c7c6711c1d3df34fe..add6a37b79b4055cba8f50b01dd8a0f0c2d7a9dd 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -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);
                }