aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2022-08-18 21:40:48 +0000
committerJunio C Hamano <gitster@pobox.com>2022-08-18 21:35:32 -0700
commitd2a79bc953375ed7dd8cb06fd3db92f85c64c206 (patch)
tree232a7cccbbd696866f00b7100aa64f290cd6fba2
parentscalar-unregister: handle error codes greater than 0 (diff)
downloadgit-d2a79bc953375ed7dd8cb06fd3db92f85c64c206.tar.gz
git-d2a79bc953375ed7dd8cb06fd3db92f85c64c206.zip
scalar-[un]register: clearly indicate source of error
When a step in 'register_dir()' or 'unregister_dir()' fails, indicate which step failed with an error message, rather than silently assigning a nonzero return code. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--contrib/scalar/scalar.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c
index 8ef8dd5504..7be2a938b0 100644
--- a/contrib/scalar/scalar.c
+++ b/contrib/scalar/scalar.c
@@ -208,15 +208,16 @@ static int add_or_remove_enlistment(int add)
static int register_dir(void)
{
- int res = add_or_remove_enlistment(1);
+ if (add_or_remove_enlistment(1))
+ return error(_("could not add enlistment"));
- if (!res)
- res = set_recommended_config(0);
+ if (set_recommended_config(0))
+ return error(_("could not set recommended config"));
- if (!res)
- res = toggle_maintenance(1);
+ if (toggle_maintenance(1))
+ return error(_("could not turn on maintenance"));
- return res;
+ return 0;
}
static int unregister_dir(void)
@@ -224,10 +225,10 @@ static int unregister_dir(void)
int res = 0;
if (toggle_maintenance(0))
- res = -1;
+ res = error(_("could not turn off maintenance"));
if (add_or_remove_enlistment(0))
- res = -1;
+ res = error(_("could not remove enlistment"));
return res;
}