git-gui: Refactor single_commit to a proc.
This is a minor code cleanup to make working with what used to be the $single_commit flag easier. Its also to better handle various UI configurations, depending on command line parameters given by the user, or perhaps user preferences. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Feb 8, 2007 at 18:03 UTC
cf25ddc8b31ef883cf23eeb8d2eae21535a98002
1 file changed
+30
-14
git-gui.sh
+30
-14
@@ -93,6 +93,22 @@ proc is_Cygwin {} {
93
return $_iscygwin
94
}
95
96
+proc is_enabled {option} {
97
+ global enabled_options
98
+ if {[catch {set on $enabled_options($option)}]} {return 0}
99
+ return $on
100
+}
101
+
102
+proc enable_option {option} {
103
+ global enabled_options
104
+ set enabled_options($option) 1
105
+}
106
+
107
+proc disable_option {option} {
108
+ global enabled_options
109
+ set enabled_options($option) 0
110
+}
111
+
112
######################################################################
113
##
114
## config
@@ -303,9 +319,9 @@ set _reponame [lindex [file split \
319
[file normalize [file dirname $_gitdir]]] \
320
end]
321
306
-set single_commit 0
322
+enable_option multicommit
323
if {[appname] eq {git-citool}} {
308
- set single_commit 1
324
+ disable_option multicommit
325
}
326
327
######################################################################
@@ -400,7 +416,7 @@ proc rescan {after {honor_trustmtime 1}} {
416
global HEAD PARENT MERGE_HEAD commit_type
417
global ui_index ui_workdir ui_status_value ui_comm
418
global rescan_active file_states
403
- global repo_config single_commit
419
+ global repo_config
420
421
if {$rescan_active > 0 || ![lock_index read]} return
422
@@ -427,7 +443,7 @@ proc rescan {after {honor_trustmtime 1}} {
443
$ui_comm edit modified false
444
}
445
430
- if {!$single_commit} {
446
+ if {[is_enabled multicommit]} {
447
load_all_heads
448
populate_branch_menu
449
}
@@ -1181,7 +1197,7 @@ proc commit_writetree {curHEAD msg} {
1197
1198
proc commit_committree {fd_wt curHEAD msg} {
1199
global HEAD PARENT MERGE_HEAD commit_type
1184
- global single_commit all_heads current_branch
1200
+ global all_heads current_branch
1201
global ui_status_value ui_comm selected_commit_type
1202
global file_states selected_paths rescan_active
1203
global repo_config
@@ -1286,7 +1302,7 @@ proc commit_committree {fd_wt curHEAD msg} {
1302
$ui_comm edit reset
1303
$ui_comm edit modified false
1304
1289
- if {$single_commit} do_quit
1305
+ if {![is_enabled multicommit]} do_quit
1306
1307
# -- Update in memory status
1308
#
@@ -4902,11 +4918,11 @@ apply_config
4918
menu .mbar -tearoff 0
4919
.mbar add cascade -label Repository -menu .mbar.repository
4920
.mbar add cascade -label Edit -menu .mbar.edit
4905
-if {!$single_commit} {
4921
+if {[is_enabled multicommit]} {
4922
.mbar add cascade -label Branch -menu .mbar.branch
4923
}
4924
.mbar add cascade -label Commit -menu .mbar.commit
4909
-if {!$single_commit} {
4925
+if {[is_enabled multicommit]} {
4926
.mbar add cascade -label Merge -menu .mbar.merge
4927
.mbar add cascade -label Fetch -menu .mbar.fetch
4928
.mbar add cascade -label Push -menu .mbar.push
@@ -4933,7 +4949,7 @@ menu .mbar.repository
4949
-font font_ui
4950
.mbar.repository add separator
4951
4936
-if {!$single_commit} {
4952
+if {[is_enabled multicommit]} {
4953
.mbar.repository add command -label {Database Statistics} \
4954
-command do_stats \
4955
-font font_ui
@@ -5007,7 +5023,7 @@ menu .mbar.edit
5023
5024
# -- Branch Menu
5025
#
5010
-if {!$single_commit} {
5026
+if {[is_enabled multicommit]} {
5027
menu .mbar.branch
5028
5029
.mbar.branch add command -label {Create...} \
@@ -5214,7 +5230,7 @@ pack .branch.l1 -side left
5230
pack .branch.cb -side left -fill x
5231
pack .branch -side top -fill x
5232
5217
-if {!$single_commit} {
5233
+if {[is_enabled multicommit]} {
5234
menu .mbar.merge
5235
.mbar.merge add command -label {Local Merge...} \
5236
-command do_local_merge \
@@ -5686,7 +5702,7 @@ bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
5702
bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
5703
bind $ui_diff <Button-1> {focus %W}
5704
5689
-if {!$single_commit} {
5705
+if {[is_enabled multicommit]} {
5706
bind . <$M1B-Key-n> do_create_branch
5707
bind . <$M1B-Key-N> do_create_branch
5708
}
@@ -5783,7 +5799,7 @@ user.email settings into your personal
5799
5800
# -- Only initialize complex UI if we are going to stay running.
5801
#
5786
-if {!$single_commit} {
5802
+if {[is_enabled multicommit]} {
5803
load_all_remotes
5804
load_all_heads
5805
@@ -5794,7 +5810,7 @@ if {!$single_commit} {
5810
5811
# -- Only suggest a gc run if we are going to stay running.
5812
#
5797
-if {!$single_commit} {
5813
+if {[is_enabled multicommit]} {
5814
set object_limit 2000
5815
if {[is_Windows]} {set object_limit 200}
5816
regexp {^([0-9]+) objects,} [exec git count-objects] _junk objects_current