{"thread":{"id":"37014","subject":"[PATCH 2/3] test-dump-cache-tree: Improve output format and exit code","startedAt":"2014-06-28T00:20:54Z","lastAt":"2014-06-30T18:13:22Z","messageCount":7,"participants":["David Turner","Duy Nguyen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"245106","messageId":"1403914856-3546-1-git-send-email-dturner@twitter.com","threadId":"37014","inReplyTo":null,"subject":"[PATCH 1/3] cache-tree: Create/update cache-tree on checkout","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2014-06-28T00:20:54Z","receivedAt":"2014-06-28T00:20:54Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"When git checkout checks out a branch, create or update the\ncache-tree so that subsequent operations are faster.\n\nSigned-off-by: David Turner <dturner@twitter.com>\n---\n builtin/checkout.c    |  4 ++++\n cache-tree.c          | 22 ++++++++++++----------\n cache-tree.h          |  1 +\n t/t0090-cache-tree.sh | 15 ++++++++++++++-\n 4 files changed, 31 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 07cf555..df791e8 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -553,6 +553,10 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t}\n \t}\n \n+\tif (write_cache_as_tree(NULL, WRITE_TREE_DO_NOT_WRITE, \"\")) {\n+\t\twarn(\"Unable to write cache_tree\");\n+\t}\n+\n \tif (write_cache(newfd, active_cache, active_nr) ||\n \t    commit_locked_index(lock_file))\n \t\tdie(_(\"unable to write new index file\"));\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 7fa524a..fb203c6 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -568,17 +568,18 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat\n \n int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)\n {\n-\tint entries, was_valid, newfd;\n+\tint entries, was_valid, newfd = -1;\n \tstruct lock_file *lock_file;\n \n-\t/*\n-\t * We can't free this memory, it becomes part of a linked list\n-\t * parsed atexit()\n-\t */\n-\tlock_file = xcalloc(1, sizeof(struct lock_file));\n-\n-\tnewfd = hold_locked_index(lock_file, 1);\n+\tif (!(flags & WRITE_TREE_DO_NOT_WRITE)) {\n+\t\t/*\n+\t\t * We can't free this memory, it becomes part of a linked list\n+\t\t * parsed atexit()\n+\t\t */\n+\t\tlock_file = xcalloc(1, sizeof(struct lock_file));\n \n+\t\tnewfd = hold_locked_index(lock_file, 1);\n+\t}\n \tentries = read_cache();\n \tif (entries < 0)\n \t\treturn WRITE_TREE_UNREADABLE_INDEX;\n@@ -612,9 +613,10 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)\n \t\t\tcache_tree_find(active_cache_tree, prefix);\n \t\tif (!subtree)\n \t\t\treturn WRITE_TREE_PREFIX_ERROR;\n-\t\thashcpy(sha1, subtree->sha1);\n+\t\tif (sha1)\n+\t\t\thashcpy(sha1, subtree->sha1);\n \t}\n-\telse\n+\telse if (sha1)\n \t\thashcpy(sha1, active_cache_tree->sha1);\n \n \tif (0 <= newfd)\ndiff --git a/cache-tree.h b/cache-tree.h\nindex f1923ad..daf6640 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -39,6 +39,7 @@ int update_main_cache_tree(int);\n #define WRITE_TREE_IGNORE_CACHE_TREE 2\n #define WRITE_TREE_DRY_RUN 4\n #define WRITE_TREE_SILENT 8\n+#define WRITE_TREE_DO_NOT_WRITE 16\n \n /* error return codes */\n #define WRITE_TREE_UNREADABLE_INDEX (-1)\ndiff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh\nindex 6c33e28..7c60675 100755\n--- a/t/t0090-cache-tree.sh\n+++ b/t/t0090-cache-tree.sh\n@@ -85,9 +85,22 @@ test_expect_success 'reset --hard without index gives cache-tree' '\n \ttest_shallow_cache_tree\n '\n \n-test_expect_failure 'checkout gives cache-tree' '\n+test_expect_success 'checkout gives cache-tree' '\n+\tgit tag current\n \tgit checkout HEAD^ &&\n \ttest_shallow_cache_tree\n '\n \n+test_expect_success 'checkout -b gives cache-tree' '\n+\tgit checkout current &&\n+\tgit checkout -b prev HEAD^ &&\n+\ttest_shallow_cache_tree\n+'\n+\n+test_expect_success 'checkout -B gives cache-tree' '\n+\tgit checkout current &&\n+\tgit checkout -B prev HEAD^ &&\n+\ttest_shallow_cache_tree\n+'\n+\n test_done\n-- \n2.0.0.390.gcb682f8\n"},{"id":"245104","messageId":"1403914856-3546-2-git-send-email-dturner@twitter.com","threadId":"37014","inReplyTo":"1403914856-3546-1-git-send-email-dturner@twitter.com","subject":"[PATCH 2/3] test-dump-cache-tree: Improve output format and exit code","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2014-06-28T00:20:55Z","receivedAt":"2014-06-28T00:20:55Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"Make test-dump-cache-tree more useful for testing.  Do not treat known\ninvalid trees as errors (and do not produce non-zero exit code),\nbecause we can fall back to the non-cache-tree codepath.\n\nSigned-off-by: David Turner <dturner@twitter.com>\n---\n t/t0090-cache-tree.sh  | 28 +++++++++++++++++++++++++---\n test-dump-cache-tree.c | 24 ++++++++++++------------\n 2 files changed, 37 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh\nindex 7c60675..5383258 100755\n--- a/t/t0090-cache-tree.sh\n+++ b/t/t0090-cache-tree.sh\n@@ -21,10 +21,13 @@ test_shallow_cache_tree () {\n \tcmp_cache_tree expect\n }\n \n+# Test that the cache-tree for a given directory is invalid.\n+# If no directory is given, check that the root is invalid\n test_invalid_cache_tree () {\n-\techo \"invalid                                   (0 subtrees)\" >expect &&\n-\tprintf \"SHA #(ref)  (%d entries, 0 subtrees)\\n\" $(git ls-files|wc -l) >>expect &&\n-\tcmp_cache_tree expect\n+\ttest-dump-cache-tree >actual &&\n+\tsed -e \"s/$_x40/SHA/\" -e \"s/[0-9]* subtrees//g\" <actual >filtered &&\n+\texpect=$(printf \"invalid                                  $1 ()\\n\") &&\n+\tfgrep \"$expect\" filtered\n }\n \n test_no_cache_tree () {\n@@ -49,6 +52,25 @@ test_expect_success 'git-add invalidates cache-tree' '\n \ttest_invalid_cache_tree\n '\n \n+test_expect_success 'git-add in subdir invalidates cache-tree' '\n+\ttest_when_finished \"git reset --hard; git read-tree HEAD\" &&\n+\tmkdir dirx &&\n+\techo \"I changed this file\" > dirx/foo &&\n+\tgit add dirx/foo &&\n+\ttest_invalid_cache_tree\n+'\n+\n+test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' '\n+\tgit tag no-children\n+\ttest_when_finished \"git reset --hard no-children; git read-tree HEAD\" &&\n+\tmkdir dir1 dir2 &&\n+\ttest_commit dir1/a &&\n+\ttest_commit dir2/b &&\n+\techo \"I changed this file\" > dir1/a &&\n+\tgit add dir1/a &&\n+\ttest_invalid_cache_tree dir1/\n+'\n+\n test_expect_success 'update-index invalidates cache-tree' '\n \ttest_when_finished \"git reset --hard; git read-tree HEAD\" &&\n \techo \"I changed this file\" > foo &&\ndiff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c\nindex 47eab97..ad42ca1 100644\n--- a/test-dump-cache-tree.c\n+++ b/test-dump-cache-tree.c\n@@ -6,12 +6,12 @@\n static void dump_one(struct cache_tree *it, const char *pfx, const char *x)\n {\n \tif (it->entry_count < 0)\n-\t\tprintf(\"%-40s %s%s (%d subtrees)\\n\",\n-\t\t       \"invalid\", x, pfx, it->subtree_nr);\n+\t\tprintf(\"%-40s %s (%d subtrees)%s\\n\",\n+\t\t       \"invalid\", pfx, it->subtree_nr, x);\n \telse\n-\t\tprintf(\"%s %s%s (%d entries, %d subtrees)\\n\",\n-\t\t       sha1_to_hex(it->sha1), x, pfx,\n-\t\t       it->entry_count, it->subtree_nr);\n+\t\tprintf(\"%s %s (%d entries, %d subtrees)%s\\n\",\n+\t\t       sha1_to_hex(it->sha1), pfx,\n+\t\t       it->entry_count, it->subtree_nr, x);\n }\n \n static int dump_cache_tree(struct cache_tree *it,\n@@ -25,19 +25,19 @@ static int dump_cache_tree(struct cache_tree *it,\n \t\t/* missing in either */\n \t\treturn 0;\n \n-\tif (it->entry_count < 0) {\n+\tif (it->entry_count < 0)\n+\t\t/* invalid */\n \t\tdump_one(it, pfx, \"\");\n-\t\tdump_one(ref, pfx, \"#(ref) \");\n-\t\tif (it->subtree_nr != ref->subtree_nr)\n-\t\t\terrs = 1;\n-\t}\n \telse {\n-\t\tdump_one(it, pfx, \"\");\n \t\tif (hashcmp(it->sha1, ref->sha1) ||\n \t\t    ref->entry_count != it->entry_count ||\n \t\t    ref->subtree_nr != it->subtree_nr) {\n-\t\t\tdump_one(ref, pfx, \"#(ref) \");\n+\t\t\t/* claims to be valid but is lying */\n+\t\t\tdump_one(ref, pfx, \" #(error)\");\n \t\t\terrs = 1;\n+\t\t} else {\n+\t\t\t/* is actually valid */\n+\t\t\tdump_one(it, pfx, \"\");\n \t\t}\n \t}\n \n-- \n2.0.0.390.gcb682f8\n"},{"id":"245105","messageId":"1403914856-3546-3-git-send-email-dturner@twitter.com","threadId":"37014","inReplyTo":"1403914856-3546-1-git-send-email-dturner@twitter.com","subject":"[PATCH 3/3] cache-tree: Write index with updated cache-tree after commit","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2014-06-28T00:20:56Z","receivedAt":"2014-06-28T00:20:56Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"During the commit process, the cache-tree is updated. We need to write\nthis updated cache-tree so that it's ready for subsequent commands.\n\nAdd test code which demonstrates that git commit now writes the cache\ntree.  Also demonstrate that  cache-tree invalidation is correct.\n\nSigned-off-by: David Turner <dturner@twitter.com>\n---\n builtin/commit.c      |  6 ++++++\n t/t0090-cache-tree.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++---\n 2 files changed, 53 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9cfef6c..6814e87 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -607,6 +607,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \tconst char *hook_arg2 = NULL;\n \tint clean_message_contents = (cleanup_mode != CLEANUP_NONE);\n \tint old_display_comment_prefix;\n+\tstatic struct lock_file index_lock;\n+\tint index_fd;\n \n \t/* This checks and barfs if author is badly specified */\n \tdetermine_author_info(author_ident);\n@@ -872,6 +874,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\terror(_(\"Error building trees\"));\n \t\treturn 0;\n \t}\n+\t/* After updating the cache-tree, rewrite the index */\n+\tindex_fd = hold_locked_index(&index_lock, 0);\n+\tif (index_fd >= 0 && write_index(&the_index, index_fd) >= 0)\n+\t\tcommit_locked_index(&index_lock);\n \n \tif (run_commit_hook(use_editor, index_file, \"prepare-commit-msg\",\n \t\t\t    git_path(commit_editmsg), hook_arg1, hook_arg2, NULL))\ndiff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh\nindex 5383258..ef012b9 100755\n--- a/t/t0090-cache-tree.sh\n+++ b/t/t0090-cache-tree.sh\n@@ -16,8 +16,31 @@ cmp_cache_tree () {\n # We don't bother with actually checking the SHA1:\n # test-dump-cache-tree already verifies that all existing data is\n # correct.\n+generate_expected_cache_tree () {\n+\tif [ -n \"$1\" ]\n+\tthen\n+\t\tlocal dir=\"$1/\"\n+\telse\n+\t\tlocal dir=\"$1\"\n+\tfi\n+\t# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux\n+\t# We want to count only foo because it's the only direct child\n+\tlocal subtrees=$(git ls-files|egrep '/' |cut -d / -f 1|uniq) &&\n+\tlocal subtree_count=$(echo \"$subtrees\"|grep -c .) &&\n+\tlocal files_count=$(git ls-files|grep -v /|wc -l) &&\n+\tlocal entries=$(expr \"$subtree_count\" + \"$files_count\") &&\n+\tprintf \"SHA $dir (%d entries, %d subtrees)\\n\" $entries $subtree_count &&\n+\tlocal subtree &&\n+\tfor subtree in $subtrees\n+\tdo\n+\t    cd \"$subtree\"\n+\t    generate_expected_cache_tree \"$dir$subtree\" || return 1\n+\t    cd ..\n+\tdone\n+}\n+\n test_shallow_cache_tree () {\n-\tprintf \"SHA  (%d entries, 0 subtrees)\\n\" $(git ls-files|wc -l) >expect &&\n+\tgenerate_expected_cache_tree > expect &&\n \tcmp_cache_tree expect\n }\n \n@@ -35,7 +58,7 @@ test_no_cache_tree () {\n \tcmp_cache_tree expect\n }\n \n-test_expect_failure 'initial commit has cache-tree' '\n+test_expect_success 'initial commit has cache-tree' '\n \ttest_commit foo &&\n \ttest_shallow_cache_tree\n '\n@@ -60,15 +83,28 @@ test_expect_success 'git-add in subdir invalidates cache-tree' '\n \ttest_invalid_cache_tree\n '\n \n+cat >before <<\\EOF\n+SHA  (3 entries, 2 subtrees)\n+SHA dir1/ (1 entries, 0 subtrees)\n+SHA dir2/ (1 entries, 0 subtrees)\n+EOF\n+\n+cat >expect <<\\EOF\n+invalid                                   (2 subtrees)\n+invalid                                  dir1/ (0 subtrees)\n+SHA dir2/ (1 entries, 0 subtrees)\n+EOF\n+\n test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' '\n \tgit tag no-children\n \ttest_when_finished \"git reset --hard no-children; git read-tree HEAD\" &&\n \tmkdir dir1 dir2 &&\n \ttest_commit dir1/a &&\n \ttest_commit dir2/b &&\n+\tcmp_cache_tree before &&\n \techo \"I changed this file\" > dir1/a &&\n \tgit add dir1/a &&\n-\ttest_invalid_cache_tree dir1/\n+\tcmp_cache_tree expect\n '\n \n test_expect_success 'update-index invalidates cache-tree' '\n@@ -95,6 +131,14 @@ test_expect_success 'second commit has cache-tree' '\n \ttest_shallow_cache_tree\n '\n \n+test_expect_success 'commit in child dir has cache-tree' '\n+\tmkdir dir &&\n+\t>dir/child.t &&\n+\tgit add dir/child.t &&\n+\tgit commit -m dir/child.t\n+\ttest_shallow_cache_tree\n+'\n+\n test_expect_success 'reset --hard gives cache-tree' '\n \ttest-scrap-cache-tree &&\n \tgit reset --hard &&\n-- \n2.0.0.390.gcb682f8\n"},{"id":"245145","messageId":"CACsJy8D8687QULRBZF_hvwASxOy5ekuPJ997xLSDX6HXDXgZnA@mail.gmail.com","threadId":"37014","inReplyTo":"1403914856-3546-1-git-send-email-dturner@twitter.com","subject":"Re: [PATCH 1/3] cache-tree: Create/update cache-tree on checkout","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-06-29T03:33:45Z","receivedAt":"2014-06-29T03:33:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jun 28, 2014 at 7:20 AM, David Turner <dturner@twopensource.com> wrote:\n> When git checkout checks out a branch, create or update the\n> cache-tree so that subsequent operations are faster.\n>\n> Signed-off-by: David Turner <dturner@twitter.com>\n> ---\n>  builtin/checkout.c    |  4 ++++\n>  cache-tree.c          | 22 ++++++++++++----------\n>  cache-tree.h          |  1 +\n>  t/t0090-cache-tree.sh | 15 ++++++++++++++-\n>  4 files changed, 31 insertions(+), 11 deletions(-)\n>\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 07cf555..df791e8 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -553,6 +553,10 @@ static int merge_working_tree(const struct checkout_opts *opts,\n>                 }\n>         }\n>\n> +       if (write_cache_as_tree(NULL, WRITE_TREE_DO_NOT_WRITE, \"\")) {\n> +               warn(\"Unable to write cache_tree\");\n> +       }\n> +\n\nI wonder if we should do this in !opts->force code path only. In the\nopts->force code path we could use prime_cache_tree() (like\nread-tree), which is supposedly faster (but may need some tests to be\nsure). prime_cache_tree() could be made a bit faster by doing it\nduring tree traversal in unpack_trees() so we don't have to unpack any\ntree objects twice.\n-- \nDuy\n"},{"id":"245169","messageId":"xmqqvbrizz63.fsf@gitster.dls.corp.google.com","threadId":"37014","inReplyTo":"1403914856-3546-1-git-send-email-dturner@twitter.com","subject":"Re: [PATCH 1/3] cache-tree: Create/update cache-tree on checkout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-30T06:31:16Z","receivedAt":"2014-06-30T06:31:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Turner <dturner@twopensource.com> writes:\n\n> When git checkout checks out a branch, create or update the\n> cache-tree so that subsequent operations are faster.\n>\n> Signed-off-by: David Turner <dturner@twitter.com>\n> ---\n>  builtin/checkout.c    |  4 ++++\n>  cache-tree.c          | 22 ++++++++++++----------\n>  cache-tree.h          |  1 +\n>  t/t0090-cache-tree.sh | 15 ++++++++++++++-\n>  4 files changed, 31 insertions(+), 11 deletions(-)\n>\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 07cf555..df791e8 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -553,6 +553,10 @@ static int merge_working_tree(const struct checkout_opts *opts,\n>  \t\t}\n>  \t}\n>  \n> +\tif (write_cache_as_tree(NULL, WRITE_TREE_DO_NOT_WRITE, \"\")) {\n> +\t\twarn(\"Unable to write cache_tree\");\n> +\t}\n> +\n\nThis is not even warn-worthy event, isn't it?  \"checkout -m other\"\nwould attempt a three-way merge to replay your local changes\nrelative to your current HEAD in the context of \"other\" branch and\nwill leave conflicts in the index and in the working tree, and it is\nperfectly a normal thing that you cannot write the index in such a\nstate as a tree object.  Perhaps you should check if the index is\nunmerged before even attempting to compute the cache tree.\n\nAlso it looks very strange that write-cache-as-tree, whose *PRIMARY*\nfunction is to write a tree, receives a \"DO NOT WRITE\" option here.\nI understand that you want a new interface into the cache-tree\nsubsystem that only updates the cache-tree but it somehow smells\nlike a sloppy/lazy refactoring that is not done quite right.\n"},{"id":"245211","messageId":"xmqqegy6z2t0.fsf@gitster.dls.corp.google.com","threadId":"37014","inReplyTo":"1403914856-3546-3-git-send-email-dturner@twitter.com","subject":"Re: [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-30T18:10:19Z","receivedAt":"2014-06-30T18:10:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Turner <dturner@twopensource.com> writes:\n\n> During the commit process, the cache-tree is updated. We need to write\n> this updated cache-tree so that it's ready for subsequent commands.\n>\n> Add test code which demonstrates that git commit now writes the cache\n> tree.  Also demonstrate that  cache-tree invalidation is correct.\n>\n> Signed-off-by: David Turner <dturner@twitter.com>\n> ---\n>  builtin/commit.c      |  6 ++++++\n>  t/t0090-cache-tree.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++---\n>  2 files changed, 53 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index 9cfef6c..6814e87 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -607,6 +607,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \tconst char *hook_arg2 = NULL;\n>  \tint clean_message_contents = (cleanup_mode != CLEANUP_NONE);\n>  \tint old_display_comment_prefix;\n> +\tstatic struct lock_file index_lock;\n> +\tint index_fd;\n>  \n>  \t/* This checks and barfs if author is badly specified */\n>  \tdetermine_author_info(author_ident);\n> @@ -872,6 +874,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \t\terror(_(\"Error building trees\"));\n>  \t\treturn 0;\n>  \t}\n> +\t/* After updating the cache-tree, rewrite the index */\n> +\tindex_fd = hold_locked_index(&index_lock, 0);\n> +\tif (index_fd >= 0 && write_index(&the_index, index_fd) >= 0)\n> +\t\tcommit_locked_index(&index_lock);\n\nIs this run unconditionally even when we are making a partial commit\nout of a temporary index file (which will be discarded after we\ncreate this commit)?\n\nI have a feeling that a better place to populate the cache-tree may\nbe prepare-index which knows the distinction between various modes\nof commit, but I haven't looked at the code path for a while...\n"},{"id":"245212","messageId":"xmqqa98uz2nx.fsf@gitster.dls.corp.google.com","threadId":"37014","inReplyTo":"CACsJy8D8687QULRBZF_hvwASxOy5ekuPJ997xLSDX6HXDXgZnA@mail.gmail.com","subject":"Re: [PATCH 1/3] cache-tree: Create/update cache-tree on checkout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-30T18:13:22Z","receivedAt":"2014-06-30T18:13:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> I wonder if we should do this in !opts->force code path only. In the\n> opts->force code path we could use prime_cache_tree() (like\n> read-tree), which is supposedly faster...\n\nNobody sane should be constantly running \"checkout -f\", so even if\npriming from existing tree objects were faster, it would be adding\ncomplexity to the code to optimize for a wrong case.\n"}]}