diffcore-rename: compute basenames of source and dest candidates
commita35df3371c2e2e9b407ff8c950169e74f6bf4add
authorElijah Newren <newren@gmail.com>
Sun, 14 Feb 2021 07:51:47 +0000 (14 07:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Feb 2021 02:02:16 +0000 (15 18:02 -0800)
tree1fcbc5f408994502d22a84697e22ea44ae0010aa
parentf3845257a55aa5c949ce2543d53fe1f28b5072df
diffcore-rename: compute basenames of source and dest candidates

We want to make use of unique basenames among remaining source and
destination files to help inform rename detection, so that more likely
pairings can be checked first.  (src/moduleA/foo.txt and
source/module/A/foo.txt are likely related if there are no other
'foo.txt' files among the remaining deleted and added files.)  Add a new
function, not yet used, which creates a map of the unique basenames
within rename_src and another within rename_dst, together with the
indices within rename_src/rename_dst where those basenames show up.
Non-unique basenames still show up in the map, but have an invalid index
(-1).

This function was inspired by the fact that in real world repositories,
files are often moved across directories without changing names.  Here
are some sample repositories and the percentage of their historical
renames (as of early 2020) that preserved basenames:
  * linux: 76%
  * gcc: 64%
  * gecko: 79%
  * webkit: 89%
These statistics alone don't prove that an optimization in this area
will help or how much it will help, since there are also unpaired adds
and deletes, restrictions on which basenames we consider, etc., but it
certainly motivated the idea to try something in this area.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-rename.c