Skip to content

Commit 62efc4c

Browse files
committed
Merge branch 'j6t-testing' of https://github.com/j6t/gitk
2 parents 974fdd3 + 381f26c commit 62efc4c

File tree

1 file changed

+88
-22
lines changed

1 file changed

+88
-22
lines changed

gitk-git/gitk

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ proc unmerged_files {files} {
389389
proc parseviewargs {n arglist} {
390390
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
391391
global vinlinediff
392-
global worddiff
392+
global worddiff gitdir
393393
394394
set vdatemode($n) 0
395395
set vmergeonly($n) 0
@@ -484,7 +484,14 @@ proc parseviewargs {n arglist} {
484484
"--merge" {
485485
set vmergeonly($n) 1
486486
# git rev-parse doesn't understand --merge
487-
lappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD
487+
# check MERGE_HEAD again at the end so that it appears in
488+
# the error message when none of the _HEADs is found
489+
foreach merge_head {MERGE_HEAD CHERRY_PICK_HEAD REVERT_HEAD REBASE_HEAD MERGE_HEAD} {
490+
if {[file exists [file join $gitdir $merge_head]]} {
491+
break
492+
}
493+
}
494+
lappend revargs --gitk-symmetric-diff-marker $merge_head...HEAD
488495
}
489496
"--no-replace-objects" {
490497
set env(GIT_NO_REPLACE_OBJECTS) "1"
@@ -2131,12 +2138,14 @@ proc ttk_toplevel {w args} {
21312138
return $w
21322139
}
21332140
2134-
proc make_transient {window origin} {
2141+
proc make_transient {window origin {geometry ""}} {
21352142
wm transient $window $origin
21362143
2137-
# Windows fails to place transient windows normally, so
2138-
# schedule a callback to center them on the parent.
2139-
if {[tk windowingsystem] eq {win32}} {
2144+
if {$geometry ne ""} {
2145+
after idle [list wm geometry $window $geometry]
2146+
} elseif {[tk windowingsystem] eq {win32}} {
2147+
# Windows fails to place transient windows normally, so
2148+
# schedule a callback to center them on the parent.
21402149
after idle [list tk::PlaceWindow $window widget $origin]
21412150
}
21422151
}
@@ -2627,7 +2636,6 @@ proc makewindow {} {
26272636
-command changeignorespace -variable ignorespace
26282637
pack .bleft.mid.ignspace -side left -padx 5
26292638
2630-
set worddiff [mc "Line diff"]
26312639
makedroplist .bleft.mid.worddiff worddiff [mc "Line diff"] \
26322640
[mc "Markup words"] [mc "Color words"]
26332641
trace add variable worddiff write changeworddiff
@@ -2723,17 +2731,9 @@ proc makewindow {} {
27232731
.pwbottom add .bright
27242732
.ctop add .pwbottom
27252733
2726-
# restore window width & height if known
2734+
# restore window position if known
27272735
if {[info exists geometry(main)]} {
2728-
if {[scan $geometry(main) "%dx%d" w h] >= 2} {
2729-
if {$w > [winfo screenwidth .]} {
2730-
set w [winfo screenwidth .]
2731-
}
2732-
if {$h > [winfo screenheight .]} {
2733-
set h [winfo screenheight .]
2734-
}
2735-
wm geometry . "${w}x$h"
2736-
}
2736+
wm geometry . "$geometry(main)"
27372737
}
27382738
27392739
if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
@@ -3073,6 +3073,11 @@ proc savestuff {w} {
30733073
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
30743074
puts $f "set geometry(botwidth) [winfo width .bleft]"
30753075
puts $f "set geometry(botheight) [winfo height .bleft]"
3076+
unset -nocomplain geometry
3077+
global geometry
3078+
if {[info exists geometry(showrefs)]} {
3079+
puts $f "set geometry(showrefs) $geometry(showrefs)"
3080+
}
30763081
30773082
array set view_save {}
30783083
array set views {}
@@ -3788,6 +3793,48 @@ proc external_diff_get_one_file {diffid filename diffdir} {
37883793
"revision $diffid"]
37893794
}
37903795
3796+
proc check_for_renames_in_diff {diffidfrom diffidto filepath} {
3797+
global nullid nullid2
3798+
3799+
if {$diffidfrom eq $nullid} {
3800+
set rev [list $diffidto -R]
3801+
} elseif {$diffidfrom eq $nullid2} {
3802+
set rev [list $diffidto --cached -R]
3803+
} elseif {$diffidto eq $nullid} {
3804+
set rev [list $diffidfrom]
3805+
} elseif {$diffidto eq $nullid2} {
3806+
set rev [list $diffidfrom --cached]
3807+
} else {
3808+
set rev [list $diffidfrom..$diffidto]
3809+
}
3810+
3811+
set renames [list {}]
3812+
if {[catch {eval exec git diff $rev --find-renames --stat --raw --diff-filter=R} cmd_result]} {
3813+
error_popup "[mc "Error getting file rename info for file \"%s\" from commit %s to %s." \
3814+
$filepath $diffidfrom $diffidto] $cmd_result.\n\n"
3815+
}
3816+
set filename [file tail $filepath]
3817+
set esc_chars {\\ | ? ^ * . $ \[ \] + \( \) \{ \}}
3818+
foreach char $esc_chars {
3819+
set filename [string map [list $char \\$char] $filename]
3820+
}
3821+
set regex_base {\d+\s\d+\s\S+\s\S+\s\S+\s+}
3822+
set regex_ren_from $regex_base[subst -nobackslashes -nocommands {(\S+$filename)\s+(\S+)}]
3823+
set regex_ren_to $regex_base[subst -nobackslashes -nocommands {(\S+)\s+(\S+$filename)}]
3824+
if {[regexp -line -- $regex_ren_from $cmd_result whole_match ren_from ren_to]} {
3825+
if {$ren_from ne {} && $ren_to ne {}} {
3826+
lappend renames $ren_from
3827+
lappend renames $ren_to
3828+
}
3829+
} elseif {[regexp -line -- $regex_ren_to $cmd_result whole_match ren_from ren_to]} {
3830+
if {$ren_from ne {} && $ren_to ne {}} {
3831+
lappend renames $ren_from
3832+
lappend renames $ren_to
3833+
}
3834+
}
3835+
return $renames
3836+
}
3837+
37913838
proc external_diff {} {
37923839
global nullid nullid2
37933840
global flist_menu_file
@@ -3818,8 +3865,16 @@ proc external_diff {} {
38183865
if {$diffdir eq {}} return
38193866
38203867
# gather files to diff
3821-
set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
3822-
set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
3868+
set renamed_filenames [check_for_renames_in_diff $diffidfrom $diffidto $flist_menu_file]
3869+
set rename_from_filename [lindex $renamed_filenames 1]
3870+
set rename_to_filename [lindex $renamed_filenames 2]
3871+
if { ($rename_from_filename != {}) && ($rename_to_filename != {}) } {
3872+
set difffromfile [external_diff_get_one_file $diffidfrom $rename_from_filename $diffdir]
3873+
set difftofile [external_diff_get_one_file $diffidto $rename_to_filename $diffdir]
3874+
} else {
3875+
set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
3876+
set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
3877+
}
38233878
38243879
if {$difffromfile ne {} && $difftofile ne {}} {
38253880
set cmd [list [shellsplit $extdifftool] $difffromfile $difftofile]
@@ -6772,7 +6827,8 @@ proc drawtags {id x xt y1} {
67726827
lappend wvals $wid
67736828
set xt [expr {$xt + $wid + $extra}]
67746829
}
6775-
set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
6830+
set yl [expr {$y1 - $lthickness}]
6831+
set t [$canv create line $x $yl [lindex $xvals end] $yl \
67766832
-width $lthickness -fill $reflinecolor -tags tag.$id]
67776833
$canv lower $t
67786834
foreach tag $marks x $xvals wid $wvals {
@@ -10160,6 +10216,7 @@ proc rmbranch {} {
1016010216
proc showrefs {} {
1016110217
global showrefstop bgcolor fgcolor selectbgcolor
1016210218
global bglist fglist reflistfilter reflist maincursor
10219+
global geometry
1016310220
1016410221
set top .showrefs
1016510222
set showrefstop $top
@@ -10170,7 +10227,11 @@ proc showrefs {} {
1017010227
}
1017110228
ttk_toplevel $top
1017210229
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
10173-
make_transient $top .
10230+
if {[info exists geometry(showrefs)]} {
10231+
make_transient $top . $geometry(showrefs)
10232+
} else {
10233+
make_transient $top .
10234+
}
1017410235
text $top.list -background $bgcolor -foreground $fgcolor \
1017510236
-selectbackground $selectbgcolor -font mainfont \
1017610237
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10206,6 +10267,9 @@ proc showrefs {} {
1020610267
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
1020710268
set reflist {}
1020810269
refill_reflist
10270+
# avoid <Configure> being bound to child windows
10271+
bindtags $top [linsert [bindtags $top] 1 bind$top]
10272+
bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
1020910273
}
1021010274
1021110275
proc sel_reflist {w x y} {
@@ -12624,7 +12688,7 @@ set diffbgcolors {"#fff3f3" "#f0fff0"}
1262412688
set diffcontext 3
1262512689
set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
1262612690
set ignorespace 0
12627-
set worddiff ""
12691+
set worddiff [mc "Line diff"]
1262812692
set markbgcolor "#e0e0ff"
1262912693
1263012694
set headbgcolor "#00ff00"
@@ -12711,6 +12775,7 @@ set config_variables {
1271112775
headfgcolor
1271212776
headoutlinecolor
1271312777
hideremotes
12778+
ignorespace
1271412779
indexcirclecolor
1271512780
kscroll
1271612781
limitdiffs
@@ -12746,6 +12811,7 @@ set config_variables {
1274612811
uifont
1274712812
visiblerefs
1274812813
web_browser
12814+
worddiff
1274912815
workingfilescirclecolor
1275012816
wrapcomment
1275112817
wrapdefault

0 commit comments

Comments
 (0)