You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: return None for detached refs and add HEAD.hexsha (#2230)
A detached HEAD currently turns a branch lookup into a TypeError. Return
None from SymbolicReference.reference (and its ref alias) and
Repo.active_branch. An unborn branch still exposes its reference.
Add repo.head.hexsha to read the hexadecimal object ID directly without
loading commit objects. Resolve loose and packed references in attached,
detached, bare, and linked-worktree repositories. Return None for an
unborn target, and raise for a missing HEAD, malformed or cyclic refs,
and failures to read reference data.
Distinguish missing references from other I/O errors so an unreadable
loose ref cannot silently fall back to a stale packed value. Replace the
empty-ref assertion with ValueError and detect symbolic-reference cycles.
Preserve revision lookup for branch names that overlap Git metadata paths.
Update conditional configuration includes, reflog and upstream lookups,
commit creation, checkout, and submodule tracking to handle optional
references. Relative submodule URLs use origin when HEAD is detached.
Update the tutorial and regression tests for the new API. Make writable
test clones usable from detached checkouts, give remote tests an explicit
master branch, and compare reflog results with Git instead of assuming
successive entries always name different commits.
Validation:
- 311 targeted tests passed using disposable clones and isolated Git
configuration, with additional detached-HEAD and feature-branch checks.
- Ruff lint and formatting checks passed; mypy passed for 45 source files.
- The pre-existing test_writer_rejects_invalid_option_names failure
remains: it expects an underscore-containing option name to be accepted,
while the config parser correctly rejects that Git-incompatible name.
0 commit comments