Replace exit() calls in branch.c that have questionable exit codes:
* in setup_tracking(), exit(-1) was introduced in 27852b2c53 (branch:
report errors in tracking branch setup, 2016-02-22). This may have
been a mechanical typo because the same commit changes the return type
of setup_tracking() from int to void.
* in validate_branch_start(), the exit code changes depending on whether
or not advice is enabled. This behavior was not discussed
upstream (see caa2036b3b (branch: give advice when tracking
start-point is missing, 2013-04-02)).
Signed-off-by: Glen Choo <redacted>
---
I don't know what the 'correct' exit codes should be, only that Junio
makes a good case that the existing exit codes are wrong. My best,
non-prescriptive, choice is 128, to be consistent with the surrounding
code and Documentation/technical/api-error-handling.txt.
branch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/branch.c b/branch.c
index 305154de0b..ad70ddd120 100644
--- a/branch.c
+++ b/branch.c
@@ -324,7 +324,7 @@ static void validate_branch_start(struct repository *r, const char *start_name,
if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
error(_(upstream_missing), start_name);
advise(_(upstream_advice));
- exit(1);
+ exit(128);
}
die(_(upstream_missing), start_name);
}@@ -398,7 +398,7 @@ void setup_tracking(const char *new_ref, const char *orig_ref,
string_list_append(tracking.srcs, full_orig_ref);
if (install_branch_config_multiple_remotes(config_flags, new_ref, tracking.remote,
tracking.srcs) < 0)
- exit(-1);
+ exit(128);
cleanup:
string_list_clear(tracking.srcs, 0);
--
2.33.GIT