Skip to content

Commit 6febded

Browse files
committed
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 <[email protected]>
1 parent 22387f2 commit 6febded

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

gitk

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,8 @@ proc makewindow {} {
25422542
{mc "Return to mark" command gotomark}
25432543
{mc "Find descendant of this and mark" command find_common_desc}
25442544
{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}}
25452547
}
25462548
$rowctxmenu configure -tearoff 0
25472549

@@ -2550,6 +2552,8 @@ proc makewindow {} {
25502552
{mc "Diff this -> selected" command {diffvssel 0}}
25512553
{mc "Diff selected -> this" command {diffvssel 1}}
25522554
{mc "Make patch" command mkpatch}
2555+
{mc "Diff this -> marked commit" command {diffvsmark 0}}
2556+
{mc "Diff marked commit -> this" command {diffvsmark 1}}
25532557
}
25542558
$fakerowmenu configure -tearoff 0
25552559

@@ -8495,28 +8499,29 @@ proc rowmenu {x y id} {
84958499
} else {
84968500
set state normal
84978501
}
8502+
if {[info exists markedid] && $markedid ne $id} {
8503+
set mstate normal
8504+
} else {
8505+
set mstate disabled
8506+
}
84988507
if {$id ne $nullid && $id ne $nullid2} {
84998508
set menu $rowctxmenu
85008509
if {$mainhead ne {}} {
85018510
$menu entryconfigure 7 -label [mc "Reset %s branch to here" $mainhead] -state normal
85028511
} else {
85038512
$menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
85048513
}
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
85148517
} else {
85158518
set menu $fakerowmenu
85168519
}
85178520
$menu entryconfigure [mca "Diff this -> selected"] -state $state
85188521
$menu entryconfigure [mca "Diff selected -> this"] -state $state
85198522
$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
85208525
tk_popup $menu $x $y
85218526
}
85228527

@@ -8720,6 +8725,21 @@ proc diffvssel {dirn} {
87208725
doseldiff $oldid $newid
87218726
}
87228727

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+
87238743
proc doseldiff {oldid newid} {
87248744
global ctext
87258745
global commitinfo

0 commit comments

Comments
 (0)