Merge branch 'tg/split-index-fixes'
authorJunio C Hamano <gitster@pobox.com>
Tue, 13 Feb 2018 21:39:12 +0000 (13:39 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Feb 2018 21:39:13 +0000 (13:39 -0800)
The split-index mode had a few corner case bugs fixed.

* tg/split-index-fixes:
travis: run tests with GIT_TEST_SPLIT_INDEX
split-index: don't write cache tree with null oid entries
read-cache: fix reading the shared index for other repos

1  2 
cache-tree.c
cache.h
ci/run-tests.sh
read-cache.c
repository.c
revision.c
t/t1700-split-index.sh
diff --cc cache-tree.c
index e03e72c34a5c1fc618994ee63f38875d28d91886,e006215edc3a593fdbe31a169ed42c097430100b..0dd6292a94e55baff0a42df89c7006a757f61065
@@@ -606,9 -606,9 +606,9 @@@ int write_index_as_tree(unsigned char *
        struct lock_file lock_file = LOCK_INIT;
        int ret = 0;
  
 -      newfd = hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
 +      hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
  
-       entries = read_index_from(index_state, index_path);
+       entries = read_index_from(index_state, index_path, get_git_dir());
        if (entries < 0) {
                ret = WRITE_TREE_UNREADABLE_INDEX;
                goto out;
diff --cc cache.h
index 8cdcee544681829a409e6cb9fdf54c57a8b33b4c,add5f9f50ac75828221b42392441d086b1df1e9d..9cac7bb5185fff37e9906dd0dcad9187673c7e1f
+++ b/cache.h
@@@ -616,31 -600,13 +617,32 @@@ extern int read_index(struct index_stat
  extern int read_index_preload(struct index_state *, const struct pathspec *pathspec);
  extern int do_read_index(struct index_state *istate, const char *path,
                         int must_exist); /* for testting only! */
- extern int read_index_from(struct index_state *, const char *path);
+ extern int read_index_from(struct index_state *, const char *path,
+                          const char *gitdir);
  extern int is_index_unborn(struct index_state *);
  extern int read_index_unmerged(struct index_state *);
 +
 +/* For use with `write_locked_index()`. */
  #define COMMIT_LOCK           (1 << 0)
 -#define CLOSE_LOCK            (1 << 1)
 +
 +/*
 + * Write the index while holding an already-taken lock. Close the lock,
 + * and if `COMMIT_LOCK` is given, commit it.
 + *
 + * Unless a split index is in use, write the index into the lockfile.
 + *
 + * With a split index, write the shared index to a temporary file,
 + * adjust its permissions and rename it into place, then write the
 + * split index to the lockfile. If the temporary file for the shared
 + * index cannot be created, fall back to the behavior described in
 + * the previous paragraph.
 + *
 + * With `COMMIT_LOCK`, the lock is always committed or rolled back.
 + * Without it, the lock is closed, but neither committed nor rolled
 + * back.
 + */
  extern int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags);
 +
  extern int discard_index(struct index_state *);
  extern void move_index_extensions(struct index_state *dst, struct index_state *src);
  extern int unmerged_index(const struct index_state *);
diff --cc ci/run-tests.sh
index 22355f0091a0a3936472179249cf152d9f20fc17,c7aee5b9ff0ba990b9d7587404c512a6703268d4..9b6fedcc2a94b83f7243767915ad0327e100ef13
@@@ -5,9 -5,10 +5,13 @@@
  
  . ${0%/*}/lib-travisci.sh
  
 -mkdir -p $HOME/travis-cache
  ln -s $HOME/travis-cache/.prove t/.prove
  make --quiet test
+ if test "$jobname" = "linux-gcc"
+ then
+       GIT_TEST_SPLIT_INDEX=YesPlease make --quiet test
+ fi
 +
 +check_unignored_build_artifacts
 +
 +save_good_tree
diff --cc read-cache.c
index 2eb81a66b941325dc339d61a0ab804a60cbb8be2,5cd14e2f726489f331425ff762068bb1c184a665..d13ce83794340f36cc09596767d154952c8e42a3
@@@ -2573,12 -2521,12 +2573,15 @@@ int write_locked_index(struct index_sta
        ret = write_split_index(istate, lock, flags);
  
        /* Freshen the shared index only if the split-index was written */
-       if (!ret && !new_shared_index)
-               freshen_shared_index(sha1_to_hex(si->base_sha1), 1);
+       if (!ret && !new_shared_index) {
+               const char *shared_index = git_path("sharedindex.%s",
+                                                   sha1_to_hex(si->base_sha1));
+               freshen_shared_index(shared_index, 1);
+       }
  
 +out:
 +      if (flags & COMMIT_LOCK)
 +              rollback_lock_file(lock);
        return ret;
  }
  
diff --cc repository.c
Simple merge
diff --cc revision.c
Simple merge
Simple merge