File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -226,8 +226,12 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
226226 continue ;
227227 }
228228
229- if (ce_uptodate (ce ) || ce_skip_worktree (ce ))
229+ if (ce_uptodate (ce ) || ce_skip_worktree (ce )) {
230+ if (revs -> diffopt .flags .find_copies_harder )
231+ diff_same (& revs -> diffopt , ce -> ce_mode ,
232+ & ce -> oid , ce -> name );
230233 continue ;
234+ }
231235
232236 /*
233237 * When CE_VALID is set (via "update-index --assume-unchanged"
@@ -272,8 +276,10 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
272276 if (!changed && !dirty_submodule ) {
273277 ce_mark_uptodate (ce );
274278 mark_fsmonitor_valid (istate , ce );
275- if (!revs -> diffopt .flags .find_copies_harder )
276- continue ;
279+ if (revs -> diffopt .flags .find_copies_harder )
280+ diff_same (& revs -> diffopt , newmode ,
281+ & ce -> oid , ce -> name );
282+ continue ;
277283 }
278284 oldmode = ce -> ce_mode ;
279285 old_oid = & ce -> oid ;
Original file line number Diff line number Diff line change @@ -67,7 +67,28 @@ test_expect_success 'copy, limited to a subtree' '
6767'
6868
6969test_expect_success ' tweak work tree' '
70- rm -f path0/COPYING &&
70+ rm -f path0/COPYING
71+ '
72+
73+ cat > expected << EOF
74+ :100644 100644 $blob $blob C100 path1/COPYING path0/COPYING
75+ EOF
76+
77+ # The cache has path0/COPYING and path1/COPYING, the working tree only
78+ # path1/COPYING. This is a deletion -- we don't treat deduplication
79+ # specially. In reverse it should be detected as a copy, though.
80+ test_expect_success ' copy detection, files to index' '
81+ git diff-files -C --find-copies-harder -R >current &&
82+ compare_diff_raw current expected
83+ '
84+
85+ test_expect_success ' copy detection, files to preloaded index' '
86+ GIT_TEST_PRELOAD_INDEX=1 \
87+ git diff-files -C --find-copies-harder -R >current &&
88+ compare_diff_raw current expected
89+ '
90+
91+ test_expect_success ' tweak index' '
7192 git update-index --remove path0/COPYING
7293'
7394# In the tree, there is only path0/COPYING. In the cache, path0 does
You can’t perform that action at this time.
0 commit comments