@@ -83,6 +83,7 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
8383 puts stderr " source $name "
8484 uplevel 1 real__source $name
8585 }
86+ if {[tk windowingsystem] eq " win32" } { console show }
8687}
8788
8889# #####################################################################
@@ -444,6 +445,8 @@ proc _lappend_nice {cmd_var} {
444445 set _nice [ _which nice]
445446 if {[ catch {exec $_nice git version}] } {
446447 set _nice {}
448+ } elseif {[ is_Windows] && [ file dirname $_nice ] ne [ file dirname $::_git ] } {
449+ set _nice {}
447450 }
448451 }
449452 if {$_nice ne {}} {
@@ -673,6 +676,7 @@ bind . <Visibility> {
673676if {[ is_Windows] } {
674677 wm iconbitmap . -default $oguilib /git-gui.ico
675678 set ::tk::AlwaysShowSelection 1
679+ bind . <Control-F2> {console show}
676680
677681 # Spoof an X11 display for SSH
678682 if {![ info exists env(DISPLAY)] } {
@@ -874,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
874878 exit 1
875879}
876880
881+ proc get_trimmed_version {s} {
882+ set r {}
883+ foreach x [ split $s -._] {
884+ if {[ string is integer -strict $x ] } {
885+ lappend r $x
886+ } else {
887+ break
888+ }
889+ }
890+ return [ join $r .]
891+ }
877892set _real_git_version $_git_version
878- regsub -- {[ \-\. ] dirty$} $_git_version {} _git_version
879- regsub {\. [ 0-9] +\. g[ 0-9a-f] +$} $_git_version {} _git_version
880- regsub {\. [ a-zA-Z] +\. ?[ 0-9] +$} $_git_version {} _git_version
881- regsub {\. GIT$} $_git_version {} _git_version
882- regsub {\. [ a-zA-Z] +\. ?[ 0-9] +$} $_git_version {} _git_version
893+ set _git_version [ get_trimmed_version $_git_version ]
883894
884895if {![ regexp {^[1-9]+(\.[0-9]+)+$} $_git_version ] } {
885896 catch {wm withdraw .}
@@ -1183,13 +1194,22 @@ if {![file isdirectory $_gitdir]} {
11831194# _gitdir exists, so try loading the config
11841195load_config 0
11851196apply_config
1186- # try to set work tree from environment, falling back to core.worktree
1187- if {[ catch { set _gitworktree $env(GIT_WORK_TREE) }] } {
1188- set _gitworktree [ get_config core.worktree]
1189- if {$_gitworktree eq " " } {
1190- set _gitworktree [ file dirname [file normalize $_gitdir ] ]
1197+
1198+ # v1.7.0 introduced --show-toplevel to return the canonical work-tree
1199+ if {[ package vsatisfies $_git_version 1.7.0] } {
1200+ set _gitworktree [ git rev-parse --show-toplevel]
1201+ } else {
1202+ # try to set work tree from environment, core.worktree or use
1203+ # cdup to obtain a relative path to the top of the worktree. If
1204+ # run from the top, the ./ prefix ensures normalize expands pwd.
1205+ if {[ catch { set _gitworktree $env(GIT_WORK_TREE) }] } {
1206+ set _gitworktree [ get_config core.worktree]
1207+ if {$_gitworktree eq " " } {
1208+ set _gitworktree [ file normalize ./[git rev-parse --show-cdup] ]
1209+ }
11911210 }
11921211}
1212+
11931213if {$_prefix ne {}} {
11941214 if {$_gitworktree eq {}} {
11951215 regsub -all {[ ^/] +/} $_prefix ../ cdup
@@ -2861,7 +2881,8 @@ proc usage {} {
28612881 set s " usage: $::argv0 $::subcommand $::subcommand_args "
28622882 if {[ tk windowingsystem] eq " win32" } {
28632883 wm withdraw .
2864- tk_messageBox -icon info -title " Usage" -message $s
2884+ tk_messageBox -icon info -message $s \
2885+ -title [ mc " Usage" ]
28652886 } else {
28662887 puts stderr $s
28672888 }
@@ -2934,7 +2955,11 @@ blame {
29342955 if {[ catch {
29352956 set head [git rev-parse --verify $head ]
29362957 } err]} {
2937- puts stderr $err
2958+ if {[ tk windowingsystem] eq " win32" } {
2959+ tk_messageBox -icon error -title [ mc Error] -message $err
2960+ } else {
2961+ puts stderr $err
2962+ }
29382963 exit 1
29392964 }
29402965 }
@@ -2973,18 +2998,19 @@ blame {
29732998citool -
29742999gui {
29753000 if {[ llength $argv ] != 0} {
2976- puts -nonewline stderr " usage: $argv0 "
2977- if {$subcommand ne {gui}
2978- && [ file tail $argv0 ] ne " git-$subcommand " } {
2979- puts -nonewline stderr " $subcommand "
2980- }
2981- puts stderr {}
2982- exit 1
3001+ usage
29833002 }
29843003 # fall through to setup UI for commits
29853004}
29863005default {
2987- puts stderr " usage: $argv0 \[ {blame|browser|citool}\] "
3006+ set err " usage: $argv0 \[ {blame|browser|citool}\] "
3007+ if {[ tk windowingsystem] eq " win32" } {
3008+ wm withdraw .
3009+ tk_messageBox -icon error -message $err \
3010+ -title [ mc " Usage" ]
3011+ } else {
3012+ puts stderr $err
3013+ }
29883014 exit 1
29893015}
29903016}
@@ -3286,6 +3312,7 @@ text $ui_diff -background white -foreground black \
32863312 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
32873313 -yscrollcommand {.vpane.lower.diff.body.sby set} \
32883314 -state disabled
3315+ catch {$ui_diff configure -tabstyle wordprocessor}
32893316${NS} ::scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
32903317 -command [ list $ui_diff xview]
32913318${NS} ::scrollbar .vpane.lower.diff.body.sby -orient vertical \
@@ -3296,8 +3323,16 @@ pack $ui_diff -side left -fill both -expand 1
32963323pack .vpane.lower.diff.header -side top -fill x
32973324pack .vpane.lower.diff.body -side bottom -fill both -expand 1
32983325
3326+ foreach {n c} {0 black 1 red4 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 grey60} {
3327+ $ui_diff tag configure clr4$n -background $c
3328+ $ui_diff tag configure clri4$n -foreground $c
3329+ $ui_diff tag configure clr3$n -foreground $c
3330+ $ui_diff tag configure clri3$n -background $c
3331+ }
3332+ $ui_diff tag configure clr1 -font font_diffbold
3333+
32993334$ui_diff tag conf d_cr -elide true
3300- $ui_diff tag conf d_@ -foreground blue - font font_diffbold
3335+ $ui_diff tag conf d_@ -font font_diffbold
33013336$ui_diff tag conf d_+ -foreground {#00a000}
33023337$ui_diff tag conf d_- -foreground red
33033338
0 commit comments