David Turner <[email protected]> writes:
> When git checkout checks out a branch, create or update the
> cache-tree so that subsequent operations are faster.
>
> Signed-off-by: David Turner <[email protected]>
> ---
Could you number your patches e.g. [PATCH v4 1/3] and/or summarize
below the three-dash line what got updated since the last round?
The readers can guess without when one is sending a reroll every
other day or less frequently, but with rerolls more often than that,
it gets unwieldy to check which points raised during the review have
been addressed.
Thanks.
> builtin/checkout.c | 8 ++++++++
> cache-tree.c | 5 +++--
> t/t0090-cache-tree.sh | 19 ++++++++++++++++---
> 3 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 07cf555..a023a86 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -553,6 +553,14 @@ static int merge_working_tree(const struct checkout_opts
> *opts,
> }
> }
>
> + if (!active_cache_tree)
> + active_cache_tree = cache_tree();
> +
> + if (!cache_tree_fully_valid(active_cache_tree))
> + cache_tree_update(active_cache_tree,
> + (const struct cache_entry * const
> *)active_cache,
> + active_nr, 0);
> +
> if (write_cache(newfd, active_cache, active_nr) ||
> commit_locked_index(lock_file))
> die(_("unable to write new index file"));
> diff --git a/cache-tree.c b/cache-tree.c
> index 7fa524a..28d2356 100644
> --- a/cache-tree.c
> +++ b/cache-tree.c
> @@ -612,9 +612,10 @@ int write_cache_as_tree(unsigned char *sha1, int flags,
> const char *prefix)
> cache_tree_find(active_cache_tree, prefix);
> if (!subtree)
> return WRITE_TREE_PREFIX_ERROR;
> - hashcpy(sha1, subtree->sha1);
> + if (sha1)
> + hashcpy(sha1, subtree->sha1);
> }
> - else
> + else if (sha1)
> hashcpy(sha1, active_cache_tree->sha1);
>
> if (0 <= newfd)
> diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
> index 6c33e28..98fb1ab 100755
> --- a/t/t0090-cache-tree.sh
> +++ b/t/t0090-cache-tree.sh
> @@ -44,14 +44,14 @@ test_expect_success 'read-tree HEAD establishes
> cache-tree' '
>
> test_expect_success 'git-add invalidates cache-tree' '
> test_when_finished "git reset --hard; git read-tree HEAD" &&
> - echo "I changed this file" > foo &&
> + echo "I changed this file" >foo &&
> git add foo &&
> test_invalid_cache_tree
> '
>
> test_expect_success 'update-index invalidates cache-tree' '
> test_when_finished "git reset --hard; git read-tree HEAD" &&
> - echo "I changed this file" > foo &&
> + echo "I changed this file" >foo &&
> git update-index --add foo &&
> test_invalid_cache_tree
> '
> @@ -85,9 +85,22 @@ test_expect_success 'reset --hard without index gives
> cache-tree' '
> test_shallow_cache_tree
> '
>
> -test_expect_failure 'checkout gives cache-tree' '
> +test_expect_success 'checkout gives cache-tree' '
> + git tag current &&
> git checkout HEAD^ &&
> test_shallow_cache_tree
> '
>
> +test_expect_success 'checkout -b gives cache-tree' '
> + git checkout current &&
> + git checkout -b prev HEAD^ &&
> + test_shallow_cache_tree
> +'
> +
> +test_expect_success 'checkout -B gives cache-tree' '
> + git checkout current &&
> + git checkout -B prev HEAD^ &&
> + test_shallow_cache_tree
> +'
> +
> test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html