@@ -83,6 +83,7 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
83
83
puts stderr " source $name "
84
84
uplevel 1 real__source $name
85
85
}
86
+ if {[tk windowingsystem] eq " win32" } { console show }
86
87
}
87
88
88
89
# #####################################################################
@@ -444,6 +445,8 @@ proc _lappend_nice {cmd_var} {
444
445
set _nice [ _which nice]
445
446
if {[ catch {exec $_nice git version}] } {
446
447
set _nice {}
448
+ } elseif {[ is_Windows] && [ file dirname $_nice ] ne [ file dirname $::_git ] } {
449
+ set _nice {}
447
450
}
448
451
}
449
452
if {$_nice ne {}} {
@@ -673,6 +676,7 @@ bind . <Visibility> {
673
676
if {[ is_Windows] } {
674
677
wm iconbitmap . -default $oguilib /git-gui.ico
675
678
set ::tk::AlwaysShowSelection 1
679
+ bind . <Control-F2> {console show}
676
680
677
681
# Spoof an X11 display for SSH
678
682
if {![ info exists env(DISPLAY)] } {
@@ -874,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
874
878
exit 1
875
879
}
876
880
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
+ }
877
892
set _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 ]
883
894
884
895
if {![ regexp {^[1-9]+(\.[0-9]+)+$} $_git_version ] } {
885
896
catch {wm withdraw .}
@@ -1183,13 +1194,22 @@ if {![file isdirectory $_gitdir]} {
1183
1194
# _gitdir exists, so try loading the config
1184
1195
load_config 0
1185
1196
apply_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
+ }
1191
1210
}
1192
1211
}
1212
+
1193
1213
if {$_prefix ne {}} {
1194
1214
if {$_gitworktree eq {}} {
1195
1215
regsub -all {[ ^/] +/} $_prefix ../ cdup
@@ -2861,7 +2881,8 @@ proc usage {} {
2861
2881
set s " usage: $::argv0 $::subcommand $::subcommand_args "
2862
2882
if {[ tk windowingsystem] eq " win32" } {
2863
2883
wm withdraw .
2864
- tk_messageBox -icon info -title " Usage" -message $s
2884
+ tk_messageBox -icon info -message $s \
2885
+ -title [ mc " Usage" ]
2865
2886
} else {
2866
2887
puts stderr $s
2867
2888
}
@@ -2934,7 +2955,11 @@ blame {
2934
2955
if {[ catch {
2935
2956
set head [git rev-parse --verify $head ]
2936
2957
} 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
+ }
2938
2963
exit 1
2939
2964
}
2940
2965
}
@@ -2973,18 +2998,19 @@ blame {
2973
2998
citool -
2974
2999
gui {
2975
3000
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
2983
3002
}
2984
3003
# fall through to setup UI for commits
2985
3004
}
2986
3005
default {
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
+ }
2988
3014
exit 1
2989
3015
}
2990
3016
}
@@ -3286,6 +3312,7 @@ text $ui_diff -background white -foreground black \
3286
3312
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
3287
3313
-yscrollcommand {.vpane.lower.diff.body.sby set} \
3288
3314
-state disabled
3315
+ catch {$ui_diff configure -tabstyle wordprocessor}
3289
3316
${NS} ::scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
3290
3317
-command [ list $ui_diff xview]
3291
3318
${NS} ::scrollbar .vpane.lower.diff.body.sby -orient vertical \
@@ -3296,8 +3323,16 @@ pack $ui_diff -side left -fill both -expand 1
3296
3323
pack .vpane.lower.diff.header -side top -fill x
3297
3324
pack .vpane.lower.diff.body -side bottom -fill both -expand 1
3298
3325
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
+
3299
3334
$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
3301
3336
$ui_diff tag conf d_+ -foreground {#00a000}
3302
3337
$ui_diff tag conf d_- -foreground red
3303
3338
0 commit comments