Re: [PATCH v5 7/7] cache-tree: verify valid cache-tree in the test suite
- From
Elijah Newren <newren@gmail.com>
- Date
- Aug 18, 2018, 21:45 UTC
- Message-ID
- <CABPp-BGn_BauwEGuHBR92CBQ-sOuS_tDwW5uDdmjrqpF2jxwxA@mail.gmail.com>
- In-Reply-To
- <20180818144128.19361-8-pclouds@gmail.com>
On Sat, Aug 18, 2018 at 7:41 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote: ...
Show 46 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index 5ce40f39b3..41f313bc9e 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -2744,6 +2744,9 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
> int new_shared_index, ret;
> struct split_index *si = istate->split_index;
>
> + if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
> + cache_tree_verify(istate);
> +
> if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
> if (flags & COMMIT_LOCK)
> rollback_lock_file(lock);
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 78f7097746..5b50f6e2e6 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -1083,6 +1083,12 @@ else
> test_set_prereq C_LOCALE_OUTPUT
> fi
>
> +if test -z "$GIT_TEST_CHECK_CACHE_TREE"
> +then
> + GIT_TEST_CHECK_CACHE_TREE=true
> + export GIT_TEST_CHECK_CACHE_TREE
> +fi
> +
> test_lazy_prereq PIPE '
> # test whether the filesystem supports FIFOs
> test_have_prereq !MINGW,!CYGWIN &&
> diff --git a/unpack-trees.c b/unpack-trees.c
> index bc43922922..3394540842 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1578,6 +1578,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
> if (o->dst_index) {
> move_index_extensions(&o->result, o->src_index);
> if (!ret) {
> + if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
> + cache_tree_verify(&o->result);
> if (!o->result.cache_tree)
> o->result.cache_tree = cache_tree();
> if (!cache_tree_fully_valid(o->result.cache_tree))
> --
> 2.18.0.1004.g6639190530Should documentation of GIT_TEST_CHECK_CACHE_TREE be added in t/README, int the "Running tests with special setups" section?