Skip to content

Commit 6e13921

Browse files
committed
Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui: git-gui: Fix the search bar destruction handler. Update the po template git-gui: Implement automatic rescan after Tool execution. git-gui: Allow Tools request arguments from the user. git-gui: Add a Tools menu for arbitrary commands. git-gui: Fix the after callback execution in rescan. git-gui: Implement system-wide configuration handling. git-gui: try to provide a window icon under X
2 parents bf31115 + 9419307 commit 6e13921

File tree

7 files changed

+1457
-311
lines changed

7 files changed

+1457
-311
lines changed

git-gui/git-gui.sh

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,28 @@ if {[is_Windows]} {
597597
if {![info exists env(DISPLAY)]} {
598598
set env(DISPLAY) :9999
599599
}
600+
} else {
601+
catch {
602+
image create photo gitlogo -width 16 -height 16
603+
604+
gitlogo put #33CC33 -to 7 0 9 2
605+
gitlogo put #33CC33 -to 4 2 12 4
606+
gitlogo put #33CC33 -to 7 4 9 6
607+
gitlogo put #CC3333 -to 4 6 12 8
608+
gitlogo put gray26 -to 4 9 6 10
609+
gitlogo put gray26 -to 3 10 6 12
610+
gitlogo put gray26 -to 8 9 13 11
611+
gitlogo put gray26 -to 8 11 10 12
612+
gitlogo put gray26 -to 11 11 13 14
613+
gitlogo put gray26 -to 3 12 5 14
614+
gitlogo put gray26 -to 5 13
615+
gitlogo put gray26 -to 10 13
616+
gitlogo put gray26 -to 4 14 12 15
617+
gitlogo put gray26 -to 5 15 11 16
618+
gitlogo redither
619+
620+
wm iconphoto . -default gitlogo
621+
}
600622
}
601623
602624
######################################################################
@@ -918,19 +940,25 @@ git-version proc _parse_config {arr_name args} {
918940
}
919941
920942
proc load_config {include_global} {
921-
global repo_config global_config default_config
943+
global repo_config global_config system_config default_config
922944
923945
if {$include_global} {
946+
_parse_config system_config --system
924947
_parse_config global_config --global
925948
}
926949
_parse_config repo_config
927950
928951
foreach name [array names default_config] {
952+
if {[catch {set v $system_config($name)}]} {
953+
set system_config($name) $default_config($name)
954+
}
955+
}
956+
foreach name [array names system_config] {
929957
if {[catch {set v $global_config($name)}]} {
930-
set global_config($name) $default_config($name)
958+
set global_config($name) $system_config($name)
931959
}
932960
if {[catch {set v $repo_config($name)}]} {
933-
set repo_config($name) $default_config($name)
961+
set repo_config($name) $system_config($name)
934962
}
935963
}
936964
}
@@ -1463,10 +1491,8 @@ proc rescan_done {fd buf after} {
14631491
prune_selection
14641492
unlock_index
14651493
display_all_files
1466-
if {$current_diff_path ne {}} reshow_diff
1467-
if {$current_diff_path eq {}} select_first_diff
1468-
1469-
uplevel #0 $after
1494+
if {$current_diff_path ne {}} { reshow_diff $after }
1495+
if {$current_diff_path eq {}} { select_first_diff $after }
14701496
}
14711497
14721498
proc prune_selection {} {
@@ -1978,16 +2004,16 @@ proc do_rescan {} {
19782004
}
19792005
19802006
proc ui_do_rescan {} {
1981-
rescan {force_first_diff; ui_ready}
2007+
rescan {force_first_diff ui_ready}
19822008
}
19832009
19842010
proc do_commit {} {
19852011
commit_tree
19862012
}
19872013
1988-
proc next_diff {} {
2014+
proc next_diff {{after {}}} {
19892015
global next_diff_p next_diff_w next_diff_i
1990-
show_diff $next_diff_p $next_diff_w {}
2016+
show_diff $next_diff_p $next_diff_w {} {} $after
19912017
}
19922018
19932019
proc find_anchor_pos {lst name} {
@@ -2072,25 +2098,42 @@ proc next_diff_after_action {w path {lno {}} {mmask {}}} {
20722098
}
20732099
}
20742100
2075-
proc select_first_diff {} {
2101+
proc select_first_diff {after} {
20762102
global ui_workdir
20772103
20782104
if {[find_next_diff $ui_workdir {} 1 {^_?U}] ||
20792105
[find_next_diff $ui_workdir {} 1 {[^O]$}]} {
2080-
next_diff
2106+
next_diff $after
2107+
} else {
2108+
uplevel #0 $after
20812109
}
20822110
}
20832111
2084-
proc force_first_diff {} {
2085-
global current_diff_path
2112+
proc force_first_diff {after} {
2113+
global ui_workdir current_diff_path file_states
20862114
20872115
if {[info exists file_states($current_diff_path)]} {
20882116
set state [lindex $file_states($current_diff_path) 0]
2117+
} else {
2118+
set state {OO}
2119+
}
20892120
2090-
if {[string index $state 1] ne {O}} return
2121+
set reselect 0
2122+
if {[string first {U} $state] >= 0} {
2123+
# Already a conflict, do nothing
2124+
} elseif {[find_next_diff $ui_workdir $current_diff_path {} {^_?U}]} {
2125+
set reselect 1
2126+
} elseif {[string index $state 1] ne {O}} {
2127+
# Already a diff & no conflicts, do nothing
2128+
} elseif {[find_next_diff $ui_workdir $current_diff_path {} {[^O]$}]} {
2129+
set reselect 1
20912130
}
20922131
2093-
select_first_diff
2132+
if {$reselect} {
2133+
next_diff $after
2134+
} else {
2135+
uplevel #0 $after
2136+
}
20942137
}
20952138
20962139
proc toggle_or_diff {w x y} {
@@ -2246,6 +2289,9 @@ if {[is_enabled transport]} {
22462289
.mbar add cascade -label [mc Merge] -menu .mbar.merge
22472290
.mbar add cascade -label [mc Remote] -menu .mbar.remote
22482291
}
2292+
if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2293+
.mbar add cascade -label [mc Tools] -menu .mbar.tools
2294+
}
22492295
. configure -menu .mbar
22502296
22512297
# -- Repository Menu
@@ -2520,6 +2566,20 @@ if {[is_MacOSX]} {
25202566
-command do_options
25212567
}
25222568
2569+
# -- Tools Menu
2570+
#
2571+
if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2572+
set tools_menubar .mbar.tools
2573+
menu $tools_menubar
2574+
$tools_menubar add separator
2575+
$tools_menubar add command -label [mc "Add..."] -command tools_add::dialog
2576+
$tools_menubar add command -label [mc "Remove..."] -command tools_remove::dialog
2577+
set tools_tailcnt 3
2578+
if {[array names repo_config guitool.*.cmd] ne {}} {
2579+
tools_populate_all
2580+
}
2581+
}
2582+
25232583
# -- Help Menu
25242584
#
25252585
.mbar add cascade -label [mc Help] -menu .mbar.help

git-gui/lib/diff.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ proc clear_diff {} {
1616
$ui_workdir tag remove in_diff 0.0 end
1717
}
1818

19-
proc reshow_diff {} {
19+
proc reshow_diff {{after {}}} {
2020
global file_states file_lists
2121
global current_diff_path current_diff_side
2222
global ui_diff
@@ -30,13 +30,13 @@ proc reshow_diff {} {
3030
|| [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
3131

3232
if {[find_next_diff $current_diff_side $p {} {[^O]}]} {
33-
next_diff
33+
next_diff $after
3434
} else {
3535
clear_diff
3636
}
3737
} else {
3838
set save_pos [lindex [$ui_diff yview] 0]
39-
show_diff $p $current_diff_side {} $save_pos
39+
show_diff $p $current_diff_side {} $save_pos $after
4040
}
4141
}
4242

git-gui/lib/option.tcl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ proc config_check_encodings {} {
2525

2626
proc save_config {} {
2727
global default_config font_descs
28-
global repo_config global_config
28+
global repo_config global_config system_config
2929
global repo_config_new global_config_new
3030
global ui_comm_spell
3131

@@ -49,7 +49,7 @@ proc save_config {} {
4949
foreach name [array names default_config] {
5050
set value $global_config_new($name)
5151
if {$value ne $global_config($name)} {
52-
if {$value eq $default_config($name)} {
52+
if {$value eq $system_config($name)} {
5353
catch {git config --global --unset $name}
5454
} else {
5555
regsub -all "\[{}\]" $value {"} value
@@ -284,17 +284,17 @@ proc do_options {} {
284284
}
285285

286286
proc do_restore_defaults {} {
287-
global font_descs default_config repo_config
287+
global font_descs default_config repo_config system_config
288288
global repo_config_new global_config_new
289289

290290
foreach name [array names default_config] {
291-
set repo_config_new($name) $default_config($name)
292-
set global_config_new($name) $default_config($name)
291+
set repo_config_new($name) $system_config($name)
292+
set global_config_new($name) $system_config($name)
293293
}
294294

295295
foreach option $font_descs {
296296
set name [lindex $option 0]
297-
set repo_config(gui.$name) $default_config(gui.$name)
297+
set repo_config(gui.$name) $system_config(gui.$name)
298298
}
299299
apply_config
300300

git-gui/lib/search.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ constructor new {i_w i_text args} {
3535

3636
trace add variable searchstring write [cb _incrsearch_cb]
3737

38-
bind $w <Destroy> [cb delete_this]
38+
bind $w <Destroy> [list delete_this $this]
3939
return $this
4040
}
4141

0 commit comments

Comments
 (0)