lockfile: allow reopening a closed but still locked file
[gitweb.git] / read-cache.c
index b1027f7ee02f0feca35258337a0e3d116c45c7ad..342fe52fdaf91695e1d75ea8aa73d87ac5405dfa 100644 (file)
@@ -1463,8 +1463,7 @@ static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,
 }
 
 /* remember to discard_cache() before reading a different cache! */
-static int do_read_index(struct index_state *istate, const char *path,
-                        int must_exist)
+int do_read_index(struct index_state *istate, const char *path, int must_exist)
 {
        int fd, i;
        struct stat st;
@@ -1885,8 +1884,11 @@ static int do_write_index(struct index_state *istate, int newfd,
                }
        }
 
-       if (!istate->version)
+       if (!istate->version) {
                istate->version = get_index_format_default();
+               if (getenv("GIT_TEST_SPLIT_INDEX"))
+                       init_split_index(istate);
+       }
 
        /* demote version 3 to version 2 when the latter suffices */
        if (istate->version == 3 || istate->version == 2)
@@ -2077,6 +2079,11 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
                return do_write_locked_index(istate, lock, flags);
        }
 
+       if (getenv("GIT_TEST_SPLIT_INDEX")) {
+               int v = si->base_sha1[0];
+               if ((v & 15) < 6)
+                       istate->cache_changed |= SPLIT_INDEX_ORDERED;
+       }
        if (istate->cache_changed & SPLIT_INDEX_ORDERED) {
                int ret = write_shared_index(istate, lock, flags);
                if (ret)