Skip to content

Commit 5ddd5f6

Browse files
codexByron
authored andcommitted
fix(gix): use GixPython 0.4.0 for dates and tree listings
The published GixPython 0.3.0 wheel loses time zone offsets when an identity line has trailing fields and misclassifies a `140000` gitlink. It also accepts malformed `.gitmodules` settings that Git rejects. Pin both extras to GixPython 0.4.0, which includes the Gitoxide 0.91.0 fixes, and document the Rust 1.95 minimum for source builds. Use the structured commit and tag dates when they match the date at the start of the raw header suffix. GixPython 0.4.0 still reads a short `+020` offset as UTC, so keep the existing CLI fallback for mismatched dates. Format native tree entry kinds as Git's canonical `ls-tree` modes while Gitoxide continues to expose the raw modes. Keep existing fallbacks for invalid or unsupported data. Verified the published macOS arm64 wheel against Git 2.54.0. Git's `split_ident_line()` and `canon_mode()` describe the display behavior. Nine focused checks failed with 0.3.0, and all 13 focused checks passed with 0.4.0, including reftable fallback coverage. Verified both package extras, Ruff lint and format, mypy, and basedpyright. The focused deserialization suite passed on both backends with the short-offset test. Agent-Model: unknown
1 parent 5dc5c76 commit 5ddd5f6

11 files changed

Lines changed: 116 additions & 29 deletions

File tree

‎.github/workflows/pythonpackage.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- name: Prepare Rust for GixPython source builds
8383
id: rust
8484
run: |
85-
# GixPython 0.3.0 publishes macOS wheels only and needs Rust >= 1.89.
85+
# GixPython 0.4.0 publishes macOS wheels only and needs Rust >= 1.95.
8686
rustup toolchain install stable --profile minimal
8787
rustup default stable
8888
rustc --version

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ optional `gix` extra in a virtual environment:
2424
python -m pip install ".[gix]"
2525
```
2626

27-
The extra installs **GixPython 0.3.0** from PyPI; its Python import name is `gix`.
27+
The extra installs **GixPython 0.4.0** from PyPI; its Python import name is `gix`.
2828
Set `GIT_PYTHON_BACKEND=gix` **before importing GitPython**, either in your
2929
environment or in Python:
3030

@@ -48,8 +48,8 @@ Explicit `gix` selection fails if GixPython cannot be imported.
4848
3.8 or newer; on Python 3.8–3.10 the extra omits GixPython and uses CLI.
4949
- **Git 2.52 or newer**, available in `PATH` or selected with
5050
`GIT_PYTHON_GIT_EXECUTABLE`, remains required for CLI fallbacks.
51-
- GixPython 0.3.0 publishes **macOS wheels**. On **Linux and Windows**, installation
52-
builds its released source distribution and requires **Rust 1.89 or newer** and
51+
- GixPython 0.4.0 publishes **macOS wheels**. On **Linux and Windows**, installation
52+
builds its released source distribution and requires **Rust 1.95 or newer** and
5353
a **system linker**. Default hashing, compression and HTTPS dependencies use
5454
pure Rust and do not require a C/C++ compiler.
5555

‎doc/gix-backend.md‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This backend is unreleased. Install `.[gix]` from this checkout to make GitPython
44
use GixPython for supported operations. GixPython is the distribution name;
55
`gix` is its import name. The extra uses the official PyPI release
6-
`GixPython==0.3.0` on CPython 3.11 or newer. On older Python versions, the
6+
`GixPython==0.4.0` on CPython 3.11 or newer. On older Python versions, the
77
dependency is omitted and GitPython uses the CLI backend. The ordinary
88
GitPython installation still supports Python 3.8 or newer.
99

@@ -16,11 +16,11 @@ uv pip install --python .tox/gix/bin/python --editable '.[test,gix]'
1616

1717
`tox -e gix` also resolves the published GixPython release from the package index.
1818

19-
GixPython 0.3.0 publishes macOS wheels. On Windows and Linux, installation
20-
builds the released source distribution and requires Rust 1.89 or newer and
19+
GixPython 0.4.0 publishes macOS wheels. On Windows and Linux, installation
20+
builds the released source distribution and requires Rust 1.95 or newer and
2121
a system linker. Its default build uses pure Rust hashing, compression and HTTPS;
2222
no C/C++ compiler is required for those dependencies. The release uses Gitoxide's
23-
`gix` 0.90.0 and `gix-testtools` 0.22.0 from crates.io. The fixture suites for both
23+
`gix` 0.91.0 and `gix-testtools` 0.23.0 from crates.io. The fixture suites for both
2424
backends need GixPython. CI prepares Rust for source builds and caches built wheels,
2525
Cargo dependencies and compilation output on the main matrix.
2626

@@ -53,6 +53,24 @@ provide general Git-path resolution. A `native` counter must represent a
5353
Gix-backed operation, and backend timings include its Python glue and any CLI
5454
fallbacks.
5555

56+
## GixPython 0.4.0 validation
57+
58+
The published GixPython 0.4.0 macOS arm64 wheel reports Gitoxide
59+
`541b4db0a59644b617a8b706b83af23e0b17f7f3`. The regression tests exercised it
60+
with Git 2.54.0 in SHA-1 and SHA-256 repositories.
61+
62+
- GIX-34 is fixed in 0.4.0. Structured author, committer and tagger
63+
accessors return the first timezone after the email. The metadata adapter
64+
accepts the native result when its date agrees with the stored header.
65+
- GIX-35 is fixed for the three recorded malformed `.gitmodules` inputs.
66+
`ModulesFile.from_bytes()` rejects each one, as Git does.
67+
- GIX-36's gitlink classification is fixed. `TreeEntry.kind()` classifies
68+
`140000` as a gitlink and identifies the executable and symlink correctly.
69+
The adapter projects these native kinds to Git's listing modes. The raw
70+
`TreeEntry.mode()` values still differ from Git's canonical display.
71+
- GIX-37 still errors on a shallow object ID followed by a space. Git stops
72+
the walk at that boundary.
73+
5674
## Index and object metadata lifecycle
5775

5876
`Repo(..., expand_vars=False)` accepts literal paths for callers such as sbxloop
@@ -152,7 +170,7 @@ These read-only budgets make no claim that index editing is native.
152170

153171
## Install and test without package indexes
154172

155-
Prepare `.venv` and `.tox/gix` with GixPython 0.3.0. Select the backend explicitly
173+
Prepare `.venv` and `.tox/gix` with GixPython 0.4.0. Select the backend explicitly
156174
when running against scripted fixtures:
157175

158176
```sh
@@ -208,7 +226,7 @@ released source distribution and retain it in the wheelhouse.
208226

209227
## Scripted test fixtures
210228

211-
The `test` extra requires GixPython 0.3.0 on Python 3.11+. Full fixture suites
229+
The `test` extra requires GixPython 0.4.0 on Python 3.11+. Full fixture suites
212230
run on Python 3.11 and newer with either backend. Python 3.8–3.10 retain
213231
installation/import smoke coverage, including the Cygwin Python 3.9 job.
214232
Running tests also requires Bash and Git 2.52+; `gix` here is GixPython's module.
@@ -989,10 +1007,11 @@ identify the historical fixture where needed.
9891007
| GIX-31 | Bug (open) | GixPython 0.2.0 `Commit.decode()` rejects commit headers containing a CR-only or tab-only line with `object parsing failed, at gix-object/src/commit/decode.rs:20`. Git 2.54.0 accepts both objects with `fsck --strict`, continues through their header block and renders the later Latin-1 declaration and message correctly. A space-only continuation line decodes natively but retains the late encoding declaration in `extra_headers` (GIX-30). `test_deserialization_headers_end_at_empty_line` reproduces all three using the `commit.sh whitespace-headers` fixtures and checks Git's projection. | Accept Git-compatible header lines and end headers only at an empty line. The existing `object_metadata()` native decoder diagnostics fallback retains Git for CR/tab inputs; the existing GIX-30 fallback covers the space input. Neither fallback closes these bugs. |
9901008
| GIX-32 | Missing capability (open); no demonstrated Git compatibility mismatch | Windows CI on GixPython 0.3.0, Git 2.56.0.windows.2 and CPython 3.12.10 enumerates the non-UTF-8 packed names in `legacy-refs.sh`, but exact byte-name lookup selects `Reference.read: CLI: native read diagnostics`; the no-CLI guard fails for SHA-1 and SHA-256. POSIX lookup succeeds. Git's Windows CLI likewise cannot address those original bytes through UTF-16 arguments, so there is no demonstrated equivalent Windows CLI operand. Git enumeration does preserve both names. | Provide native Windows packed-reference lookup for byte names without first converting the name to a loose-reference filesystem path. Keep `reference_info()`'s existing diagnostic fallback; `test_non_utf8_tag_names_preserve_bytes` checks it on Windows. Resolution coverage and native claims remain POSIX-only. The upstream lookup source attempts loose-path conversion before consulting packed refs; CI demonstrates the fallback, but does not capture the underlying Gix error text. |
9911009
| GIX-33 | Bug (open); missing exact-name mode | With Git 2.54.0 and GixPython 0.3.0, `exact-refs.sh sha1 files symbolic` makes `refs/tags/REBASE_HEAD` a symbolic ref to another tag while the root `REBASE_HEAD` is absent. `Repository.try_find_reference("REBASE_HEAD")` returns that tag; native `_symbolic_ref` formerly returned its target, whereas `git symbolic-ref --quiet --no-recurse -- REBASE_HEAD` exits 1. GitPython's root-reference object read consequently returned a commit through Gix and raised `ValueError` through CLI. SHA-256 reproduces the same mismatch. | Expose an exact-name lookup mode, including root references, whose absence and error behavior matches Git. `_symbolic_ref()` compares the native reference's name with the requested bytes and selects CLI for a lookalike. `test_missing_root_reference_does_not_follow_symbolic_lookalike_tag` verifies parity and forced CLI fallback. This adapter guard does not close the upstream compatibility bug. |
992-
| GIX-34 | Bug (open) | With Git 2.54.0 and GixPython 0.3.0, an author, committer or tagger line with fields after its time zone, such as `A <a@example.com> 1112591163 +0200 1700000000 -0500`, decodes through `Commit.author()`/`committer()` and `Tag.tagger()` with the correct seconds but an offset of 0. Git reads only the first date and time zone after the last `>` (`split_ident_line`) and reports `1112591163 +0200` through `git show --format=%ad --date=raw` and `%(taggerdate:raw)`. `git fsck` reports `badTimezone` for such objects, but the default `transfer.fsckObjects=false` accepts them. The `trailing-date` read-only `commit.sh` fixture in `test_deserialization_reads_date_after_email` reproduces both object kinds. | Report the time zone Git reads for identity lines with trailing fields, or reject them consistently. `object_metadata()` selects CLI when the decoded signature does not reproduce the end of its raw header line. This adapter guard does not close the upstream compatibility bug. |
993-
| GIX-35 | Bug (open) | With Git 2.54.0 and GixPython 0.3.0, `ModulesFile.from_bytes()` accepts `.gitmodules` lines that Git rejects with `bad config line`, so `git submodule update --init` stops while `git fsck` reports only `gitmodulesParse`. A line holding more than one name is read as several settings: after `url = ../good`, `x url = ../evil` makes `url()` return `../evil` with `submodule.<name>.x` true, and `[submodule "module"] x url = ../evil` does the same on the header line. `br#anch = main` is read as an implicit `br` followed by a comment. The `submodule-rejected-lines.sh` read-only fixture in `test_submodule_configuration_rejects_lines_git_rejects` reproduces all three. | Reject the lines Git rejects, at least in a Git-strict parsing mode, with a typed error. `submodule_config()` selects CLI unless every line is blank, a comment, a bare submodule header or a single `key` or `key = value` setting, so Git's parser reports the error. This adapter guard does not close the upstream compatibility bug. |
994-
| GIX-36 | Bug (open) | With Git 2.54.0 and GixPython 0.3.0, `Tree.iter()` reports tree entry modes as stored, while Git canonicalizes them when it reads a tree (`canon_mode`): `git ls-tree` and checkout use `100755` for `100700`, `120000` for `120777` and `160000` for every mode whose type is not a regular file, symbolic link or directory. `TreeEntry.mode()` returned `0o100700` and `0o120777`, so `Blob.mode` did not match `Blob.executable_mode` or `Blob.link_mode` for entries Git checks out as an executable or a symbolic link. A `140000` entry, which Git reads as a gitlink, is reported as a tree with mode `0o40000`, so GitPython listed the contents of an object Git never checks out; other noncanonical gitlink modes made tree iteration raise `TypeError`. `git fsck` reports these trees only as `badFilemode` warnings, so default transfers accept them. The `tree-modes.sh` read-only fixture in `test_tree_entry_modes_match_git` reproduces all three for SHA-1 and SHA-256. | Report the modes Git reads, at least in a Git-compatible mode, or expose the raw mode bytes. `_ls_tree()` selects CLI unless every native mode is one Git reports and the tree's bytes re-encode to the same object ID through the in-memory object database, so Git lists the entries. This adapter guard does not close the upstream compatibility bug. |
995-
| GIX-37 | Bug (open) | On macOS with Git 2.54.0 and GixPython 0.3.0, create a linear history `A <- B <- C` with `HEAD` at `C` and write `B`'s full SHA-1 followed by a space and newline to `.git/shallow`. `git rev-list --skip=1 HEAD` returns only `B` and stops at the shallow boundary. `Repository.rev_walk([repo.head_id()]).all()` instead raises a `gix.Error` when consumed: `gix-shallow` treats the trailing space as a 41st hexadecimal character. | Match Git's shallow-file parsing in Gitoxide. `Commit.iter_parents(first_parent=False)` keeps the existing CLI fallback in `_backend.history()` and returns `B` with or without `max_count=1`. An explicitly native `first_parent=True` walk still exposes the parsing mismatch, which also occurs through `Commit.iter_items(..., first_parent=True, skip=1)`. |
1010+
| GIX-34 | Fixed in Gitoxide 0.91.0 | With Git 2.54.0 and GixPython 0.3.0, an author, committer or tagger line with fields after its time zone, such as `A <a@example.com> 1112591163 +0200 1700000000 -0500`, decodes through `Commit.author()`/`committer()` and `Tag.tagger()` with the correct seconds but an offset of 0. Git reads only the first date and time zone after the last `>` (`split_ident_line`) and reports `1112591163 +0200` through `git show --format=%ad --date=raw` and `%(taggerdate:raw)`. `git fsck` reports `badTimezone` for such objects, but the default `transfer.fsckObjects=false` accepts them. The `trailing-date` read-only `commit.sh` fixture in `test_deserialization_reads_date_after_email` reproduces both object kinds. | Gitoxide fixed the offset in `39e523a8ce`. The GixPython 0.4.0 wheel passes both native decoding checks. The adapter retains its date validation for GIX-38. |
1011+
| GIX-35 | Fixed in Gitoxide 0.91.0 | With Git 2.54.0 and GixPython 0.3.0, `ModulesFile.from_bytes()` accepts `.gitmodules` lines that Git rejects with `bad config line`, so `git submodule update --init` stops while `git fsck` reports only `gitmodulesParse`. A line holding more than one name is read as several settings: after `url = ../good`, `x url = ../evil` makes `url()` return `../evil` with `submodule.<name>.x` true, and `[submodule "module"] x url = ../evil` does the same on the header line. `br#anch = main` is read as an implicit `br` followed by a comment. The `submodule-rejected-lines.sh` read-only fixture in `test_submodule_configuration_rejects_lines_git_rejects` reproduces all three. | Gitoxide rejects all three inputs after the parser change in `3d3aa94b70`. The GixPython 0.4.0 wheel passes the regression on both object formats. GitPython retains its existing fallback for native parse errors. |
1012+
| GIX-36 | Classification fixed in Gitoxide 0.91.0; raw mode mismatch open | With Git 2.54.0 and GixPython 0.3.0, `Tree.iter()` reports tree entry modes as stored, while Git canonicalizes them when it reads a tree (`canon_mode`): `git ls-tree` and checkout use `100755` for `100700`, `120000` for `120777` and `160000` for every mode whose type is not a regular file, symbolic link or directory. `TreeEntry.mode()` returned `0o100700` and `0o120777`, so `Blob.mode` did not match `Blob.executable_mode` or `Blob.link_mode` for entries Git checks out as an executable or a symbolic link. A `140000` entry, which Git reads as a gitlink, is reported as a tree with mode `0o40000`, so GitPython listed the contents of an object Git never checks out; other noncanonical gitlink modes made tree iteration raise `TypeError`. `git fsck` reports these trees only as `badFilemode` warnings, so default transfers accept them. The `tree-modes.sh` read-only fixture reproduces all three for SHA-1 and SHA-256. | Gitoxide preserves the raw mode and fixes classification in `74a7a86060`. `_ls_tree()` formats the native kinds as Git listing modes. `test_native_tree_entry_modes_match_git` verifies the listing against Git on the GixPython 0.4.0 wheel. The raw-mode mismatch remains open. Expose Git's canonical mode as a separate native projection. |
1013+
| GIX-37 | Bug (open) | On macOS with Git 2.54.0 and GixPython 0.3.0 or 0.4.0, create a linear history `A <- B <- C` with `HEAD` at `C` and write `B`'s full SHA-1 followed by a space and newline to `.git/shallow`. `git rev-list --skip=1 HEAD` returns only `B` and stops at the shallow boundary. `Repository.rev_walk([repo.head_id()]).all()` instead raises a `gix.Error` when consumed: `gix-shallow` treats the trailing space as a 41st hexadecimal character. | Match Git's shallow-file parsing in Gitoxide. `Commit.iter_parents(first_parent=False)` keeps the existing CLI fallback in `_backend.history()` and returns `B` with or without `max_count=1`. An explicitly native `first_parent=True` walk still exposes the parsing mismatch, which also occurs through `Commit.iter_items(..., first_parent=True, skip=1)`. |
1014+
| GIX-38 | Bug (open) | With Git 2.54.0 and GixPython 0.4.0, the `commit.sh short-offset` fixture stores `1112591163 +020` in an identity. `git show -s --format=%ad --date=raw` reports `1112591163 +0020`, while `Commit.author()` reports an offset of zero. A separate probe with `+0299` preserves that spelling in Git but renders as `+0339` from the native offset in seconds. | Expose Git-compatible interpretation of short offsets and a way to preserve the stored offset spelling. `object_metadata()` accepts native dates when their formatted prefix matches the raw identity and otherwise keeps the existing CLI fallback. `test_deserialization_short_offset_matches_git` verifies the fallback returns the 20-minute offset. |
9961015

9971016
GIX-14 also covers configured worktree symlink resolution. On macOS with
9981017
GixPython 0.3.0, CPython 3.12.14 and Git 2.54.0, set a submodule's

‎git/_backend.py‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ def object_metadata(command: Any, oid: str, kind: str) -> Any:
245245
else ((data.tagger, result["tagger"]),)
246246
)
247247
for raw, signature in signatures:
248-
# Gix reads a time zone of 0 with trailing fields (GIX-34); accept either UTC sign.
249-
if signature is not None and not raw.replace(b" -0000", b" +0000").endswith(b"> " + _date(signature)):
250-
raise _Unsupported("signature trailing fields (GIX-34)")
248+
if signature is not None:
249+
# Gix can decode a short offset such as +020 as UTC.
250+
date = raw.rpartition(b">")[2].replace(b" -0000", b" +0000", 1)
251+
if not (date + b" ").startswith(b" " + _date(signature) + b" "):
252+
raise _Unsupported("signature date differs from raw header (GIX-38)")
251253
except _Unsupported as exc:
252254
return _fallback(kind + ".decode", str(exc))
253255
except gix.Error as exc:
@@ -311,18 +313,21 @@ def _rev_parse(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes:
311313
return str(_oid(repo, args[-1], kwargs.get("env"))).encode("ascii") + b"\n"
312314

313315

316+
_LS_TREE_MODES = {
317+
"blob": b"100644 blob",
318+
"exe": b"100755 blob",
319+
"link": b"120000 blob",
320+
"tree": b"040000 tree",
321+
"commit": b"160000 commit",
322+
}
323+
324+
314325
def _ls_tree(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes:
315326
if len(args) != 3 or args[:2] != ["-z", "--full-tree"]:
316327
raise _Unsupported("tree options")
317328
with repo.find_tree(_oid(repo, args[2])).iter() as entries:
318329
return b"".join(
319-
b"%06o %s %s\t%s\0"
320-
% (
321-
entry.mode(),
322-
b"tree" if entry.kind() == "tree" else b"commit" if entry.kind() == "commit" else b"blob",
323-
str(entry.id()).encode("ascii"),
324-
entry.filename(),
325-
)
330+
b"%s %s\t%s\0" % (_LS_TREE_MODES[entry.kind()], str(entry.id()).encode("ascii"), entry.filename())
326331
for entry in entries
327332
)
328333

‎gix-requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GixPython==0.3.0 ; python_version >= "3.11"
1+
GixPython==0.4.0 ; python_version >= "3.11"

‎test-requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
coverage[toml]
2-
GixPython==0.3.0 ; python_version >= "3.11"
2+
GixPython==0.4.0 ; python_version >= "3.11"
33
basedpyright==1.39.9 ; python_version >= "3.9" and sys_platform != "cygwin"
44
ddt >= 1.1.1, != 1.4.3
55
mock # Also needed to typecheck the Python 3.7 import branches.

0 commit comments

Comments
 (0)