git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 5/5] Avoid "diff-index --cached" optimization under --find-copies-harder
Date: Sat, 23 May 2009 12:24:38 -0700	[thread overview]
Message-ID: <1243106678-6343-6-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1243106678-6343-5-git-send-email-gitster@pobox.com>

When find-copies-harder is in effect, the diff frontends are expected to
feed all paths, not just changed paths, to the diffcore, so that copy
sources can be picked up.  In such a case, not descending into subtrees
using the cache-tree information is simply wrong.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff-lib.c          |    5 +++--
 t/t4007-rename-3.sh |    5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 1cb97af..ae75eac 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -446,7 +446,8 @@ int run_diff_index(struct rev_info *revs, int cached)
 	memset(&opts, 0, sizeof(opts));
 	opts.head_idx = 1;
 	opts.index_only = cached;
-	opts.diff_index_cached = cached;
+	opts.diff_index_cached = (cached &&
+				  !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER));
 	opts.merge = 1;
 	opts.fn = oneway_diff;
 	opts.unpack_data = revs;
@@ -503,7 +504,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
 	memset(&opts, 0, sizeof(opts));
 	opts.head_idx = 1;
 	opts.index_only = 1;
-	opts.diff_index_cached = 1;
+	opts.diff_index_cached = !DIFF_OPT_TST(opt, FIND_COPIES_HARDER);
 	opts.merge = 1;
 	opts.fn = oneway_diff;
 	opts.unpack_data = &revs;
diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh
index 25e7a83..11502b7 100755
--- a/t/t4007-rename-3.sh
+++ b/t/t4007-rename-3.sh
@@ -35,6 +35,11 @@ test_expect_success 'copy detection' '
 	compare_diff_raw current expected
 '
 
+test_expect_success 'copy detection, cached' '
+	git diff-index -C --find-copies-harder --cached $tree >current &&
+	compare_diff_raw current expected
+'
+
 # In the tree, there is only path0/COPYING.  In the cache, path0 and
 # path1 both have COPYING and the latter is a copy of path0/COPYING.
 # However when we say we care only about path1, we should just see
-- 
1.6.3.1.145.gb74d77

  reply	other threads:[~2009-05-23 19:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-23 19:24 [PATCH 0/5] Speeding up "git status" and "git diff --cached" Junio C Hamano
2009-05-23 19:24 ` [PATCH 1/5] write-tree --ignore-cache-tree Junio C Hamano
2009-05-23 19:24   ` [PATCH 2/5] cache-tree.c::cache_tree_find(): simplify inernal API Junio C Hamano
2009-05-23 19:24     ` [PATCH 3/5] t4007: modernize the style Junio C Hamano
2009-05-23 19:24       ` [PATCH 4/5] Optimize "diff-index --cached" using cache-tree Junio C Hamano
2009-05-23 19:24         ` Junio C Hamano [this message]
2009-05-25 10:59 ` [PATCH 0/5] Speeding up "git status" and "git diff --cached" 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=1243106678-6343-6-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).