Skip to content

Commit

Permalink
gitk: Cope better with getting commits that we have already seen
Browse files Browse the repository at this point in the history
This fixes a bug in updating the graph after we have cherry-picked
a commit in gitk and then added some new stuff externally.  First,
we weren't updating viewincl with the new head added by the cherry-
pick.  Secondly, getcommitlines was doing bad things if it saw a
commit that was already in the graph (was already in an arc).  This
fixes both things.  If getcommitlines sees a commit that is already
in the graph, it ignores it unless it was not listed before and is
listed now.  In that case it doesn't assign it a new arc now, and
doesn't re-add the commit to its arc.

Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Paul Mackerras committed Feb 16, 2008
1 parent b8a938c commit f1bf4ee
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,11 @@ proc getcommitlines {fd inst view} {
}
set id [lindex $ids 0]
set vid $view,$id
if {!$listed && [info exists parents($vid)]} continue
set a 0
if {[info exists varcid($vid)]} {
if {$cmitlisted($vid) || !$listed} continue
set a $varcid($vid)
}
if {$listed} {
set olds [lrange $ids 1 end]
} else {
Expand All @@ -1074,10 +1078,9 @@ proc getcommitlines {fd inst view} {
set commitdata($id) [string range $cmit [expr {$j + 1}] end]
set cmitlisted($vid) $listed
set parents($vid) $olds
set a 0
if {![info exists children($vid)]} {
set children($vid) {}
} elseif {[llength $children($vid)] == 1} {
} elseif {$a == 0 && [llength $children($vid)] == 1} {
set k [lindex $children($vid) 0]
if {[llength $parents($view,$k)] == 1 &&
(!$datemode ||
Expand All @@ -1089,11 +1092,14 @@ proc getcommitlines {fd inst view} {
# new arc
set a [newvarc $view $id]
}
set varcid($vid) $a
if {[string compare [lindex $varctok($view) $a] $vtokmod($view)] < 0} {
modify_arc $view $a
}
lappend varccommits($view,$a) $id
if {![info exists varcid($vid)]} {
set varcid($vid) $a
lappend varccommits($view,$a) $id
incr commitidx($view)
}

set i 0
foreach p $olds {
Expand All @@ -1112,7 +1118,6 @@ proc getcommitlines {fd inst view} {
incr i
}

incr commitidx($view)
if {[info exists commitinterest($id)]} {
foreach script $commitinterest($id) {
lappend scripts [string map [list "%I" $id] $script]
Expand Down Expand Up @@ -7035,7 +7040,7 @@ proc mkbrgo {top} {
}

proc cherrypick {} {
global rowmenuid curview
global rowmenuid curview viewincl
global mainhead mainheadid

set oldhead [exec git rev-parse HEAD]
Expand Down Expand Up @@ -7069,6 +7074,12 @@ proc cherrypick {} {
movedhead $newhead $mainhead
set mainheadid $newhead
}
# remove oldhead from viewincl and add newhead
set i [lsearch -exact $viewincl($curview) $oldhead]
if {$i >= 0} {
set viewincl($curview) [lreplace $viewincl($curview) $i $i]
}
lappend viewincl($curview) $newhead
redrawtags $oldhead
redrawtags $newhead
selbyid $newhead
Expand Down

0 comments on commit f1bf4ee

Please sign in to comment.