gitk: Add a "reset branch to here" row context-menu operation
This adds an entry to the menu that comes up when the user does a right-click on a row. The new entry allows the user to reset the currently checked-out head to the commit for the row that they did the right-click on. The user has to select what type of reset to do, and confirm the reset, via a dialog box that pops up. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
6a90bff1e8
commit
6fb735aedb
62
gitk
62
gitk
@ -873,6 +873,8 @@ proc makewindow {} {
|
|||||||
$rowctxmenu add command -label "Create new branch" -command mkbranch
|
$rowctxmenu add command -label "Create new branch" -command mkbranch
|
||||||
$rowctxmenu add command -label "Cherry-pick this commit" \
|
$rowctxmenu add command -label "Cherry-pick this commit" \
|
||||||
-command cherrypick
|
-command cherrypick
|
||||||
|
$rowctxmenu add command -label "Reset HEAD branch to here" \
|
||||||
|
-command resethead
|
||||||
|
|
||||||
set fakerowmenu .fakerowmenu
|
set fakerowmenu .fakerowmenu
|
||||||
menu $fakerowmenu -tearoff 0
|
menu $fakerowmenu -tearoff 0
|
||||||
@ -5377,8 +5379,8 @@ proc mstime {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc rowmenu {x y id} {
|
proc rowmenu {x y id} {
|
||||||
global rowctxmenu commitrow selectedline rowmenuid curview nullid
|
global rowctxmenu commitrow selectedline rowmenuid curview
|
||||||
global fakerowmenu
|
global nullid fakerowmenu mainhead
|
||||||
|
|
||||||
set rowmenuid $id
|
set rowmenuid $id
|
||||||
if {![info exists selectedline]
|
if {![info exists selectedline]
|
||||||
@ -5389,6 +5391,7 @@ proc rowmenu {x y id} {
|
|||||||
}
|
}
|
||||||
if {$id ne $nullid} {
|
if {$id ne $nullid} {
|
||||||
set menu $rowctxmenu
|
set menu $rowctxmenu
|
||||||
|
$menu entryconfigure 7 -label "Reset $mainhead branch to here"
|
||||||
} else {
|
} else {
|
||||||
set menu $fakerowmenu
|
set menu $fakerowmenu
|
||||||
}
|
}
|
||||||
@ -5775,6 +5778,55 @@ proc cherrypick {} {
|
|||||||
notbusy cherrypick
|
notbusy cherrypick
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc resethead {} {
|
||||||
|
global mainheadid mainhead rowmenuid confirm_ok resettype
|
||||||
|
global showlocalchanges
|
||||||
|
|
||||||
|
set confirm_ok 0
|
||||||
|
set w ".confirmreset"
|
||||||
|
toplevel $w
|
||||||
|
wm transient $w .
|
||||||
|
wm title $w "Confirm reset"
|
||||||
|
message $w.m -text \
|
||||||
|
"Reset branch $mainhead to [string range $rowmenuid 0 7]?" \
|
||||||
|
-justify center -aspect 1000
|
||||||
|
pack $w.m -side top -fill x -padx 20 -pady 20
|
||||||
|
frame $w.f -relief sunken -border 2
|
||||||
|
message $w.f.rt -text "Reset type:" -aspect 1000
|
||||||
|
grid $w.f.rt -sticky w
|
||||||
|
set resettype mixed
|
||||||
|
radiobutton $w.f.soft -value soft -variable resettype -justify left \
|
||||||
|
-text "Soft: Leave working tree and index untouched"
|
||||||
|
grid $w.f.soft -sticky w
|
||||||
|
radiobutton $w.f.mixed -value mixed -variable resettype -justify left \
|
||||||
|
-text "Mixed: Leave working tree untouched, reset index"
|
||||||
|
grid $w.f.mixed -sticky w
|
||||||
|
radiobutton $w.f.hard -value hard -variable resettype -justify left \
|
||||||
|
-text "Hard: Reset working tree and index\n(discard ALL local changes)"
|
||||||
|
grid $w.f.hard -sticky w
|
||||||
|
pack $w.f -side top -fill x
|
||||||
|
button $w.ok -text OK -command "set confirm_ok 1; destroy $w"
|
||||||
|
pack $w.ok -side left -fill x -padx 20 -pady 20
|
||||||
|
button $w.cancel -text Cancel -command "destroy $w"
|
||||||
|
pack $w.cancel -side right -fill x -padx 20 -pady 20
|
||||||
|
bind $w <Visibility> "grab $w; focus $w"
|
||||||
|
tkwait window $w
|
||||||
|
if {!$confirm_ok} return
|
||||||
|
dohidelocalchanges
|
||||||
|
if {[catch {exec git reset --$resettype $rowmenuid} err]} {
|
||||||
|
error_popup $err
|
||||||
|
} else {
|
||||||
|
set oldhead $mainheadid
|
||||||
|
movedhead $rowmenuid $mainhead
|
||||||
|
set mainheadid $rowmenuid
|
||||||
|
redrawtags $oldhead
|
||||||
|
redrawtags $rowmenuid
|
||||||
|
}
|
||||||
|
if {$showlocalchanges} {
|
||||||
|
doshowlocalchanges
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# context menu for a head
|
# context menu for a head
|
||||||
proc headmenu {x y id head} {
|
proc headmenu {x y id head} {
|
||||||
global headmenuid headmenuhead headctxmenu mainhead
|
global headmenuid headmenuhead headctxmenu mainhead
|
||||||
@ -5812,9 +5864,9 @@ proc cobranch {} {
|
|||||||
redrawtags $headids($oldmainhead)
|
redrawtags $headids($oldmainhead)
|
||||||
}
|
}
|
||||||
redrawtags $headmenuid
|
redrawtags $headmenuid
|
||||||
if {$showlocalchanges} {
|
}
|
||||||
dodiffindex
|
if {$showlocalchanges} {
|
||||||
}
|
dodiffindex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user