# [BUG] gitk: clicking on a connecting line produces can't read "cflist_top"

5 messages from 2012-10-01 to 2012-10-21. Participants: Johannes Sixt, Stefan Haller, Paul Mackerras.
Thread: https://gitlist.dev/t/31699

## Johannes Sixt, 2012-10-01 08:40

Subject: [BUG] gitk: clicking on a connecting line produces can't read "cflist_top"
Message-ID: <506956E1.1080303@viscovery.net>
URL: https://gitlist.dev/e/506956E1.1080303%40viscovery.net

```
Clicking on a line that connects commit nodes produces this error:

can't read "cflist_top": no such variable
can't read "cflist_top": no such variable
    while executing
"$cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend""
    (procedure "highlightfile" line 4)
    invoked from within
"highlightfile 0"
    (procedure "highlightfile_for_scrollpos" line 8)
    invoked from within
"highlightfile_for_scrollpos $topidx"
    (procedure "scrolltext" line 9)
    invoked from within
"scrolltext 0.0 1.0"
    (vertical scrolling command executed by text)


Bisection points to b967135d (Synchronize highlighting in file view when
scrolling diff).

gitk remains responsive after the error window is closed, so it is not
urgent. A fix would be appreciated nevertheless.

-- Hannes

```

## Stefan Haller, 2012-10-04 20:50

Subject: Re: [BUG] gitk: clicking on a connecting line produces can't read "cflist_top"
Message-ID: <1349383817-14457-1-git-send-email-stefan@haller-berlin.de>
URL: https://gitlist.dev/e/1349383817-14457-1-git-send-email-stefan%40haller-berlin.de
In-Reply-To: <506956E1.1080303@viscovery.net>

```
Sorry, I didn't realize that there is a display mode where the
list of files is empty, not even showing a "Comments" entry.

Here's a patch that fixes it, plus another patch that is only related
in so far as the bug that it fixes was introduced by the same commit.

[PATCH 1/2] gitk: Fix error message when clicking on a connecting line
[PATCH 2/2] gitk: When searching, only highlight files when in Patch mode

```

## Stefan Haller, 2012-10-04 20:50

Subject: [PATCH 1/2] gitk: Fix error message when clicking on a connecting line
Message-ID: <1349383817-14457-2-git-send-email-stefan@haller-berlin.de>
URL: https://gitlist.dev/e/1349383817-14457-2-git-send-email-stefan%40haller-berlin.de
In-Reply-To: <1349383817-14457-1-git-send-email-stefan@haller-berlin.de>

```
When clicking on the line that connects two commit nodes, gitk
would bring up an error dialog saying "can't read "cflist_top":
no such variable".

This fixes a regression that was introduced with b967135 ("gitk:
Synchronize highlighting in file view when scrolling diff").

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 gitk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gitk b/gitk
index 379582a..8935284 100755
--- a/gitk
+++ b/gitk
@@ -7958,6 +7958,8 @@ proc changediffdisp {} {
 proc highlightfile {cline} {
     global cflist cflist_top
 
+    if {![info exists cflist_top]} return
+
     $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
     $cflist tag add highlight $cline.0 "$cline.0 lineend"
     $cflist see $cline.0
-- 
1.8.0.rc0.36.gef0f079

```

## Stefan Haller, 2012-10-04 20:50

Subject: [PATCH 2/2] gitk: When searching, only highlight files when in Patch mode
Message-ID: <1349383817-14457-3-git-send-email-stefan@haller-berlin.de>
URL: https://gitlist.dev/e/1349383817-14457-3-git-send-email-stefan%40haller-berlin.de
In-Reply-To: <1349383817-14457-1-git-send-email-stefan@haller-berlin.de>

```
This fixes another regression that was introduced in b967135 ("gitk:
Synchronize highlighting in file view when scrolling diff"): when
searching for a string in tree mode, jumping to the next search hit
would highlight the "Comments" entry in the file list.

Signed-off-by: Stefan Haller <stefan@haller-berlin.de>
---
 gitk | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gitk b/gitk
index 8935284..0ee5585 100755
--- a/gitk
+++ b/gitk
@@ -7967,8 +7967,9 @@ proc highlightfile {cline} {
 }
 
 proc highlightfile_for_scrollpos {topidx} {
-    global difffilestart
+    global cmitmode difffilestart
 
+    if {$cmitmode eq "tree"} return
     if {![info exists difffilestart]} return
 
     set top [lindex [split $topidx .] 0]
@@ -8192,12 +8193,10 @@ proc scrolltext {f0 f1} {
     global searchstring cmitmode ctext
     global suppress_highlighting_file_for_this_scrollpos
 
-    if {$cmitmode ne "tree"} {
-	set topidx [$ctext index @0,0]
-	if {![info exists suppress_highlighting_file_for_this_scrollpos]
-	    || $topidx ne $suppress_highlighting_file_for_this_scrollpos} {
-	    highlightfile_for_scrollpos $topidx
-	}
+    set topidx [$ctext index @0,0]
+    if {![info exists suppress_highlighting_file_for_this_scrollpos]
+	|| $topidx ne $suppress_highlighting_file_for_this_scrollpos} {
+	highlightfile_for_scrollpos $topidx
     }
 
     catch {unset suppress_highlighting_file_for_this_scrollpos}
-- 
1.8.0.rc0.36.gef0f079

```

## Paul Mackerras, 2012-10-21 22:25

Subject: Re: [BUG] gitk: clicking on a connecting line produces can't read "cflist_top"
Message-ID: <20121021222545.GC7407@bloggs.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20121021222545.GC7407%40bloggs.ozlabs.ibm.com
In-Reply-To: <1349383817-14457-1-git-send-email-stefan@haller-berlin.de>

```
On Thu, Oct 04, 2012 at 10:50:15PM +0200, Stefan Haller wrote:
> Sorry, I didn't realize that there is a display mode where the
> list of files is empty, not even showing a "Comments" entry.
> 
> Here's a patch that fixes it, plus another patch that is only related
> in so far as the bug that it fixes was introduced by the same commit.
> 
> [PATCH 1/2] gitk: Fix error message when clicking on a connecting line
> [PATCH 2/2] gitk: When searching, only highlight files when in Patch mode

Thanks, applied both.

Paul.

```
