@@ -873,6 +873,8 @@ proc makewindow {} {
873
873
$rowctxmenu add command -label " Create new branch" -command mkbranch
874
874
$rowctxmenu add command -label " Cherry-pick this commit" \
875
875
-command cherrypick
876
+ $rowctxmenu add command -label " Reset HEAD branch to here" \
877
+ -command resethead
876
878
877
879
set fakerowmenu .fakerowmenu
878
880
menu $fakerowmenu -tearoff 0
@@ -5377,8 +5379,8 @@ proc mstime {} {
5377
5379
}
5378
5380
5379
5381
proc rowmenu {x y id} {
5380
- global rowctxmenu commitrow selectedline rowmenuid curview nullid
5381
- global fakerowmenu
5382
+ global rowctxmenu commitrow selectedline rowmenuid curview
5383
+ global nullid fakerowmenu mainhead
5382
5384
5383
5385
set rowmenuid $id
5384
5386
if {![info exists selectedline]
@@ -5389,6 +5391,7 @@ proc rowmenu {x y id} {
5389
5391
}
5390
5392
if {$id ne $nullid } {
5391
5393
set menu $rowctxmenu
5394
+ $menu entryconfigure 7 -label " Reset $mainhead branch to here"
5392
5395
} else {
5393
5396
set menu $fakerowmenu
5394
5397
}
@@ -5775,6 +5778,55 @@ proc cherrypick {} {
5775
5778
notbusy cherrypick
5776
5779
}
5777
5780
5781
+ proc resethead {} {
5782
+ global mainheadid mainhead rowmenuid confirm_ok resettype
5783
+ global showlocalchanges
5784
+
5785
+ set confirm_ok 0
5786
+ set w " .confirmreset"
5787
+ toplevel $w
5788
+ wm transient $w .
5789
+ wm title $w " Confirm reset"
5790
+ message $w .m -text \
5791
+ " Reset branch $mainhead to [ string range $rowmenuid 0 7] ?" \
5792
+ -justify center -aspect 1000
5793
+ pack $w .m -side top -fill x -padx 20 -pady 20
5794
+ frame $w .f -relief sunken -border 2
5795
+ message $w .f.rt -text " Reset type:" -aspect 1000
5796
+ grid $w .f.rt -sticky w
5797
+ set resettype mixed
5798
+ radiobutton $w .f.soft -value soft -variable resettype -justify left \
5799
+ -text " Soft: Leave working tree and index untouched"
5800
+ grid $w .f.soft -sticky w
5801
+ radiobutton $w .f.mixed -value mixed -variable resettype -justify left \
5802
+ -text " Mixed: Leave working tree untouched, reset index"
5803
+ grid $w .f.mixed -sticky w
5804
+ radiobutton $w .f.hard -value hard -variable resettype -justify left \
5805
+ -text " Hard: Reset working tree and index\n (discard ALL local changes)"
5806
+ grid $w .f.hard -sticky w
5807
+ pack $w .f -side top -fill x
5808
+ button $w .ok -text OK -command " set confirm_ok 1; destroy $w "
5809
+ pack $w .ok -side left -fill x -padx 20 -pady 20
5810
+ button $w .cancel -text Cancel -command " destroy $w "
5811
+ pack $w .cancel -side right -fill x -padx 20 -pady 20
5812
+ bind $w <Visibility> " grab $w ; focus $w "
5813
+ tkwait window $w
5814
+ if {!$confirm_ok } return
5815
+ dohidelocalchanges
5816
+ if {[catch {exec git reset --$resettype $rowmenuid } err]} {
5817
+ error_popup $err
5818
+ } else {
5819
+ set oldhead $mainheadid
5820
+ movedhead $rowmenuid $mainhead
5821
+ set mainheadid $rowmenuid
5822
+ redrawtags $oldhead
5823
+ redrawtags $rowmenuid
5824
+ }
5825
+ if {$showlocalchanges } {
5826
+ doshowlocalchanges
5827
+ }
5828
+ }
5829
+
5778
5830
# context menu for a head
5779
5831
proc headmenu {x y id head} {
5780
5832
global headmenuid headmenuhead headctxmenu mainhead
@@ -5812,9 +5864,9 @@ proc cobranch {} {
5812
5864
redrawtags $headids($oldmainhead)
5813
5865
}
5814
5866
redrawtags $headmenuid
5815
- if { $showlocalchanges } {
5816
- dodiffindex
5817
- }
5867
+ }
5868
+ if { $showlocalchanges } {
5869
+ dodiffindex
5818
5870
}
5819
5871
}
5820
5872
0 commit comments