From: Thomas Rast <trast@inf.ethz.ch>
To: Jeff King <peff@peff.net>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: git status: small difference between stating whole repository and small subdirectory
Date: Mon, 20 Feb 2012 19:45:59 +0100 [thread overview]
Message-ID: <87d3991gyg.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <20120220151134.GA13135@sigill.intra.peff.net> (Jeff King's message of "Mon, 20 Feb 2012 10:11:34 -0500")
Jeff King <peff@peff.net> writes:
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 8be3f6c..e8aedea 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1135,6 +1135,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
> }
> }
>
> + o->result.cache_tree = o->src_index->cache_tree;
> o->src_index = NULL;
> ret = check_updates(o) ? (-2) : 0;
> if (o->dst_index)
Brilliant. I know I'm stealing Junio's punchline, but please make it so
:-)
Browsing around in history, it seems that this was silently broken by
34110cd (Make 'unpack_trees()' have a separate source and destination
index, 2008-03-06), which introduced the distinction between source and
destination index. Before that they were the same, so the cache tree
would have been updated correctly.
> It makes "git checkout" with no changes just work (since we preserve the
> cache tree, and it doesn't need updated). It makes something like "git
> checkout HEAD^" work, keeping most of the cache-tree intact, but
> invalidating trees containing paths that were modified.
Great. Here's a test you could use. It's a bit noisy because the
shallow in test_shallow_cache_tree no longer made any sense, but I think
it tests what we want to see.
diff --git i/t/t0090-cache-tree.sh w/t/t0090-cache-tree.sh
index 6c33e28..5706305 100755
--- i/t/t0090-cache-tree.sh
+++ w/t/t0090-cache-tree.sh
@@ -16,14 +16,16 @@ cmp_cache_tree () {
# We don't bother with actually checking the SHA1:
# test-dump-cache-tree already verifies that all existing data is
# correct.
-test_shallow_cache_tree () {
- printf "SHA (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >expect &&
+test_cache_tree () {
+ printf "SHA (%d entries, 1 subtrees)\n" $(git ls-files|wc -l) >expect &&
+ printf "SHA sub/ (%d entries, 0 subtrees)\n" $(git ls-files sub|wc -l) >>expect &&
cmp_cache_tree expect
}
test_invalid_cache_tree () {
- echo "invalid (0 subtrees)" >expect &&
- printf "SHA #(ref) (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >>expect &&
+ echo "invalid (1 subtrees)" >expect &&
+ printf "SHA #(ref) (%d entries, 1 subtrees)\n" $(git ls-files|wc -l) >>expect &&
+ printf "SHA sub/ (%d entries, 0 subtrees)\n" $(git ls-files sub|wc -l) >>expect &&
cmp_cache_tree expect
}
@@ -33,13 +35,16 @@ test_no_cache_tree () {
}
test_expect_failure 'initial commit has cache-tree' '
+ mkdir sub &&
+ echo bar > sub/bar &&
+ git add sub/bar &&
test_commit foo &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_expect_success 'read-tree HEAD establishes cache-tree' '
git read-tree HEAD &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_expect_success 'git-add invalidates cache-tree' '
@@ -59,7 +64,7 @@ test_expect_success 'update-index invalidates cache-tree' '
test_expect_success 'write-tree establishes cache-tree' '
test-scrap-cache-tree &&
git write-tree &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_expect_success 'test-scrap-cache-tree works' '
@@ -70,24 +75,39 @@ test_expect_success 'test-scrap-cache-tree works' '
test_expect_success 'second commit has cache-tree' '
test_commit bar &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_expect_success 'reset --hard gives cache-tree' '
test-scrap-cache-tree &&
git reset --hard &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_expect_success 'reset --hard without index gives cache-tree' '
rm -f .git/index &&
git reset --hard &&
- test_shallow_cache_tree
+ test_cache_tree
'
-test_expect_failure 'checkout gives cache-tree' '
+test_expect_success 'checkout HEAD leaves cache-tree intact' '
+ git read-tree HEAD &&
+ git checkout HEAD &&
+ test_cache_tree
+'
+
+# NEEDSWORK: only one of these two can succeed. The second is there
+# because it would be the better result.
+test_expect_success 'checkout HEAD^ correctly invalidates cache-tree' '
+ git checkout HEAD^ &&
+ test_invalid_cache_tree
+'
+
+test_expect_failure 'checkout HEAD^ gives full cache-tree' '
+ git checkout master &&
+ git read-tree HEAD &&
git checkout HEAD^ &&
- test_shallow_cache_tree
+ test_cache_tree
'
test_done
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2012-02-20 18:46 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 9:42 git status: small difference between stating whole repository and small subdirectory Piotr Krukowiecki
2012-02-10 12:33 ` Nguyen Thai Ngoc Duy
2012-02-10 13:46 ` Piotr Krukowiecki
2012-02-10 14:37 ` Nguyen Thai Ngoc Duy
2012-02-13 16:54 ` Piotr Krukowiecki
2012-02-10 16:18 ` Piotr Krukowiecki
2012-02-14 11:34 ` Thomas Rast
2012-02-15 8:57 ` Piotr Krukowiecki
2012-02-15 11:01 ` Nguyen Thai Ngoc Duy
2012-02-15 15:14 ` Piotr Krukowiecki
2012-02-16 13:22 ` Piotr Krukowiecki
2012-02-15 19:03 ` Jeff King
2012-02-16 13:37 ` Piotr Krukowiecki
2012-02-16 14:05 ` Thomas Rast
2012-02-16 20:15 ` Junio C Hamano
2012-02-17 16:55 ` Piotr Krukowiecki
2012-02-16 19:20 ` Jeff King
2012-02-17 17:19 ` Piotr Krukowiecki
2012-02-17 20:37 ` Jeff King
2012-02-17 22:25 ` Junio C Hamano
2012-02-17 22:29 ` Jeff King
2012-02-20 8:25 ` Piotr Krukowiecki
2012-02-20 14:06 ` Jeff King
2012-02-20 14:09 ` Thomas Rast
2012-02-20 14:36 ` Nguyen Thai Ngoc Duy
2012-02-20 14:39 ` Jeff King
2012-02-20 15:11 ` Jeff King
2012-02-20 18:45 ` Thomas Rast [this message]
2012-02-20 20:35 ` Jeff King
2012-02-20 22:04 ` Junio C Hamano
2012-02-20 22:41 ` Jeff King
2012-02-20 23:31 ` Junio C Hamano
2012-02-21 7:21 ` Piotr Krukowiecki
2012-02-20 20:08 ` Junio C Hamano
2012-02-20 20:17 ` Jeff King
2012-02-21 14:45 ` Nguyen Thai Ngoc Duy
2012-02-21 19:16 ` Junio C Hamano
2012-02-22 2:12 ` Nguyen Thai Ngoc Duy
2012-02-22 2:55 ` Junio C Hamano
2012-02-22 12:54 ` Nguyen Thai Ngoc Duy
2012-02-22 13:17 ` Thomas Rast
2012-02-22 10:34 ` Nguyen Thai Ngoc Duy
2012-02-22 3:32 ` Junio C Hamano
2012-04-10 15:16 ` Piotr Krukowiecki
2012-04-10 16:23 ` Junio C Hamano
2012-04-10 18:00 ` Jeff King
2012-02-20 19:57 ` Junio C Hamano
2012-02-20 19:59 ` Thomas Rast
2012-02-20 14:16 ` Nguyen Thai Ngoc Duy
2012-02-20 14:22 ` Jeff King
2012-02-20 19:56 ` Junio C Hamano
2012-02-20 20:09 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d3991gyg.fsf@thomas.inf.ethz.ch \
--to=trast@inf.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=piotr.krukowiecki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.