X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-init-db.c;h=bfdfc7b411fb463f06ba98f58c07f5e707813310;hb=f06b9f1dffa67c1d28793bdaf7b2165d3d392d35;hp=ee3911f8eef5c00eeb4868c843f2b8c5c83d688d;hpb=f3d6073e02f8ee8dc6376b0262151dbbfbbdfe7d;p=git.git diff --git a/builtin-init-db.c b/builtin-init-db.c index ee3911f8e..bfdfc7b41 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir) template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR); if (!template_dir[0]) return; + template_len = strlen(template_dir); + if (PATH_MAX <= (template_len+strlen("/config"))) + die("insanely long template path %s", template_dir); strcpy(template_path, template_dir); - template_len = strlen(template_path); if (template_path[template_len-1] != '/') { template_path[template_len++] = '/'; template_path[template_len] = 0; @@ -195,6 +197,8 @@ static int create_default_files(const char *template_path) git_config(git_default_config, NULL); is_bare_repository_cfg = init_is_bare_repository; + + /* reading existing config may have overwrote it */ if (init_shared_repository != -1) shared_repository = init_shared_repository; @@ -313,12 +317,15 @@ int init_db(const char *template_dir, unsigned int flags) * and compatibility values for PERM_GROUP and * PERM_EVERYBODY. */ - if (shared_repository == PERM_GROUP) + if (shared_repository < 0) + /* force to the mode value */ + sprintf(buf, "0%o", -shared_repository); + else if (shared_repository == PERM_GROUP) sprintf(buf, "%d", OLD_PERM_GROUP); else if (shared_repository == PERM_EVERYBODY) sprintf(buf, "%d", OLD_PERM_EVERYBODY); else - sprintf(buf, "0%o", shared_repository); + die("oops"); git_config_set("core.sharedrepository", buf); git_config_set("receive.denyNonFastforwards", "true"); } @@ -398,6 +405,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) usage(init_db_usage); } + if (init_shared_repository != -1) + shared_repository = init_shared_repository; + /* * GIT_WORK_TREE makes sense only in conjunction with GIT_DIR * without --bare. Catch the error early.