]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tg/split-index-fixes' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)
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-build-and-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 d8b975a5715e8a5ec7c32e176958725cba61d67a,add5f9f50ac75828221b42392441d086b1df1e9d..fd755c32cf5daf91115f6f534fdd9029609ee546
+++ 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 *);
index d3a094603f030752ccb8bd49dd5d855a3a10c36c,c7aee5b9ff0ba990b9d7587404c512a6703268d4..3e23e65f9eed88d1251c9ae32cb9a24e28da8ebe
@@@ -5,11 -5,10 +5,15 @@@
  
  . ${0%/*}/lib-travisci.sh
  
 -mkdir -p $HOME/travis-cache
  ln -s $HOME/travis-cache/.prove t/.prove
 +
 +make --jobs=2
  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