safe_create_leading_directories_const() returns a non-zero value on
error.  The old code at this calling site recognized a couple of
particular error values, and treated all other return values as
success.  Instead, be more conservative: recognize the errors we are
interested in, but treat any other nonzero values as failures.  This
is more robust in case somebody adds another possible return value
without telling us.

Signed-off-by: Michael Haggerty <>
 builtin/init-db.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 6f69593..c7c76bb 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -515,13 +515,14 @@ int cmd_init_db(int argc, const char **argv, const char 
                                saved = shared_repository;
                                shared_repository = 0;
(safe_create_leading_directories_const(argv[0])) {
+                               case SCLD_OK:
+                               case SCLD_PERMS:
+                                       break;
                                case SCLD_EXISTS:
                                        errno = EEXIST;
                                        /* fallthru */
-                               case SCLD_FAILED:
-                                       die_errno(_("cannot mkdir %s"), 
-                                       break;
+                                       die_errno(_("cannot mkdir %s"), 
                                shared_repository = saved;

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to