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 <brgan@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Brian Gan <brgan@google.com>
diff --git a/project.py b/project.py index b81fcd5..3603932 100644 --- a/project.py +++ b/project.py
@@ -4398,8 +4398,12 @@ 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 = []