Skip to content

Commit ba41b5b

Browse files
bertwesargprati0100
authored andcommitted
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 <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent c77abf0 commit ba41b5b

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

git-gui.sh

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,14 +1341,14 @@ set HEAD {}
13411341
set PARENT {}
13421342
set MERGE_HEAD [list]
13431343
set commit_type {}
1344+
set commit_type_is_amend 0
13441345
set empty_tree {}
13451346
set current_branch {}
13461347
set is_detached 0
13471348
set current_diff_path {}
13481349
set is_3way_diff 0
13491350
set is_submodule_diff 0
13501351
set is_conflict_diff 0
1351-
set selected_commit_type new
13521352
set diff_empty_count 0
13531353
set last_revert {}
13541354
set last_revert_enc {}
@@ -1437,7 +1437,7 @@ proc PARENT {} {
14371437
}
14381438
14391439
proc force_amend {} {
1440-
global selected_commit_type
1440+
global commit_type_is_amend
14411441
global HEAD PARENT MERGE_HEAD commit_type
14421442
14431443
repository_state newType newHEAD newMERGE_HEAD
@@ -1446,7 +1446,7 @@ proc force_amend {} {
14461446
set MERGE_HEAD $newMERGE_HEAD
14471447
set commit_type $newType
14481448
1449-
set selected_commit_type amend
1449+
set commit_type_is_amend 1
14501450
do_select_commit_type
14511451
}
14521452
@@ -2852,19 +2852,10 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
28522852
menu .mbar.commit
28532853
28542854
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 \
28642856
-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
28682859
lappend disable_on_lock \
28692860
[list .mbar.commit entryconf [.mbar.commit index last] -state]
28702861
@@ -3337,18 +3328,10 @@ set ui_comm .vpane.lower.commarea.buffer.frame.t
33373328
set ui_coml .vpane.lower.commarea.buffer.header.l
33383329
33393330
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 \
33483332
-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
33523335
lappend disable_on_lock \
33533336
[list .vpane.lower.commarea.buffer.header.amend conf -state]
33543337
}
@@ -3373,7 +3356,6 @@ pack $ui_coml -side left -fill x
33733356
33743357
if {![is_enabled nocommit]} {
33753358
pack .vpane.lower.commarea.buffer.header.amend -side right
3376-
pack .vpane.lower.commarea.buffer.header.new -side right
33773359
}
33783360
33793361
textframe .vpane.lower.commarea.buffer.frame

lib/checkout_op.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ $err
389389
}
390390

391391
method _after_readtree {} {
392-
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
392+
global commit_type HEAD MERGE_HEAD PARENT
393393
global current_branch is_detached
394394
global ui_comm
395395

@@ -490,12 +490,12 @@ method _update_repo_state {} {
490490
# amend mode our file lists are accurate and we can avoid
491491
# the rescan.
492492
#
493-
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
493+
global commit_type_is_amend commit_type HEAD MERGE_HEAD PARENT
494494
global ui_comm
495495

496496
unlock_index
497497
set name [_name $this]
498-
set selected_commit_type new
498+
set commit_type_is_amend 0
499499
if {[string match amend* $commit_type]} {
500500
$ui_comm delete 0.0 end
501501
$ui_comm edit reset

lib/commit.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ proc commit_writetree {curHEAD msg_p} {
327327
proc commit_committree {fd_wt curHEAD msg_p} {
328328
global HEAD PARENT MERGE_HEAD commit_type commit_author
329329
global current_branch
330-
global ui_comm selected_commit_type
330+
global ui_comm commit_type_is_amend
331331
global file_states selected_paths rescan_active
332332
global repo_config
333333
global env
@@ -461,8 +461,8 @@ A rescan will be automatically started now.
461461

462462
# -- Update in memory status
463463
#
464-
set selected_commit_type new
465464
set commit_type normal
465+
set commit_type_is_amend 0
466466
set HEAD $cmt_id
467467
set PARENT $cmt_id
468468
set MERGE_HEAD [list]

lib/index.tcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,19 @@ proc do_revert_selection {} {
466466
}
467467

468468
proc do_select_commit_type {} {
469-
global commit_type selected_commit_type
469+
global commit_type commit_type_is_amend
470470

471-
if {$selected_commit_type eq {new}
471+
if {$commit_type_is_amend == 0
472472
&& [string match amend* $commit_type]} {
473473
create_new_commit
474-
} elseif {$selected_commit_type eq {amend}
474+
} elseif {$commit_type_is_amend == 1
475475
&& ![string match amend* $commit_type]} {
476476
load_last_commit
477477

478478
# The amend request was rejected...
479479
#
480480
if {![string match amend* $commit_type]} {
481-
set selected_commit_type new
481+
set commit_type_is_amend 0
482482
}
483483
}
484484
}

0 commit comments

Comments
 (0)