]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-init-db.c
log --graph --left-right: show left/right information in place of '*'
[git.git] / builtin-init-db.c
index 79eaf8d6edf18675897f6eed571289fce450526a..b061317275792ccb33eea80a5071b72ed6f8d6a7 100644 (file)
@@ -167,9 +167,9 @@ static int create_default_files(const char *git_dir, const char *template_path)
 {
        unsigned len = strlen(git_dir);
        static char path[PATH_MAX];
-       unsigned char sha1[20];
        struct stat st1;
        char repo_version_string[10];
+       char junk[2];
        int reinit;
        int filemode;
 
@@ -219,7 +219,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
         * branch, if it does not exist yet.
         */
        strcpy(path + len, "HEAD");
-       reinit = !read_ref("HEAD", sha1);
+       reinit = (!access(path, R_OK)
+                 || readlink(path, junk, sizeof(junk)-1) != -1);
        if (!reinit) {
                if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
                        exit(1);
@@ -254,8 +255,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
                        git_config_set("core.worktree", work_tree);
        }
 
-       /* Check if symlink is supported in the work tree */
        if (!reinit) {
+               /* Check if symlink is supported in the work tree */
                path[len] = 0;
                strcpy(path + len, "tXXXXXX");
                if (!close(xmkstemp(path)) &&
@@ -266,6 +267,12 @@ static int create_default_files(const char *git_dir, const char *template_path)
                        unlink(path); /* good */
                else
                        git_config_set("core.symlinks", "false");
+
+               /* Check if the filesystem is case-insensitive */
+               path[len] = 0;
+               strcpy(path + len, "CoNfIg");
+               if (!access(path, F_OK))
+                       git_config_set("core.ignorecase", "true");
        }
 
        return reinit;
@@ -399,9 +406,16 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                char buf[10];
                /* We do not spell "group" and such, so that
                 * the configuration can be read by older version
-                * of git.
+                * of git. Note, we use octal numbers for new share modes,
+                * and compatibility values for PERM_GROUP and
+                * PERM_EVERYBODY.
                 */
-               sprintf(buf, "%d", shared_repository);
+               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);
                git_config_set("core.sharedrepository", buf);
                git_config_set("receive.denyNonFastforwards", "true");
        }