Viewing file history across renames
This entry is also about an addition in Emacs’s VC support (development branch, Emacs 30).
Git doesn’t really track renames, but supports printing the commit log
across renames using certain heuristics (seeing that a commit contains
a deleted and a created file where a big enough percentage of lines
are the same; copies are detected similarly), but this has to be
enabled explicitly (the --follow
option), and it can end up missing
commits in some situations with complex branch merging
history.
In Emacs vc-print-log
(C-x v l) likewise had problems
with renames, with multiple
reports over the
years and different approaches having been
proposed. Adding the support for --follow
helped somewhat, but the
commands to view the diff (d), or annotate/blame
(a), or check out that old version (f), stayed
broken when the version had a different file name.
This difficulty is not specific to Emacs, though, and looking around, Github has recently adopted a solution for this: adding a “show history for that name” link when the current log ends. It’s not an original invention either: it started out as a Chrome extension.
Anyway, now we also have a button that allows you to jump to the
history of the previous file name. Just make sure to set
vc-git-print-log-follow
back to its default value (nil
), to be
able to use it.
This is currently implemented for Git and Mercurial only.