如何在gitk中添加更好的复制检测? [英] How to add better copy detection to gitk?
问题描述
在命令行Git中, show
, diff
和 log
命令可以选择-find-copies-更加
.
In command line Git, the show
, diff
and log
commands have got an option to --find-copies-harder
.
是否有一种方法可以告诉(或修补) gitk
来使用它?我不时需要这样做,而且我的项目很小,以至于我不在乎性能降低.
Is there a way I can tell (or patch) gitk
to use this, too? I need this from time to time, and my projects are small enough such that I don't care about the reduced performance.
(我不想修改历史记录以强制进行复制检测.)
我注意到-find-copies-harder
出现在gitk代码中,但我不明白为什么.因此,我尝试了命令行 gitk --all --find-copies-harder
,但是它不起作用:在提交从另一个版本文件复制的新文件的提交中,gitk仍然没有显示该文件已被复制的事实.
I noticed that the --find-copies-harder
appears within the gitk code, but I don't understand why.
So I have tried the command line gitk --all --find-copies-harder
, but it didn't work: In a commit with a new file copied from another versioned file, gitk still did not display the fact that this file was copied.
更新:在字段 git log:
的其他参数中输入-find-copies-harder
来编辑视图也无效:复制(略微复制)修改后)文件仍未显示为已复制,而在命令行 git show --find-copies-harder
中显示.
Update: Editing the view by entering --find-copies-harder
into the field Additional arguments to git log:
also has no effect: A copied (and slightly modified) file is still not shown as copied, while in the command line git show --find-copies-harder
it is.
推荐答案
必要的更改是:
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 23d9dd1fe0..a98a115080 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7909,7 +7909,7 @@ proc diffcmd {ids flags} {
if {$log_showroot} {
lappend flags --root
}
- set cmd [concat | git diff-tree -r $flags $ids]
+ set cmd [concat | git diff-tree --find-copies-harder -r $flags $ids]
}
return $cmd
}
有了这个,gitk在以下测试存储库的第二次提交中显示副本
With this, gitk displays the copy in the second commit of the following test repository
git init
echo "a file" > a
git add a
git commit -m "a file"
cp a b
git add b
git commit -m "a copy"
根据需要:
-------------------------------------- b --------------------------------------
similarity index 100%
copy from a
copy to b
但是请注意,可能会产生意想不到的副作用,因为已在多个地方调用了经过修改的过程'diffcmd'.我没有系统地测试所有这些代码路径.
But note that there might be unintended side effects, since the modified procedure 'diffcmd' is called in several places. I did not systematically test all these code paths.
(我也发送了通用版本此补丁到Git邮件列表中.)
这篇关于如何在gitk中添加更好的复制检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!