]> git.ipfire.org Git - thirdparty/git.git/commitdiff
scalar-[un]register: clearly indicate source of error
authorVictoria Dye <vdye@github.com>
Thu, 18 Aug 2022 21:40:48 +0000 (21:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Aug 2022 04:35:32 +0000 (21:35 -0700)
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>
contrib/scalar/scalar.c

index 8ef8dd55041622a26807b16c9e6c192d37f76355..7be2a938b0ce0ed21b9b51ebe68e9df3ca3e87b6 100644 (file)
@@ -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;
 }