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>
This commit is contained in:
Bert Wesarg 2019-09-13 08:02:30 +02:00 committed by Pratyush Yadav
parent c77abf0460
commit ba41b5b335
4 changed files with 18 additions and 36 deletions

View File

@ -1341,6 +1341,7 @@ set HEAD {}
set PARENT {} set PARENT {}
set MERGE_HEAD [list] set MERGE_HEAD [list]
set commit_type {} set commit_type {}
set commit_type_is_amend 0
set empty_tree {} set empty_tree {}
set current_branch {} set current_branch {}
set is_detached 0 set is_detached 0
@ -1348,7 +1349,6 @@ set current_diff_path {}
set is_3way_diff 0 set is_3way_diff 0
set is_submodule_diff 0 set is_submodule_diff 0
set is_conflict_diff 0 set is_conflict_diff 0
set selected_commit_type new
set diff_empty_count 0 set diff_empty_count 0
set last_revert {} set last_revert {}
set last_revert_enc {} set last_revert_enc {}
@ -1437,7 +1437,7 @@ proc PARENT {} {
} }
proc force_amend {} { proc force_amend {} {
global selected_commit_type global commit_type_is_amend
global HEAD PARENT MERGE_HEAD commit_type global HEAD PARENT MERGE_HEAD commit_type
repository_state newType newHEAD newMERGE_HEAD repository_state newType newHEAD newMERGE_HEAD
@ -1446,7 +1446,7 @@ proc force_amend {} {
set MERGE_HEAD $newMERGE_HEAD set MERGE_HEAD $newMERGE_HEAD
set commit_type $newType set commit_type $newType
set selected_commit_type amend set commit_type_is_amend 1
do_select_commit_type do_select_commit_type
} }
@ -2852,19 +2852,10 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
menu .mbar.commit menu .mbar.commit
if {![is_enabled nocommit]} { if {![is_enabled nocommit]} {
.mbar.commit add radiobutton \ .mbar.commit add checkbutton \
-label [mc "New Commit"] \
-command do_select_commit_type \
-variable selected_commit_type \
-value new
lappend disable_on_lock \
[list .mbar.commit entryconf [.mbar.commit index last] -state]
.mbar.commit add radiobutton \
-label [mc "Amend Last Commit"] \ -label [mc "Amend Last Commit"] \
-command do_select_commit_type \ -variable commit_type_is_amend \
-variable selected_commit_type \ -command do_select_commit_type
-value amend
lappend disable_on_lock \ lappend disable_on_lock \
[list .mbar.commit entryconf [.mbar.commit index last] -state] [list .mbar.commit entryconf [.mbar.commit index last] -state]
@ -3337,18 +3328,10 @@ set ui_comm .vpane.lower.commarea.buffer.frame.t
set ui_coml .vpane.lower.commarea.buffer.header.l set ui_coml .vpane.lower.commarea.buffer.header.l
if {![is_enabled nocommit]} { if {![is_enabled nocommit]} {
${NS}::radiobutton .vpane.lower.commarea.buffer.header.new \ ${NS}::checkbutton .vpane.lower.commarea.buffer.header.amend \
-text [mc "New Commit"] \
-command do_select_commit_type \
-variable selected_commit_type \
-value new
lappend disable_on_lock \
[list .vpane.lower.commarea.buffer.header.new conf -state]
${NS}::radiobutton .vpane.lower.commarea.buffer.header.amend \
-text [mc "Amend Last Commit"] \ -text [mc "Amend Last Commit"] \
-command do_select_commit_type \ -variable commit_type_is_amend \
-variable selected_commit_type \ -command do_select_commit_type
-value amend
lappend disable_on_lock \ lappend disable_on_lock \
[list .vpane.lower.commarea.buffer.header.amend conf -state] [list .vpane.lower.commarea.buffer.header.amend conf -state]
} }
@ -3373,7 +3356,6 @@ pack $ui_coml -side left -fill x
if {![is_enabled nocommit]} { if {![is_enabled nocommit]} {
pack .vpane.lower.commarea.buffer.header.amend -side right pack .vpane.lower.commarea.buffer.header.amend -side right
pack .vpane.lower.commarea.buffer.header.new -side right
} }
textframe .vpane.lower.commarea.buffer.frame textframe .vpane.lower.commarea.buffer.frame

View File

@ -389,7 +389,7 @@ $err
} }
method _after_readtree {} { method _after_readtree {} {
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT global commit_type HEAD MERGE_HEAD PARENT
global current_branch is_detached global current_branch is_detached
global ui_comm global ui_comm
@ -490,12 +490,12 @@ method _update_repo_state {} {
# amend mode our file lists are accurate and we can avoid # amend mode our file lists are accurate and we can avoid
# the rescan. # the rescan.
# #
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT global commit_type_is_amend commit_type HEAD MERGE_HEAD PARENT
global ui_comm global ui_comm
unlock_index unlock_index
set name [_name $this] set name [_name $this]
set selected_commit_type new set commit_type_is_amend 0
if {[string match amend* $commit_type]} { if {[string match amend* $commit_type]} {
$ui_comm delete 0.0 end $ui_comm delete 0.0 end
$ui_comm edit reset $ui_comm edit reset

View File

@ -327,7 +327,7 @@ proc commit_writetree {curHEAD msg_p} {
proc commit_committree {fd_wt curHEAD msg_p} { proc commit_committree {fd_wt curHEAD msg_p} {
global HEAD PARENT MERGE_HEAD commit_type commit_author global HEAD PARENT MERGE_HEAD commit_type commit_author
global current_branch global current_branch
global ui_comm selected_commit_type global ui_comm commit_type_is_amend
global file_states selected_paths rescan_active global file_states selected_paths rescan_active
global repo_config global repo_config
global env global env
@ -461,8 +461,8 @@ A rescan will be automatically started now.
# -- Update in memory status # -- Update in memory status
# #
set selected_commit_type new
set commit_type normal set commit_type normal
set commit_type_is_amend 0
set HEAD $cmt_id set HEAD $cmt_id
set PARENT $cmt_id set PARENT $cmt_id
set MERGE_HEAD [list] set MERGE_HEAD [list]

View File

@ -466,19 +466,19 @@ proc do_revert_selection {} {
} }
proc do_select_commit_type {} { proc do_select_commit_type {} {
global commit_type selected_commit_type global commit_type commit_type_is_amend
if {$selected_commit_type eq {new} if {$commit_type_is_amend == 0
&& [string match amend* $commit_type]} { && [string match amend* $commit_type]} {
create_new_commit create_new_commit
} elseif {$selected_commit_type eq {amend} } elseif {$commit_type_is_amend == 1
&& ![string match amend* $commit_type]} { && ![string match amend* $commit_type]} {
load_last_commit load_last_commit
# The amend request was rejected... # The amend request was rejected...
# #
if {![string match amend* $commit_type]} { if {![string match amend* $commit_type]} {
set selected_commit_type new set commit_type_is_amend 0
} }
} }
} }