Skip to content

Commit 6d8d9b7

Browse files
codexByron
authored andcommitted
test: respect Windows argument encoding in packed-tag regressions
The Windows Python 3.15 free-threaded CI job enumerated the non-UTF-8 packed tags correctly, then failed both object-format variants when the new regression tried to resolve their surrogate-escaped names through the CLI. Git 2.56.0.windows.2 returned exit 128 from `git rev-parse --verify --end-of-options` with `fatal: Needed a single revision`. Git's Windows `wmain()` converts UTF-16 arguments to UTF-8, so those arguments cannot carry the original invalid UTF-8 reference bytes. Separate packed-tag enumeration from reference resolution. Keep the reported enumeration regression on both backends and every platform; skip only the Windows CLI resolution variant. Gix resolution still runs on every platform with `Git.execute()` forbidden, using the supported byte-capable native APIs. Document the demonstrated CLI limitation and the coverage boundary in `doc/gix-backend.md`. Validation: all 44 reference tests and 24 subtests pass locally on each backend; Ruff check/format and `git diff --check` pass. Windows execution remains for CI.
1 parent 75f0ba7 commit 6d8d9b7

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

‎doc/gix-backend.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,17 @@ Reference names and revisions are encoded with `surrogateescape` before calling
393393
GixPython's byte-capable `Target.Symbolic`, `Repository.try_find_reference`,
394394
`Repository.rev_parse_single`, `Repository.rev_parse` and `RefEdit` APIs.
395395
This preserves non-UTF-8 packed tag names without interpreting reference storage
396-
in Python. `test_non_utf8_tag_names_preserve_bytes_and_resolve` covers lightweight
397-
and annotated tags in SHA-1 and SHA-256 repositories and forbids CLI fallback
398-
during native resolution. This corrects adapter input conversion; GixPython 0.3.0
399-
already accepts the original bytes through those APIs.
396+
in Python. `test_non_utf8_tag_names_preserve_bytes` covers lightweight and annotated
397+
tag enumeration in SHA-1 and SHA-256 repositories on both backends and all platforms.
398+
`test_non_utf8_tag_names_resolve` forbids CLI fallback during native resolution.
399+
Its CLI variant requires POSIX: Windows command-line arguments cannot preserve
400+
the original non-UTF-8 bytes. Windows CI with Git 2.56.0.windows.2 and CPython
401+
3.15.1 free-threaded enumerates both packed names, but resolving the
402+
surrogate-escaped `annotated-\udce3` name through `git rev-parse --verify` exits 128
403+
with `fatal: Needed a single revision`. Enumeration remains tested on Windows
404+
CLI; Gix resolution remains tested on Windows through the byte-capable APIs.
405+
This corrects adapter input conversion; GixPython 0.3.0 already accepts the
406+
original bytes through those APIs.
400407

401408
Repository-backed native operations fall back for reftable (GIX-1) and repositories
402409
with `extensions.compatObjectFormat` (GIX-19). Process-returning calls, timeouts,

‎test/test_refs.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

66
import contextlib
7+
import os
78
import os.path as osp
89
import unittest
910
from itertools import chain
@@ -37,11 +38,23 @@
3738

3839

3940
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
40-
def test_non_utf8_tag_names_preserve_bytes_and_resolve(object_format):
41+
def test_non_utf8_tag_names_preserve_bytes(object_format):
4142
with fixture_repo("legacy-refs.sh", object_format) as repo:
4243
tags = repo.tags
4344
assert len(tags) == 2
4445
assert {safe_encode(tag.path) for tag in tags} == {b"refs/tags/release-\xf5", b"refs/tags/annotated-\xe3"}
46+
if _backend.name == "gix":
47+
with patch.object(_backend, "gix", None):
48+
assert {tag.path for tag in repo.tags} == {tag.path for tag in tags}
49+
50+
51+
@pytest.mark.skipif(
52+
os.name == "nt" and _backend.name == "cli", reason="Windows command-line arguments cannot preserve non-UTF-8 bytes"
53+
)
54+
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
55+
def test_non_utf8_tag_names_resolve(object_format):
56+
with fixture_repo("legacy-refs.sh", object_format) as repo:
57+
tags = repo.tags
4558
native_guard = (
4659
patch.object(Git, "execute", side_effect=AssertionError("unexpected reference CLI call"))
4760
if _backend.name == "gix"
@@ -52,9 +65,6 @@ def test_non_utf8_tag_names_preserve_bytes_and_resolve(object_format):
5265
assert tag.commit == repo.head.commit
5366
assert repo.rev_parse(tag.path).hexsha == tag.object.hexsha
5467
assert repo.commit(tag.path) == repo.head.commit
55-
if _backend.name == "gix":
56-
with patch.object(_backend, "gix", None):
57-
assert {tag.path for tag in repo.tags} == {tag.path for tag in tags}
5868

5969

6070
class TestRefs(TestBase):

0 commit comments

Comments
 (0)