How to add better copy detection to gitk? How to add better copy detection to gitk? shell shell

How to add better copy detection to gitk?


The necessary change is:

diff --git a/gitk-git/gitk b/gitk-git/gitkindex 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 }

With this, gitk displays the copy in the second commit of the following test repository

git initecho "a file" > agit add agit commit -m "a file"cp a bgit add bgit commit -m "a copy"

as desired:

-------------------------------------- b --------------------------------------similarity index 100%copy from acopy to b

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.

(I have also sent a generalized version of this patch to the Git mailing list.)


That does not seem supported without patching somehow the gitk source code itself.

For example, there was in the Git mailing list a similar request in Feb. 2020

As of commit c1a63459ed73 ("gitk: Preserve window dimensions on exitwhen not using ttk themes", 2019-12-15, Git v2.29.0-rc0), gitk seems to lack two features that I consider "killer" ones, for reviewing patches (including my ownpatches, of course):

  • support for the "--function-context" ("-W") option,
  • support for the "-O<orderfile>" (aka "diff.orderFile") setting.

These flags are in fact mentioned in the gitk source code, going back tohistorical commit ee66e089c1d4 ("gitk: Make updates go faster", 2008-05-09, Git v1.5.6-rc0).

The options are stashed in vdflags($n), and then summarily ignored.
A comment says, "These request or affect diff output, which we don'twant", and I don't understand why; I would very much like them, please :)

Could someone please write gitk patches for honoring "diff.orderFile"and "--function-context"?