git-gui: convert new/amend commit radiobutton to checkbutton
Its a bi-state anyway and also saves one line in the menu. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
Bert Wesarg committed
Sep 13, 2019 at 08:02 UTC
ba41b5b335b00ac1cb277c83b87ebf3c26b670c0
4 files changed
+18
-36
git-gui.sh
+9
-27
@@ -1341,6 +1341,7 @@ set HEAD {}
1341
set PARENT {}
1342
set MERGE_HEAD [list]
1343
set commit_type {}
1344
+set commit_type_is_amend 0
1345
set empty_tree {}
1346
set current_branch {}
1347
set is_detached 0
@@ -1348,7 +1349,6 @@ set current_diff_path {}
1349
set is_3way_diff 0
1350
set is_submodule_diff 0
1351
set is_conflict_diff 0
1351
-set selected_commit_type new
1352
set diff_empty_count 0
1353
set last_revert {}
1354
set last_revert_enc {}
@@ -1437,7 +1437,7 @@ proc PARENT {} {
1437
}
1438
1439
proc force_amend {} {
1440
- global selected_commit_type
1440
+ global commit_type_is_amend
1441
global HEAD PARENT MERGE_HEAD commit_type
1442
1443
repository_state newType newHEAD newMERGE_HEAD
@@ -1446,7 +1446,7 @@ proc force_amend {} {
1446
set MERGE_HEAD $newMERGE_HEAD
1447
set commit_type $newType
1448
1449
- set selected_commit_type amend
1449
+ set commit_type_is_amend 1
1450
do_select_commit_type
1451
}
1452
@@ -2852,19 +2852,10 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2852
menu .mbar.commit
2853
2854
if {![is_enabled nocommit]} {
2855
- .mbar.commit add radiobutton \
2856
- -label [mc "New Commit"] \
2857
- -command do_select_commit_type \
2858
- -variable selected_commit_type \
2859
- -value new
2860
- lappend disable_on_lock \
2861
- [list .mbar.commit entryconf [.mbar.commit index last] -state]
2862
-
2863
- .mbar.commit add radiobutton \
2855
+ .mbar.commit add checkbutton \
2856
-label [mc "Amend Last Commit"] \
2865
- -command do_select_commit_type \
2866
- -variable selected_commit_type \
2867
- -value amend
2857
+ -variable commit_type_is_amend \
2858
+ -command do_select_commit_type
2859
lappend disable_on_lock \
2860
[list .mbar.commit entryconf [.mbar.commit index last] -state]
2861
@@ -3337,18 +3328,10 @@ set ui_comm .vpane.lower.commarea.buffer.frame.t
3328
set ui_coml .vpane.lower.commarea.buffer.header.l
3329
3330
if {![is_enabled nocommit]} {
3340
- ${NS}::radiobutton .vpane.lower.commarea.buffer.header.new \
3341
- -text [mc "New Commit"] \
3342
- -command do_select_commit_type \
3343
- -variable selected_commit_type \
3344
- -value new
3345
- lappend disable_on_lock \
3346
- [list .vpane.lower.commarea.buffer.header.new conf -state]
3347
- ${NS}::radiobutton .vpane.lower.commarea.buffer.header.amend \
3331
+ ${NS}::checkbutton .vpane.lower.commarea.buffer.header.amend \
3332
-text [mc "Amend Last Commit"] \
3349
- -command do_select_commit_type \
3350
- -variable selected_commit_type \
3351
- -value amend
3333
+ -variable commit_type_is_amend \
3334
+ -command do_select_commit_type
3335
lappend disable_on_lock \
3336
[list .vpane.lower.commarea.buffer.header.amend conf -state]
3337
}
@@ -3373,7 +3356,6 @@ pack $ui_coml -side left -fill x
3356
3357
if {![is_enabled nocommit]} {
3358
pack .vpane.lower.commarea.buffer.header.amend -side right
3376
- pack .vpane.lower.commarea.buffer.header.new -side right
3359
}
3360
3361
textframe .vpane.lower.commarea.buffer.frame
lib/checkout_op.tcl
+3
-3
@@ -389,7 +389,7 @@ $err
389
}
390
391
method _after_readtree {} {
392
- global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
392
+ global commit_type HEAD MERGE_HEAD PARENT
393
global current_branch is_detached
394
global ui_comm
395
@@ -490,12 +490,12 @@ method _update_repo_state {} {
490
# amend mode our file lists are accurate and we can avoid
491
# the rescan.
492
#
493
- global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
493
+ global commit_type_is_amend commit_type HEAD MERGE_HEAD PARENT
494
global ui_comm
495
496
unlock_index
497
set name [_name $this]
498
- set selected_commit_type new
498
+ set commit_type_is_amend 0
499
if {[string match amend* $commit_type]} {
500
$ui_comm delete 0.0 end
501
$ui_comm edit reset
lib/commit.tcl
+2
-2
@@ -327,7 +327,7 @@ proc commit_writetree {curHEAD msg_p} {
327
proc commit_committree {fd_wt curHEAD msg_p} {
328
global HEAD PARENT MERGE_HEAD commit_type commit_author
329
global current_branch
330
- global ui_comm selected_commit_type
330
+ global ui_comm commit_type_is_amend
331
global file_states selected_paths rescan_active
332
global repo_config
333
global env
@@ -461,8 +461,8 @@ A rescan will be automatically started now.
461
462
# -- Update in memory status
463
#
464
- set selected_commit_type new
464
set commit_type normal
465
+ set commit_type_is_amend 0
466
set HEAD $cmt_id
467
set PARENT $cmt_id
468
set MERGE_HEAD [list]
lib/index.tcl
+4
-4
@@ -466,19 +466,19 @@ proc do_revert_selection {} {
466
}
467
468
proc do_select_commit_type {} {
469
- global commit_type selected_commit_type
469
+ global commit_type commit_type_is_amend
470
471
- if {$selected_commit_type eq {new}
471
+ if {$commit_type_is_amend == 0
472
&& [string match amend* $commit_type]} {
473
create_new_commit
474
- } elseif {$selected_commit_type eq {amend}
474
+ } elseif {$commit_type_is_amend == 1
475
&& ![string match amend* $commit_type]} {
476
load_last_commit
477
478
# The amend request was rejected...
479
#
480
if {![string match amend* $commit_type]} {
481
- set selected_commit_type new
481
+ set commit_type_is_amend 0
482
}
483
}
484
}