Skip to content

Commit

Permalink
gitk: Add menu items for comparing a commit with the marked commit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mackerras committed Mar 23, 2012
1 parent 22387f2 commit 6febded
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,8 @@ proc makewindow {} {
{mc "Return to mark" command gotomark}
{mc "Find descendant of this and mark" command find_common_desc}
{mc "Compare with marked commit" command compare_commits}
{mc "Diff this -> marked commit" command {diffvsmark 0}}
{mc "Diff marked commit -> this" command {diffvsmark 1}}
}
$rowctxmenu configure -tearoff 0

Expand All @@ -2550,6 +2552,8 @@ proc makewindow {} {
{mc "Diff this -> selected" command {diffvssel 0}}
{mc "Diff selected -> this" command {diffvssel 1}}
{mc "Make patch" command mkpatch}
{mc "Diff this -> marked commit" command {diffvsmark 0}}
{mc "Diff marked commit -> this" command {diffvsmark 1}}
}
$fakerowmenu configure -tearoff 0

Expand Down Expand Up @@ -8495,28 +8499,29 @@ proc rowmenu {x y id} {
} else {
set state normal
}
if {[info exists markedid] && $markedid ne $id} {
set mstate normal
} else {
set mstate disabled
}
if {$id ne $nullid && $id ne $nullid2} {
set menu $rowctxmenu
if {$mainhead ne {}} {
$menu entryconfigure 7 -label [mc "Reset %s branch to here" $mainhead] -state normal
} else {
$menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
}
if {[info exists markedid] && $markedid ne $id} {
$menu entryconfigure 9 -state normal
$menu entryconfigure 10 -state normal
$menu entryconfigure 11 -state normal
} else {
$menu entryconfigure 9 -state disabled
$menu entryconfigure 10 -state disabled
$menu entryconfigure 11 -state disabled
}
$menu entryconfigure 9 -state $mstate
$menu entryconfigure 10 -state $mstate
$menu entryconfigure 11 -state $mstate
} else {
set menu $fakerowmenu
}
$menu entryconfigure [mca "Diff this -> selected"] -state $state
$menu entryconfigure [mca "Diff selected -> this"] -state $state
$menu entryconfigure [mca "Make patch"] -state $state
$menu entryconfigure [mca "Diff this -> marked commit"] -state $mstate
$menu entryconfigure [mca "Diff marked commit -> this"] -state $mstate
tk_popup $menu $x $y
}

Expand Down Expand Up @@ -8720,6 +8725,21 @@ proc diffvssel {dirn} {
doseldiff $oldid $newid
}

proc diffvsmark {dirn} {
global rowmenuid markedid

if {![info exists markedid]} return
if {$dirn} {
set oldid $markedid
set newid $rowmenuid
} else {
set oldid $rowmenuid
set newid $markedid
}
addtohistory [list doseldiff $oldid $newid] savectextpos
doseldiff $oldid $newid
}

proc doseldiff {oldid newid} {
global ctext
global commitinfo
Expand Down

0 comments on commit 6febded

Please sign in to comment.