@@ -3662,11 +3662,33 @@ proc external_diff_get_one_file {diffid filename diffdir} {
3662
3662
" revision $diffid " ]
3663
3663
}
3664
3664
3665
+ proc check_for_renames_in_diff {filepath} {
3666
+ global ctext
3667
+
3668
+ set renamed_filenames [list {}]
3669
+ set filename [file tail $filepath ]
3670
+ set rename_from_text_length 12
3671
+ set rename_to_text_length 10
3672
+ set reg_expr_rename_from {^rename from (.*$filename )}
3673
+ set reg_expr_rename_from [subst -nobackslashes -nocommands $reg_expr_rename_from ]
3674
+ set reg_expr_rename_to {^rename to (.*)}
3675
+ set rename_from_text_index [$ctext search -elide -regexp -- $reg_expr_rename_from 0.0]
3676
+ if { ($rename_from_text_index != {})} {
3677
+ set rename_to_text_index [$ctext search -elide -regexp -- $reg_expr_rename_to $rename_from_text_index ]
3678
+ if { ($rename_from_text_index != {}) && ($rename_to_text_index != {}) } {
3679
+ lappend renamed_filenames [$ctext get " $rename_from_text_index + $rename_from_text_length chars" " $rename_from_text_index lineend" ]
3680
+ lappend renamed_filenames [$ctext get " $rename_to_text_index + $rename_to_text_length chars" " $rename_to_text_index lineend" ]
3681
+ }
3682
+ }
3683
+ return $renamed_filenames
3684
+ }
3685
+
3665
3686
proc external_diff {} {
3666
3687
global nullid nullid2
3667
3688
global flist_menu_file
3668
3689
global diffids
3669
3690
global extdifftool
3691
+ global file_rename_detection
3670
3692
3671
3693
if {[llength $diffids ] == 1} {
3672
3694
# no reference commit given
@@ -3692,8 +3714,21 @@ proc external_diff {} {
3692
3714
if {$diffdir eq {}} return
3693
3715
3694
3716
# gather files to diff
3695
- set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir ]
3696
- set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir ]
3717
+ if {$file_rename_detection } {
3718
+ set renamed_filenames [check_for_renames_in_diff $flist_menu_file ]
3719
+ set rename_from_filename [lindex $renamed_filenames 1]
3720
+ set rename_to_filename [lindex $renamed_filenames 2]
3721
+ if { ($rename_from_filename != {}) && ($rename_to_filename != {}) } {
3722
+ set difffromfile [external_diff_get_one_file $diffidfrom $rename_from_filename $diffdir ]
3723
+ set difftofile [external_diff_get_one_file $diffidto $rename_to_filename $diffdir ]
3724
+ } else {
3725
+ set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir ]
3726
+ set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir ]
3727
+ }
3728
+ } else {
3729
+ set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir ]
3730
+ set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir ]
3731
+ }
3697
3732
3698
3733
if {$difffromfile ne {} && $difftofile ne {}} {
3699
3734
set cmd [list [shellsplit $extdifftool ] $difffromfile $difftofile ]
@@ -11577,7 +11612,7 @@ proc create_prefs_page {w} {
11577
11612
proc prefspage_general {notebook} {
11578
11613
global NS maxwidth maxgraphpct showneartags showlocalchanges
11579
11614
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11580
- global hideremotes want_ttk have_ttk maxrefs web_browser
11615
+ global hideremotes want_ttk have_ttk maxrefs web_browser file_rename_detection
11581
11616
11582
11617
set page [create_prefs_page $notebook .general]
11583
11618
@@ -11639,12 +11674,16 @@ proc prefspage_general {notebook} {
11639
11674
grid $page .lgen - -sticky w -pady 10
11640
11675
${NS} ::checkbutton $page .want_ttk -variable want_ttk \
11641
11676
-text [mc " Use themed widgets" ]
11677
+ ${NS} ::checkbutton $page .file_rename_detection -variable file_rename_detection \
11678
+ -text [mc " Use ext diff file rename detection" ]
11679
+ ${NS} ::label $page .file_rename_detection_note -text [mc " (EXPERIMENTAL\n Tries to find the file path of a\n renamed file in external diff)" ]
11642
11680
if {$have_ttk } {
11643
11681
${NS} ::label $page .ttk_note -text [mc " (change requires restart)" ]
11644
11682
} else {
11645
11683
${NS} ::label $page .ttk_note -text [mc " (currently unavailable)" ]
11646
11684
}
11647
11685
grid x $page .want_ttk $page .ttk_note -sticky w
11686
+ grid x $page .file_rename_detection $page .file_rename_detection_note -sticky w
11648
11687
return $page
11649
11688
}
11650
11689
@@ -11725,7 +11764,7 @@ proc doprefs {} {
11725
11764
global oldprefs prefstop showneartags showlocalchanges
11726
11765
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11727
11766
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11728
- global hideremotes want_ttk have_ttk
11767
+ global hideremotes want_ttk have_ttk file_rename_detection
11729
11768
11730
11769
set top .gitkprefs
11731
11770
set prefstop $top
@@ -11734,7 +11773,7 @@ proc doprefs {} {
11734
11773
return
11735
11774
}
11736
11775
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11737
- limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11776
+ limitdiffs tabstop perfile_attrs hideremotes want_ttk file_rename_detection } {
11738
11777
set oldprefs($v ) [set $v ]
11739
11778
}
11740
11779
ttk_toplevel $top
@@ -11860,7 +11899,7 @@ proc prefscan {} {
11860
11899
global oldprefs prefstop
11861
11900
11862
11901
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11863
- limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11902
+ limitdiffs tabstop perfile_attrs hideremotes want_ttk file_rename_detection } {
11864
11903
global $v
11865
11904
set $v $oldprefs($v)
11866
11905
}
@@ -12404,6 +12443,7 @@ set autoselect 1
12404
12443
set autosellen 40
12405
12444
set perfile_attrs 0
12406
12445
set want_ttk 1
12446
+ set file_rename_detection 0
12407
12447
12408
12448
if {[tk windowingsystem] eq " aqua" } {
12409
12449
set extdifftool " opendiff"
@@ -12498,7 +12538,7 @@ config_check_tmp_exists 50
12498
12538
set config_variables {
12499
12539
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12500
12540
cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs
12501
- hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
12541
+ hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk file_rename_detection
12502
12542
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
12503
12543
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
12504
12544
extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor
0 commit comments