Documentation/technical: describe remembering renames optimization
authorElijah Newren <newren@gmail.com>
Thu, 20 May 2021 06:09:30 +0000 (06:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 May 2021 06:40:39 +0000 (15:40 +0900)
commitbb80333c0853b04ff789de8037bef5a4ade1da8c
tree245bd1873182bb57afaa2ee30be4fdf7650f39b6
parent15f3e1e05683ce710f22d9b1ef0f6b849f1d4b36
Documentation/technical: describe remembering renames optimization

Remembering renames on the upstream side of history in an early merge of
a rebase or cherry-pick for re-use in a latter merge of the same
operation makes pretty good intuitive sense.  However, trying to show
that it doesn't cause some subtle behavioral difference or some funny
edge or corner case is much more involved.  And, in fact, it does
introduce a subtle behavioral change.

Document all the assumptions, special cases, and logic involved in such
an optimization, and describe why this optimization is safe under the
current optimizations/features/etc. -- even when the subtle behavioral
change is triggered.

Part of the point of adding this document that goes over the
optimization in such laborious detail, is that it is possible that
significant future changes (optimizations or feature changes) could
interact with this optimization in interesting ways; this document is
here to help folks making big changes sanity check that the assumptions
and arguments underlying this optimization are still valid.  (As a side
note, creating this document forced me to review things in sufficient
detail that I found I was not properly caching directory-rename-induced
renames, resulting in the code not being aware of those renames and
causing unnecessary diffcore_rename_extended() calls in subsequent
merges.)

A subsequent commit will add several testcases based on this document
meant to stress-test the implementation and also document the case with
the subtle behavioral change.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/remembering-renames.txt [new file with mode: 0644]