[PATCH 3/4] branch --set-upstream-to: be consistent when advising
- From
Glen Choo via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 29, 2022, 20:01 UTC
- Message-ID
- <8e6ea3478b376b24835f3a3fef7fca39bed0afec.1648584079.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1190.git.1648584079.gitgitgadget@gmail.com>
From: Glen Choo <chooglen@google.com>
"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> --- branch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/branch.c b/branch.c index 133e6047bc6..4a8796489c7 100644 --- a/branch.c +++ b/branch.c @@ -389,9 +389,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); }
-- gitgitgadget