@@ -38,7 +38,7 @@ if {[catch {package require Tcl 8.4} err]
3838 tk_messageBox \
3939 -icon error \
4040 -type ok \
41- -title [mc " git-gui: fatal error" ] \
41+ -title " git-gui: fatal error" \
4242 -message $err
4343 exit 1
4444}
@@ -269,6 +269,17 @@ proc is_config_true {name} {
269269 }
270270}
271271
272+ proc is_config_false {name} {
273+ global repo_config
274+ if {[catch {set v $repo_config($name) }]} {
275+ return 0
276+ } elseif {$v eq {false} || $v eq {0} || $v eq {no}} {
277+ return 1
278+ } else {
279+ return 0
280+ }
281+ }
282+
272283proc get_config {name} {
273284 global repo_config
274285 if {[catch {set v $repo_config($name) }]} {
@@ -323,6 +334,8 @@ proc _trace_exec {cmd} {
323334 puts stderr $d
324335}
325336
337+ # '" fix poor old emacs font-lock mode
338+
326339proc _git_cmd {name} {
327340 global _git_cmd_path
328341
@@ -416,6 +429,9 @@ proc _lappend_nice {cmd_var} {
416429
417430 if {![ info exists _nice] } {
418431 set _nice [ _which nice]
432+ if {[ catch {exec $_nice git version}] } {
433+ set _nice {}
434+ }
419435 }
420436 if {$_nice ne {}} {
421437 lappend cmd $_nice
@@ -634,6 +650,7 @@ proc rmsel_tag {text} {
634650 return $text
635651}
636652
653+ wm withdraw .
637654set root_exists 0
638655bind . <Visibility> {
639656 bind . <Visibility> {}
@@ -782,6 +799,7 @@ set default_config(user.email) {}
782799
783800set default_config(gui.encoding) [ encoding system]
784801set default_config(gui.matchtrackingbranch) false
802+ set default_config(gui.textconv) true
785803set default_config(gui.pruneduringfetch) false
786804set default_config(gui.trustmtime) false
787805set default_config(gui.fastcopyblame) false
@@ -1155,6 +1173,9 @@ apply_config
11551173# try to set work tree from environment, falling back to core.worktree
11561174if {[ catch { set _gitworktree $env(GIT_WORK_TREE) }] } {
11571175 set _gitworktree [ get_config core.worktree]
1176+ if {$_gitworktree eq " " } {
1177+ set _gitworktree [ file dirname [file normalize $_gitdir ] ]
1178+ }
11581179}
11591180if {$_prefix ne {}} {
11601181 if {$_gitworktree eq {}} {
@@ -2098,7 +2119,7 @@ proc do_explore {} {
20982119 # freedesktop.org-conforming system is our best shot
20992120 set explorer " xdg-open"
21002121 }
2101- eval exec $explorer $_gitworktree &
2122+ eval exec $explorer [ list [ file nativename $_gitworktree ] ] &
21022123}
21032124
21042125set is_quitting 0
@@ -2901,6 +2922,7 @@ blame {
29012922 set current_branch $head
29022923 }
29032924
2925+ wm deiconify .
29042926 switch -- $subcommand {
29052927 browser {
29062928 if {$jump_spec ne {}} usage
@@ -3405,6 +3427,19 @@ lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
34053427$ctxmsm add separator
34063428create_common_diff_popup $ctxmsm
34073429
3430+ proc has_textconv {path} {
3431+ if {[ is_config_false gui.textconv] } {
3432+ return 0
3433+ }
3434+ set filter [ gitattr $path diff set]
3435+ set textconv [ get_config [join [list diff $filter textconv] .]]
3436+ if {$filter ne {set} && $textconv ne {}} {
3437+ return 1
3438+ } else {
3439+ return 0
3440+ }
3441+ }
3442+
34083443proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
34093444 global current_diff_path file_states
34103445 set ::cursorX $x
@@ -3440,7 +3475,8 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
34403475 || {__} eq $state
34413476 || {_O} eq $state
34423477 || {_T} eq $state
3443- || {T_} eq $state } {
3478+ || {T_} eq $state
3479+ || [ has_textconv $current_diff_path ] } {
34443480 set s disabled
34453481 } else {
34463482 set s normal
@@ -3460,29 +3496,44 @@ $main_status show [mc "Initializing..."]
34603496
34613497# -- Load geometry
34623498#
3463- catch {
3464- set gm $repo_config(gui.geometry)
3465- wm geometry . [ lindex $gm 0]
3466- if {$use_ttk } {
3467- .vpane sashpos 0 [ lindex $gm 1]
3468- .vpane.files sashpos 0 [ lindex $gm 2]
3469- } else {
3470- .vpane sash place 0 \
3471- [ lindex $gm 1] \
3472- [ lindex [.vpane sash coord 0] 1]
3473- .vpane.files sash place 0 \
3474- [ lindex [.vpane.files sash coord 0] 0] \
3475- [ lindex $gm 2]
3499+ proc on_ttk_pane_mapped {w pane pos} {
3500+ bind $w <Map> {}
3501+ after 0 [ list after idle [list $w sashpos $pane $pos ] ]
3502+ }
3503+ proc on_tk_pane_mapped {w pane x y} {
3504+ bind $w <Map> {}
3505+ after 0 [ list after idle [list $w sash place $pane $x $y ] ]
3506+ }
3507+ proc on_application_mapped {} {
3508+ global repo_config use_ttk
3509+ bind . <Map> {}
3510+ set gm $repo_config(gui.geometry)
3511+ if {$use_ttk } {
3512+ bind .vpane <Map> \
3513+ [ list on_ttk_pane_mapped %W 0 [lindex $gm 1] ]
3514+ bind .vpane.files <Map> \
3515+ [ list on_ttk_pane_mapped %W 0 [lindex $gm 2] ]
3516+ } else {
3517+ bind .vpane <Map> \
3518+ [ list on_tk_pane_mapped %W 0 \
3519+ [lindex $gm 1] \
3520+ [ lindex [.vpane sash coord 0] 1]]
3521+ bind .vpane.files <Map> \
3522+ [ list on_tk_pane_mapped %W 0 \
3523+ [lindex [.vpane.files sash coord 0] 0] \
3524+ [ lindex $gm 2] ]
3525+ }
3526+ wm geometry . [ lindex $gm 0]
34763527}
3477- unset gm
3528+ if {[ info exists repo_config(gui.geometry)] } {
3529+ bind . <Map> [ list on_application_mapped]
3530+ wm geometry . [ lindex $repo_config(gui.geometry) 0]
34783531}
34793532
34803533# -- Load window state
34813534#
3482- catch {
3483- set gws $repo_config(gui.wmstate)
3484- wm state . $gws
3485- unset gws
3535+ if {[ info exists repo_config(gui.wmstate)] } {
3536+ catch {wm state . $repo_config(gui.wmstate) }
34863537}
34873538
34883539# -- Key Bindings
0 commit comments