]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: fix error when remote tracking branch is deleted
authorMichael Rappazzo <rappazzo@gmail.com>
Sat, 13 Sep 2025 11:31:51 +0000 (07:31 -0400)
committerJohannes Sixt <j6t@kdbg.org>
Sun, 14 Sep 2025 18:18:30 +0000 (20:18 +0200)
When a remote tracking branch is deleted (e.g., via 'git push --delete
origin branch'), the headids array entry for that branch is removed, but
upstreamofref may still reference it. This causes gitk to show an error
and prevents the Tags and Heads view from opening.

Fix by checking that headids($upstreamofref($n)) exists before accessing
it in the refill_reflist function.

Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
gitk

diff --git a/gitk b/gitk
index 080192820e8f3c91491d1af00c73b0ff3b0a412a..fc502fbd688c29d231bdf82501f6509129b96a53 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -10332,7 +10332,9 @@ proc refill_reflist {} {
         if {![string match "remotes/*" $n] && [string match $reflistfilter $n]} {
             if {[commitinview $headids($n) $curview]} {
                 lappend localrefs [list $n H]
-                if {[info exists upstreamofref($n)] && [commitinview $headids($upstreamofref($n)) $curview]} {
+                if {[info exists upstreamofref($n)] && \
+                        [info exists headids($upstreamofref($n))] && \
+                        [commitinview $headids($upstreamofref($n)) $curview]} {
                     lappend trackedremoterefs [list $upstreamofref($n) R]
                 }
             } else {