summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a90bff)
raw | patch | inline | side by side (parent: 6a90bff)
author | Paul Mackerras <paulus@samba.org> | |
Thu, 19 Oct 2006 00:09:06 +0000 (10:09 +1000) | ||
committer | Paul Mackerras <paulus@samba.org> | |
Sat, 23 Jun 2007 10:58:04 +0000 (20:58 +1000) |
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>
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>
gitk | patch | blob | history |
index 73324cfb7169a0c53d76c5ef6878097e7e29e33d..d6ed4f6c4050b3a4f0db462d531f6e7a161c1bfb 100755 (executable)
--- a/gitk
+++ b/gitk
$rowctxmenu add command -label "Create new branch" -command mkbranch
$rowctxmenu add command -label "Cherry-pick this commit" \
-command cherrypick
+ $rowctxmenu add command -label "Reset HEAD branch to here" \
+ -command resethead
set fakerowmenu .fakerowmenu
menu $fakerowmenu -tearoff 0
}
proc rowmenu {x y id} {
- global rowctxmenu commitrow selectedline rowmenuid curview nullid
- global fakerowmenu
+ global rowctxmenu commitrow selectedline rowmenuid curview
+ global nullid fakerowmenu mainhead
set rowmenuid $id
if {![info exists selectedline]
}
if {$id ne $nullid} {
set menu $rowctxmenu
+ $menu entryconfigure 7 -label "Reset $mainhead branch to here"
} else {
set menu $fakerowmenu
}
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
proc headmenu {x y id head} {
global headmenuid headmenuhead headctxmenu mainhead
redrawtags $headids($oldmainhead)
}
redrawtags $headmenuid
- if {$showlocalchanges} {
- dodiffindex
- }
+ }
+ if {$showlocalchanges} {
+ dodiffindex
}
}