Title: Fix `Repo.active_branch` resolution for reftable-backed repositories by Copilot · Pull Request #2114 · gitpython-developers/GitPython · GitHub
Open Graph Title: Fix `Repo.active_branch` resolution for reftable-backed repositories by Copilot · Pull Request #2114 · gitpython-developers/GitPython
X Title: Fix `Repo.active_branch` resolution for reftable-backed repositories by Copilot · Pull Request #2114 · gitpython-developers/GitPython
Description: GitPython currently infers the active branch from ref files directly, which breaks on repositories using Git’s reftable ref storage and can surface refs/heads/.invalid as the active branch. This PR switches active-branch resolution to Git’s symbolic-ref plumbing so behavior stays correct across ref backends. Active branch resolution Replaced Repo.active_branch’s direct HEAD reference dereference path with git symbolic-ref -q HEAD. Constructs Head from the resolved symbolic ref path returned by Git. Preserves detached-HEAD semantics by translating symbolic-ref’s non-symbolic result into the existing TypeError behavior. Regression coverage Added a reftable-specific test for empty repositories that validates: repo.active_branch.path matches git symbolic-ref HEAD repo.active_branch.name matches git symbolic-ref --short HEAD Added a detached-HEAD test asserting Repo.active_branch raises TypeError with the expected detached-reference message. @property def active_branch(self) -> Head: try: return Head(self, self.git.symbolic_ref("-q", "HEAD").strip()) except GitCommandError as err: if err.status == 1: raise TypeError("HEAD is a detached symbolic reference as it points to a commit") from err raise ✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Open Graph Description: GitPython currently infers the active branch from ref files directly, which breaks on repositories using Git’s reftable ref storage and can surface refs/heads/.invalid as the active branch. This PR...
X Description: GitPython currently infers the active branch from ref files directly, which breaks on repositories using Git’s reftable ref storage and can surface refs/heads/.invalid as the active branch. This PR...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2114
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aaec0f72-947a-388e-221d-cf41d6a7cc87 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 82DA:2A854D:2078C42:2EF1F38:6A5502F2 |
| html-safe-nonce | 79aa18d662d6948a0dee4a919bd2289ba2fa69888a36e3b3d496e1dbba454045 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkRBOjJBODU0RDoyMDc4QzQyOjJFRjFGMzg6NkE1NTAyRjIiLCJ2aXNpdG9yX2lkIjoiMTQwNjg0MjQ2ODMwNjMyMjE2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4c36bf269bb1ec6a8fef87f7663e10ff76178bca71e4d71a9104c29b4c004766 |
| hovercard-subject-tag | pull_request:3427031132 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/2114/files |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | GitPython currently infers the active branch from ref files directly, which breaks on repositories using Git’s reftable ref storage and can surface refs/heads/.invalid as the active branch. This PR... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a35ab858be185cd86d12b93a43bccf34e8d8536 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width