@matheusbsbs / matheus-bagliano / commits / a0919ced8a
Fork 0

Avoid "diff-index --cached" optimization under --find-copies-harder

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>

Junio C Hamano committed May 22, 2009 at 23:14 UTC a0919ced8a5efe938cf97c74a0f851cbbe00aaf6
2 files changed +8 -2
diff-lib.c
+3 -2
@@ -446,7 +446,8 @@ int run_diff_index(struct rev_info *revs, int cached)
446 memset(&opts, 0, sizeof(opts));
447 opts.head_idx = 1;
448 opts.index_only = cached;
449 - opts.diff_index_cached = cached;
449 + opts.diff_index_cached = (cached &&
450 + !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER));
451 opts.merge = 1;
452 opts.fn = oneway_diff;
453 opts.unpack_data = revs;
@@ -503,7 +504,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
504 memset(&opts, 0, sizeof(opts));
505 opts.head_idx = 1;
506 opts.index_only = 1;
506 - opts.diff_index_cached = 1;
507 + opts.diff_index_cached = !DIFF_OPT_TST(opt, FIND_COPIES_HARDER);
508 opts.merge = 1;
509 opts.fn = oneway_diff;
510 opts.unpack_data = &revs;
t/t4007-rename-3.sh
+5
@@ -35,6 +35,11 @@ test_expect_success 'copy detection' '
35 compare_diff_raw current expected
36 '
37
38 +test_expect_success 'copy detection, cached' '
39 + git diff-index -C --find-copies-harder --cached $tree >current &&
40 + compare_diff_raw current expected
41 +'
42 +
43 # In the tree, there is only path0/COPYING. In the cache, path0 and
44 # path1 both have COPYING and the latter is a copy of path0/COPYING.
45 # However when we say we care only about path1, we should just see