Support --find-copies-harder in the Log window
Detecting copies from unmodified files in TortoiseGit is a longed-for feature, such as #3219 .
This merge request integrates the git option --find-copies-harder
into the Log Message window.
I don't have much experience in writing C++/MFC, so this feature is implemented as a command line option as the first step.
To Test
-
In Icon Overlays page, set Status cache to None. (may not be necessary)
-
Head to a resopitory where you know there are copy commits. For me
D:\Speak Easy>git log --find-copies --find-copies-harder --name-status
commit d4cdd85d4bed86fbec314989aff075eeab2bd3e3 (HEAD -> copy)
Author: Qiqi Gu <qiqigutg@gmail.com>
Date: Mon Aug 5 16:38:07 2024 +0800
add ep4
C085 ep3 ep4
commit 59d51a593770ba5e8b20f7c1085022691904577e
Author: Qiqi Gu <qiqigutg@gmail.com>
Date: Sat Aug 3 20:17:50 2024 +0800
finish ep3
M ep3
A ep3-30.filter
- Run command
D:\Speak Easy>D:\tortoisegit\bin\Debug64\bin\TortoiseGitProc.exe /command:log /path:"D:\Speak Easy" /findcopiesharder
Then the log window successfully picks up the copy operation from ep3 to ep4.
Design Concerns
I added LOG_INFO_FIND_COPIES_HARDER
at the end of CGit::LOG_INFO_MASK. LOG_INFO_MASK is like a bitset which only has 32 seats. I'm not sure if it's a good idea to take one of these precious seats.
LogDlg.h did not have public fields. I added m_FindCopiesHarder
so that LogCommand can pass information over. I don't know whether it is idiomatic in this project.
Limitations
There are limitations though.
-
I didn't implement the libgit2 way for
--find-copies-harder
. If users specify the/findcopiesharder
option, TortoiseGit does not call libgit2, and fall back to git.exe. Nevertheless, the current version of TortoiseGit is not using libgit2 forGIT_CMD_LOGLISTDIFF
in the first place. -
I disabled
m_LogCache.FetchCacheIndex()
if the/findcopiesharder
option is specified. The reason is that, if the cache has been created without/findcopiesharder
, a new Log window with/findcopiesharder
reads the existing cache which contains no copy information. A Log window with/findcopiesharder
does not create or modify cache (tortoisegit.data and tortoisegit.index) either. -
I did not change the GUI. I envision a checkbox on the Log window but this MR is the first step to add support for
--find-copies-harder
.
All these points lead to future work. When the community agrees on this MR, I'm very likely to work on the next step. I have a series of changes in my mind.
Anyway, please give feedback. I just started to look into this project recently and the changes I made are minimal in my opinion to bake in the feature.
Signed-off-by: Qiqi Gu qiqigutg@gmail.com