@matheusbsbs / matheus-bagliano / commits / aa43561ac0
Fork 0

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 <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Sep 10, 2009 at 21:58 UTC aa43561ac0c18dd6d200afe3a02e4e6c7e4beeae
1 file changed +21 -9
gitk
+21 -9
@@ -2,7 +2,7 @@
2 # Tcl ignores the next line -*- tcl -*- \
3 exec wish "$0" -- "$@"
4
5 -# Copyright © 2005-2008 Paul Mackerras. All rights reserved.
5 +# Copyright © 2005-2009 Paul Mackerras. All rights reserved.
6 # This program is free software; it may be used, copied, modified
7 # and distributed under the terms of the GNU General Public Licence,
8 # either version 2, or (at your option) any later version.
@@ -989,6 +989,18 @@ proc removefakerow {id} {
989 drawvisible
990 }
991
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 +
1004 proc first_real_child {vp} {
1005 global children nullid nullid2
1006
@@ -8463,23 +8475,23 @@ proc do_cmp_commits {a b} {
8475 }
8476 }
8477 if {$skipa} {
8466 - if {[llength $children($curview,$a)] != 1} {
8478 + set kids [real_children $curview,$a]
8479 + if {[llength $kids] != 1} {
8480 $ctext insert end "\n"
8481 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]]
8483 break
8484 }
8473 - set a [lindex $children($curview,$a) 0]
8485 + set a [lindex $kids 0]
8486 }
8487 if {$skipb} {
8476 - if {[llength $children($curview,$b)] != 1} {
8488 + set kids [real_children $curview,$b]
8489 + if {[llength $kids] != 1} {
8490 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]]
8492 break
8493 }
8482 - set b [lindex $children($curview,$b) 0]
8494 + set b [lindex $kids 0]
8495 }
8496 }
8497 $ctext conf -state disabled