Skip to content

Commit f1bf4ee

Browse files
committed
gitk: Cope better with getting commits that we have already seen
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>
1 parent b8a938c commit f1bf4ee

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

gitk

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,11 @@ proc getcommitlines {fd inst view} {
10651065
}
10661066
set id [lindex $ids 0]
10671067
set vid $view,$id
1068-
if {!$listed && [info exists parents($vid)]} continue
1068+
set a 0
1069+
if {[info exists varcid($vid)]} {
1070+
if {$cmitlisted($vid) || !$listed} continue
1071+
set a $varcid($vid)
1072+
}
10691073
if {$listed} {
10701074
set olds [lrange $ids 1 end]
10711075
} else {
@@ -1074,10 +1078,9 @@ proc getcommitlines {fd inst view} {
10741078
set commitdata($id) [string range $cmit [expr {$j + 1}] end]
10751079
set cmitlisted($vid) $listed
10761080
set parents($vid) $olds
1077-
set a 0
10781081
if {![info exists children($vid)]} {
10791082
set children($vid) {}
1080-
} elseif {[llength $children($vid)] == 1} {
1083+
} elseif {$a == 0 && [llength $children($vid)] == 1} {
10811084
set k [lindex $children($vid) 0]
10821085
if {[llength $parents($view,$k)] == 1 &&
10831086
(!$datemode ||
@@ -1089,11 +1092,14 @@ proc getcommitlines {fd inst view} {
10891092
# new arc
10901093
set a [newvarc $view $id]
10911094
}
1092-
set varcid($vid) $a
10931095
if {[string compare [lindex $varctok($view) $a] $vtokmod($view)] < 0} {
10941096
modify_arc $view $a
10951097
}
1096-
lappend varccommits($view,$a) $id
1098+
if {![info exists varcid($vid)]} {
1099+
set varcid($vid) $a
1100+
lappend varccommits($view,$a) $id
1101+
incr commitidx($view)
1102+
}
10971103

10981104
set i 0
10991105
foreach p $olds {
@@ -1112,7 +1118,6 @@ proc getcommitlines {fd inst view} {
11121118
incr i
11131119
}
11141120

1115-
incr commitidx($view)
11161121
if {[info exists commitinterest($id)]} {
11171122
foreach script $commitinterest($id) {
11181123
lappend scripts [string map [list "%I" $id] $script]
@@ -7035,7 +7040,7 @@ proc mkbrgo {top} {
70357040
}
70367041

70377042
proc cherrypick {} {
7038-
global rowmenuid curview
7043+
global rowmenuid curview viewincl
70397044
global mainhead mainheadid
70407045

70417046
set oldhead [exec git rev-parse HEAD]
@@ -7069,6 +7074,12 @@ proc cherrypick {} {
70697074
movedhead $newhead $mainhead
70707075
set mainheadid $newhead
70717076
}
7077+
# remove oldhead from viewincl and add newhead
7078+
set i [lsearch -exact $viewincl($curview) $oldhead]
7079+
if {$i >= 0} {
7080+
set viewincl($curview) [lreplace $viewincl($curview) $i $i]
7081+
}
7082+
lappend viewincl($curview) $newhead
70727083
redrawtags $oldhead
70737084
redrawtags $newhead
70747085
selbyid $newhead

0 commit comments

Comments
 (0)