submodule update: run at most one fetch job unless otherwise set
[gitweb.git] / read-cache.c
index 1e9c772603070722899ee88f559c51283961e3d3..bd45dc3e24d7dc28820d26cc6e6d377f92fda46d 100644 (file)
@@ -2176,7 +2176,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 
        src_offset = sizeof(*hdr);
 
-       nr_threads = git_config_get_index_threads();
+       if (git_config_get_index_threads(&nr_threads))
+               nr_threads = 1;
 
        /* TODO: does creating more threads than cores help? */
        if (!nr_threads) {
@@ -2695,7 +2696,28 @@ static int record_eoie(void)
 
        if (!git_config_get_bool("index.recordendofindexentries", &val))
                return val;
-       return 0;
+
+       /*
+        * As a convenience, the end of index entries extension
+        * used for threading is written by default if the user
+        * explicitly requested threaded index reads.
+        */
+       return !git_config_get_index_threads(&val) && val != 1;
+}
+
+static int record_ieot(void)
+{
+       int val;
+
+       if (!git_config_get_bool("index.recordoffsettable", &val))
+               return val;
+
+       /*
+        * As a convenience, the offset table used for threading is
+        * written by default if the user explicitly requested
+        * threaded index reads.
+        */
+       return !git_config_get_index_threads(&val) && val != 1;
 }
 
 /*
@@ -2756,12 +2778,10 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
        if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
                return -1;
 
-       if (HAVE_THREADS)
-               nr_threads = git_config_get_index_threads();
-       else
+       if (!HAVE_THREADS || git_config_get_index_threads(&nr_threads))
                nr_threads = 1;
 
-       if (nr_threads != 1) {
+       if (nr_threads != 1 && record_ieot()) {
                int ieot_blocks, cpus;
 
                /*
@@ -3159,7 +3179,8 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
                struct tempfile *temp;
                int saved_errno;
 
-               temp = mks_tempfile(git_path("sharedindex_XXXXXX"));
+               /* Same initial permissions as the main .git/index file */
+               temp = mks_tempfile_sm(git_path("sharedindex_XXXXXX"), 0, 0666);
                if (!temp) {
                        oidclr(&si->base_oid);
                        ret = do_write_locked_index(istate, lock, flags);