Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit f3565c0

Browse files
mhaggergitster
authored andcommitted
cmd_init_db(): when creating directories, handle errors conservatively
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0be0521 commit f3565c0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/init-db.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
515515
saved = shared_repository;
516516
shared_repository = 0;
517517
switch (safe_create_leading_directories_const(argv[0])) {
518+
case SCLD_OK:
519+
case SCLD_PERMS:
520+
break;
518521
case SCLD_EXISTS:
519522
errno = EEXIST;
520523
/* fallthru */
521-
case SCLD_FAILED:
522-
die_errno(_("cannot mkdir %s"), argv[0]);
523-
break;
524524
default:
525+
die_errno(_("cannot mkdir %s"), argv[0]);
525526
break;
526527
}
527528
shared_repository = saved;

0 commit comments

Comments
 (0)