From: Michael Rappazzo <rappazzo@gmail•com>
To: git@vger•kernel.org
Cc: j6t@kdbg•org, Michael Rappazzo <rappazzo@gmail•com>
Subject: [PATCH] gitk: fix error when remote tracking branch is deleted
Date: Sat, 13 Sep 2025 07:31:51 -0400 [thread overview]
Message-ID: <20250913113253.74362-1-rappazzo@gmail.com> (raw)
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>
---
To reproduce the case:
```
mkdir sample-repo-remote &&
cd sample-repo-remote &&
git init --bare --initial-branch master &&
cd .. &&
git clone sample-repo-remote sample-repo &&
cd sample-repo &&
git commit --allow-empty -m "Sample commit" &&
git push origin master &&
git push origin master:master2 &&
git branch master2 origin/master2 &&
git push --delete origin master2
```
Then run gitk --all then bring up the "Tags and Heads" view.
gitk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gitk b/gitk
index 6e4d71d585..3cfc9ef291 100755
--- a/gitk
+++ b/gitk
@@ -10294,7 +10294,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 {
--
2.51.0
next reply other threads:[~2025-09-13 11:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 11:31 Michael Rappazzo [this message]
2025-09-14 18:32 ` [PATCH] gitk: fix error when remote tracking branch is deleted Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250913113253.74362-1-rappazzo@gmail.com \
--to=rappazzo@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=j6t@kdbg$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox