gitk: Add menu items for comparing a commit with the marked commit
Sometimes one wants to see the different between two commits that are a long distance apart in the graph display. This is difficult to do with the "Diff this -> selected" and "Diff selected -> this" menu items because the need to maintain the selection means that one can't use the find facilities or the reference list window to navigate from one to the other. This provides an alternative using the mark. Having found one commit, one marks it with the "Mark this commit" menu item, then navigates to the other commit and uses the new "Diff this -> marked commit" and/or "Diff marked commit -> this" menu items. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Mar 23, 2012 at 22:07 UTC
6febdede5acdbab192d955d4e0cd810f3fbee27f
1 file changed
+29
-9
gitk
+29
-9
@@ -2542,6 +2542,8 @@ proc makewindow {} {
2542
{mc "Return to mark" command gotomark}
2543
{mc "Find descendant of this and mark" command find_common_desc}
2544
{mc "Compare with marked commit" command compare_commits}
2545
+ {mc "Diff this -> marked commit" command {diffvsmark 0}}
2546
+ {mc "Diff marked commit -> this" command {diffvsmark 1}}
2547
}
2548
$rowctxmenu configure -tearoff 0
2549
@@ -2550,6 +2552,8 @@ proc makewindow {} {
2552
{mc "Diff this -> selected" command {diffvssel 0}}
2553
{mc "Diff selected -> this" command {diffvssel 1}}
2554
{mc "Make patch" command mkpatch}
2555
+ {mc "Diff this -> marked commit" command {diffvsmark 0}}
2556
+ {mc "Diff marked commit -> this" command {diffvsmark 1}}
2557
}
2558
$fakerowmenu configure -tearoff 0
2559
@@ -8495,6 +8499,11 @@ proc rowmenu {x y id} {
8499
} else {
8500
set state normal
8501
}
8502
+ if {[info exists markedid] && $markedid ne $id} {
8503
+ set mstate normal
8504
+ } else {
8505
+ set mstate disabled
8506
+ }
8507
if {$id ne $nullid && $id ne $nullid2} {
8508
set menu $rowctxmenu
8509
if {$mainhead ne {}} {
@@ -8502,21 +8511,17 @@ proc rowmenu {x y id} {
8511
} else {
8512
$menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
8513
}
8505
- if {[info exists markedid] && $markedid ne $id} {
8506
- $menu entryconfigure 9 -state normal
8507
- $menu entryconfigure 10 -state normal
8508
- $menu entryconfigure 11 -state normal
8509
- } else {
8510
- $menu entryconfigure 9 -state disabled
8511
- $menu entryconfigure 10 -state disabled
8512
- $menu entryconfigure 11 -state disabled
8513
- }
8514
+ $menu entryconfigure 9 -state $mstate
8515
+ $menu entryconfigure 10 -state $mstate
8516
+ $menu entryconfigure 11 -state $mstate
8517
} else {
8518
set menu $fakerowmenu
8519
}
8520
$menu entryconfigure [mca "Diff this -> selected"] -state $state
8521
$menu entryconfigure [mca "Diff selected -> this"] -state $state
8522
$menu entryconfigure [mca "Make patch"] -state $state
8523
+ $menu entryconfigure [mca "Diff this -> marked commit"] -state $mstate
8524
+ $menu entryconfigure [mca "Diff marked commit -> this"] -state $mstate
8525
tk_popup $menu $x $y
8526
}
8527
@@ -8720,6 +8725,21 @@ proc diffvssel {dirn} {
8725
doseldiff $oldid $newid
8726
}
8727
8728
+proc diffvsmark {dirn} {
8729
+ global rowmenuid markedid
8730
+
8731
+ if {![info exists markedid]} return
8732
+ if {$dirn} {
8733
+ set oldid $markedid
8734
+ set newid $rowmenuid
8735
+ } else {
8736
+ set oldid $rowmenuid
8737
+ set newid $markedid
8738
+ }
8739
+ addtohistory [list doseldiff $oldid $newid] savectextpos
8740
+ doseldiff $oldid $newid
8741
+}
8742
+
8743
proc doseldiff {oldid newid} {
8744
global ctext
8745
global commitinfo