Skip to content

Commit c01a29c

Browse files
committed
Merge git://repo.or.cz/git-gui into pt/git-gui
* git://repo.or.cz/git-gui: git-gui: fix size and position of window panes on startup git-gui: mc cannot be used before msgcat has been loaded git-gui: use textconv filter for diff and blame git-gui: Avoid using the <<Copy>> binding as a menu accelerator on win32 git-gui: fix shortcut creation on cygwin git-gui: fix PATH environment for mingw development environment git-gui: fix usage of _gitworktree when creating shortcut for windows git-gui: fix "Explore Working Copy" for Windows again git-gui: fix usage of themed widgets variable git-gui: Handle failure of core.worktree to identify the working directory. git-gui: check whether systems nice command works or disable it
2 parents ac2e1e6 + 2810a58 commit c01a29c

File tree

9 files changed

+112
-33
lines changed

9 files changed

+112
-33
lines changed

git-gui/git-gui.sh

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
272283
proc 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+
326339
proc _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 .
637654
set root_exists 0
638655
bind . <Visibility> {
639656
bind . <Visibility> {}
@@ -782,6 +799,7 @@ set default_config(user.email) {}
782799
783800
set default_config(gui.encoding) [encoding system]
784801
set default_config(gui.matchtrackingbranch) false
802+
set default_config(gui.textconv) true
785803
set default_config(gui.pruneduringfetch) false
786804
set default_config(gui.trustmtime) false
787805
set default_config(gui.fastcopyblame) false
@@ -1155,6 +1173,9 @@ apply_config
11551173
# try to set work tree from environment, falling back to core.worktree
11561174
if {[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
}
11591180
if {$_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
21042125
set 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
34063428
create_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+
34083443
proc 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

git-gui/lib/blame.tcl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,28 @@ method _load {jump} {
449449

450450
$status show [mc "Reading %s..." "$commit:[escape_path $path]"]
451451
$w_path conf -text [escape_path $path]
452+
453+
set do_textconv 0
454+
if {![is_config_false gui.textconv] && [git-version >= 1.7.2]} {
455+
set filter [gitattr $path diff set]
456+
set textconv [get_config [join [list diff $filter textconv] .]]
457+
if {$filter ne {set} && $textconv ne {}} {
458+
set do_textconv 1
459+
}
460+
}
452461
if {$commit eq {}} {
453-
set fd [open $path r]
462+
if {$do_textconv ne 0} {
463+
set fd [open |[list $textconv $path] r]
464+
} else {
465+
set fd [open $path r]
466+
}
454467
fconfigure $fd -eofchar {}
455468
} else {
456-
set fd [git_read cat-file blob "$commit:$path"]
469+
if {$do_textconv ne 0} {
470+
set fd [git_read cat-file --textconv "$commit:$path"]
471+
} else {
472+
set fd [git_read cat-file blob "$commit:$path"]
473+
}
457474
}
458475
fconfigure $fd \
459476
-blocking 0 \

git-gui/lib/choose_repository.tcl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ constructor pick {} {
100100
$opts insert end [mc "Clone Existing Repository"] link_clone
101101
$opts insert end "\n"
102102
if {$m_repo ne {}} {
103+
if {[tk windowingsystem] eq "win32"} {
104+
set key L
105+
} else {
106+
set key C
107+
}
103108
$m_repo add command \
104109
-command [cb _next clone] \
105-
-accelerator $M1T-C \
110+
-accelerator $M1T-$key \
106111
-label [mc "Clone..."]
107-
bind $top <$M1B-c> [cb _next clone]
108-
bind $top <$M1B-C> [cb _next clone]
112+
bind $top <$M1B-[string tolower $key]> [cb _next clone]
113+
bind $top <$M1B-[string toupper $key]> [cb _next clone]
109114
}
110115

111116
$opts tag conf link_open -foreground blue -underline 1

git-gui/lib/diff.tcl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ proc handle_empty_diff {} {
5555

5656
set path $current_diff_path
5757
set s $file_states($path)
58-
if {[lindex $s 0] ne {_M}} return
58+
if {[lindex $s 0] ne {_M} || [has_textconv $path]} return
5959

6060
# Prevent infinite rescan loops
6161
incr diff_empty_count
@@ -280,6 +280,9 @@ proc start_show_diff {cont_info {add_opts {}}} {
280280
lappend cmd diff-files
281281
}
282282
}
283+
if {![is_config_false gui.textconv] && [git-version >= 1.6.1]} {
284+
lappend cmd --textconv
285+
}
283286

284287
if {[string match {160000 *} [lindex $s 2]]
285288
|| [string match {160000 *} [lindex $s 3]]} {

git-gui/lib/option.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ proc do_options {} {
148148
{b gui.trustmtime {mc "Trust File Modification Timestamps"}}
149149
{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
150150
{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
151+
{b gui.textconv {mc "Use Textconv For Diffs and Blames"}}
151152
{b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}}
152153
{i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}}
153154
{i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}}

git-gui/lib/shortcut.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ proc do_windows_shortcut {} {
1616
[info nameofexecutable] \
1717
[file normalize $::argv0] \
1818
] \
19-
[file normalize [$_gitworktree]]
19+
[file normalize $_gitworktree]
2020
} err]} {
2121
error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
2222
}
@@ -57,7 +57,7 @@ proc do_cygwin_shortcut {} {
5757
$sh -c \
5858
"CHERE_INVOKING=1 source /etc/profile;[sq $me] &" \
5959
] \
60-
[file normalize [$_gitworktree]]
60+
[file normalize $_gitworktree]
6161
} err]} {
6262
error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
6363
}

git-gui/lib/status_bar.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ method _oneline_pack {} {
3939
}
4040

4141
constructor two_line {path} {
42+
global NS
4243
set w $path
4344
set w_l $w.l
4445
set w_c $w.c

git-gui/lib/win32.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ proc win32_create_lnk {lnk_path lnk_exec lnk_dir} {
1818
eval [list exec wscript.exe \
1919
/E:jscript \
2020
/nologo \
21-
[file join $oguilib win32_shortcut.js] \
21+
[file nativename [file join $oguilib win32_shortcut.js]] \
2222
$lnk_path \
23-
[file join $oguilib git-gui.ico] \
23+
[file nativename [file join $oguilib git-gui.ico]] \
2424
$lnk_dir \
2525
$lnk_exec] $lnk_args
2626
}

git-gui/windows/git-gui.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
1313
incr argc -2
1414
}
1515

16-
set bindir [file dirname \
16+
set basedir [file dirname \
1717
[file dirname \
1818
[file dirname [info script]]]]
19-
set bindir [file join $bindir bin]
19+
set bindir [file join $basedir bin]
20+
set bindir "$bindir;[file join $basedir mingw bin]"
2021
regsub -all ";" $bindir "\\;" bindir
2122
set env(PATH) "$bindir;$env(PATH)"
2223
unset bindir

0 commit comments

Comments
 (0)