Skip to content

Commit aa43561

Browse files
committed
gitk: Don't compare fake children when comparing commits
This fixes a bug where the compare-commits function would advance to a fake node (one representing local changes, either checked in but not committed, or not checked in) and then get an error when trying to get the patch-id. This fixes it by only considering the real children of each commit. Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 4a3da5d commit aa43561

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

gitk

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Tcl ignores the next line -*- tcl -*- \
33
exec wish "$0" -- "$@"
44

5-
# Copyright © 2005-2008 Paul Mackerras. All rights reserved.
5+
# Copyright © 2005-2009 Paul Mackerras. All rights reserved.
66
# This program is free software; it may be used, copied, modified
77
# and distributed under the terms of the GNU General Public Licence,
88
# either version 2, or (at your option) any later version.
@@ -989,6 +989,18 @@ proc removefakerow {id} {
989989
drawvisible
990990
}
991991

992+
proc real_children {vp} {
993+
global children nullid nullid2
994+
995+
set kids {}
996+
foreach id $children($vp) {
997+
if {$id ne $nullid && $id ne $nullid2} {
998+
lappend kids $id
999+
}
1000+
}
1001+
return $kids
1002+
}
1003+
9921004
proc first_real_child {vp} {
9931005
global children nullid nullid2
9941006

@@ -8463,23 +8475,23 @@ proc do_cmp_commits {a b} {
84638475
}
84648476
}
84658477
if {$skipa} {
8466-
if {[llength $children($curview,$a)] != 1} {
8478+
set kids [real_children $curview,$a]
8479+
if {[llength $kids] != 1} {
84678480
$ctext insert end "\n"
84688481
appendshortlink $a [mc "Commit "] \
8469-
[mc " has %s children - stopping\n" \
8470-
[llength $children($curview,$a)]]
8482+
[mc " has %s children - stopping\n" [llength $kids]]
84718483
break
84728484
}
8473-
set a [lindex $children($curview,$a) 0]
8485+
set a [lindex $kids 0]
84748486
}
84758487
if {$skipb} {
8476-
if {[llength $children($curview,$b)] != 1} {
8488+
set kids [real_children $curview,$b]
8489+
if {[llength $kids] != 1} {
84778490
appendshortlink $b [mc "Commit "] \
8478-
[mc " has %s children - stopping\n" \
8479-
[llength $children($curview,$b)]]
8491+
[mc " has %s children - stopping\n" [llength $kids]]
84808492
break
84818493
}
8482-
set b [lindex $children($curview,$b) 0]
8494+
set b [lindex $kids 0]
84838495
}
84848496
}
84858497
$ctext conf -state disabled

0 commit comments

Comments
 (0)