Skip to content

Commit a8e1f5b

Browse files
codexByron
authored andcommitted
feat(gix): resolve symbolic reference targets natively
Use native reference lookup for quiet, nonrecursive symbolic-target reads. Preserve detached-reference exit status and let Git supply missing-reference diagnostics. Symbolic mutations retain their existing reflog and validation behavior through the CLI. The staged version passes Ruff and Python syntax checks. Its SHA-1/SHA-256 native smoke and focused pytest selection pass: 13 passed, 24 subtests passed in 3.81s.
1 parent 8ab427b commit a8e1f5b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎git/_backend.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,22 @@ def _ls_tree(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes:
160160
)
161161

162162

163+
def _symbolic_ref(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes:
164+
if len(args) != 4 or args[:3] != ["--quiet", "--no-recurse", "--"]:
165+
raise _Unsupported("reference mutation or options")
166+
reference = repo.try_find_reference(args[-1])
167+
if reference is None:
168+
raise _Unsupported("missing reference diagnostics")
169+
target = reference.target().try_name()
170+
if target is None:
171+
raise GitCommandError(["git", "symbolic-ref"], 1)
172+
return target + b"\n"
173+
174+
163175
_HANDLERS: Dict[str, Callable[[Any, List[str], Dict[str, Any]], bytes]] = {
164176
"rev_parse": _rev_parse,
165177
"ls_tree": _ls_tree,
178+
"symbolic_ref": _symbolic_ref,
166179
}
167180

168181

0 commit comments

Comments
 (0)