Skip to content

Commit 07c9a7f

Browse files
newrengitster
authored andcommitted
gitdiffcore doc: mention new preliminary step for rename detection
The last few patches have introduced a new preliminary step when rename detection is on but both break detection and copy detection are off. Document this new step. While we're at it, add a testcase that checks the new behavior as well. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd24aa2 commit 07c9a7f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Documentation/gitdiffcore.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,26 @@ a similarity score different from the default of 50% by giving a
168168
number after the "-M" or "-C" option (e.g. "-M8" to tell it to use
169169
8/10 = 80%).
170170

171+
Note that when rename detection is on but both copy and break
172+
detection are off, rename detection adds a preliminary step that first
173+
checks if files are moved across directories while keeping their
174+
filename the same. If there is a file added to a directory whose
175+
contents is sufficiently similar to a file with the same name that got
176+
deleted from a different directory, it will mark them as renames and
177+
exclude them from the later quadratic step (the one that pairwise
178+
compares all unmatched files to find the "best" matches, determined by
179+
the highest content similarity). So, for example, if a deleted
180+
docs/ext.txt and an added docs/config/ext.txt are similar enough, they
181+
will be marked as a rename and prevent an added docs/ext.md that may
182+
be even more similar to the deleted docs/ext.txt from being considered
183+
as the rename destination in the later step. For this reason, the
184+
preliminary "match same filename" step uses a bit higher threshold to
185+
mark a file pair as a rename and stop considering other candidates for
186+
better matches. At most, one comparison is done per file in this
187+
preliminary pass; so if there are several remaining ext.txt files
188+
throughout the directory hierarchy after exact rename detection, this
189+
preliminary step will be skipped for those files.
190+
171191
Note. When the "-C" option is used with `--find-copies-harder`
172192
option, 'git diff-{asterisk}' commands feed unmodified filepairs to
173193
diffcore mechanism as well as modified ones. This lets the copy

0 commit comments

Comments
 (0)