--- OLD/builtin-init-db.c Thu Jan 1 00:00:00 1970 +++ NEW/builtin-init-db.c Thu Jan 1 00:00:00 1970 @@ -46,6 +46,8 @@ * be really carefully chosen. */ safe_create_dir(path, 1); + path[baselen++] = '/'; + template[template_baselen++] = '/'; while ((de = readdir(dir)) != NULL) { struct stat st_git, st_template; int namelen; @@ -75,8 +77,6 @@ int template_baselen_sub = template_baselen + namelen; if (!subdir) die_errno("cannot opendir '%s'", template); - path[baselen_sub++] = - template[template_baselen_sub++] = '/'; path[baselen_sub] = template[template_baselen_sub] = 0; copy_templates_1(path, baselen_sub, @@ -127,10 +127,6 @@ if (PATH_MAX <= (template_len+strlen("/config"))) die("insanely long template path %s", template_dir); strcpy(template_path, template_dir); - if (template_path[template_len-1] != '/') { - template_path[template_len++] = '/'; - template_path[template_len] = 0; - } dir = opendir(template_path); if (!dir) { warning("templates not found %s", template_dir); @@ -138,7 +134,7 @@ } /* Make sure that template is from the correct vintage */ - strcpy(template_path + template_len, "config"); + strcpy(template_path + template_len, "/config"); repository_format_version = 0; git_config_from_file(check_repository_format_version, template_path, NULL); @@ -155,8 +151,6 @@ } memcpy(path, git_dir, len); - if (len && path[len - 1] != '/') - path[len++] = '/'; path[len] = 0; copy_templates_1(path, len, template_path, template_len, @@ -217,7 +211,7 @@ * Create the default symlink from ".git/HEAD" to the "master" * branch, if it does not exist yet. */ - strcpy(path + len, "HEAD"); + strcpy(path + len, "/HEAD"); reinit = (!access(path, R_OK) || readlink(path, junk, sizeof(junk)-1) != -1); if (!reinit) { @@ -230,7 +224,7 @@ git_config_set("core.repositoryformatversion", repo_version_string); path[len] = 0; - strcpy(path + len, "config"); + strcpy(path + len, "/config"); /* Check filemode trustability */ filemode = TEST_FILEMODE; @@ -259,7 +253,7 @@ if (!reinit) { /* Check if symlink is supported in the work tree */ path[len] = 0; - strcpy(path + len, "tXXXXXX"); + strcpy(path + len, "/tXXXXXX"); if (!close(xmkstemp(path)) && !unlink(path) && !symlink("testing", path) && @@ -271,7 +265,7 @@ /* Check if the filesystem is case-insensitive */ path[len] = 0; - strcpy(path + len, "CoNfIg"); + strcpy(path + len, "/CoNfIg"); if (!access(path, F_OK)) git_config_set("core.ignorecase", "true"); }