Skip to content

Commit d2a79bc

Browse files
vdyegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent adedcee commit d2a79bc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

contrib/scalar/scalar.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,27 @@ static int add_or_remove_enlistment(int add)
208208

209209
static int register_dir(void)
210210
{
211-
int res = add_or_remove_enlistment(1);
211+
if (add_or_remove_enlistment(1))
212+
return error(_("could not add enlistment"));
212213

213-
if (!res)
214-
res = set_recommended_config(0);
214+
if (set_recommended_config(0))
215+
return error(_("could not set recommended config"));
215216

216-
if (!res)
217-
res = toggle_maintenance(1);
217+
if (toggle_maintenance(1))
218+
return error(_("could not turn on maintenance"));
218219

219-
return res;
220+
return 0;
220221
}
221222

222223
static int unregister_dir(void)
223224
{
224225
int res = 0;
225226

226227
if (toggle_maintenance(0))
227-
res = -1;
228+
res = error(_("could not turn off maintenance"));
228229

229230
if (add_or_remove_enlistment(0))
230-
res = -1;
231+
res = error(_("could not remove enlistment"));
231232

232233
return res;
233234
}

0 commit comments

Comments
 (0)