From 29b6630a6532b20fc26c7b44d8fa69fd4db390a0 Mon Sep 17 00:00:00 2001 From: Brian Gan Date: Wed, 29 Jul 2026 23:25:20 +0000 Subject: [PATCH] project: make GetHead file-read fallback reftable-aware When both `git symbolic-ref` and `git rev-parse` fail to resolve HEAD, GetHead falls back to reading .git/HEAD directly. With the "reftable" ref backend, .git/HEAD is only a stub pointing at the "refs/heads/.invalid" placeholder while the real HEAD lives in the reftable stack. Reading the stub returned that bogus placeholder value. Detect the placeholder and treat HEAD as unresolvable (raising NoManifestException) instead of returning the invalid ref. Bug: 483758905 Change-Id: Ia0a825c0d1874686b98c5ddcdea6dc26c0d46784 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/612882 Tested-by: Brian Gan Reviewed-by: Gavin Mak Commit-Queue: Brian Gan --- project.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/project.py b/project.py index b81fcd5f0..36039321f 100644 --- a/project.py +++ b/project.py @@ -4398,8 +4398,12 @@ class Project: except AttributeError: pass if line.startswith("ref: "): - return line[5:-1] - return line[:-1] + ref = line[5:-1] + else: + ref = line[:-1] + if ref == R_HEADS + ".invalid": + raise NoManifestException(path, str(e)) + return ref def SetHead(self, ref, message=None): cmdv = []