Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/gix-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Commit metadata uses `Repository.find_commit().decode()` plus structured
`Commit.author()`/`committer()` signatures. Tag metadata uses
`Repository.find_tag().decode()` and `Tag.tagger()`. A missing native tagger maps
to GitPython's empty actor and zero date/offset; tag reads remain native.
Tags with a signature block or a body of only line feeds use `git cat-file`
because the decoded message does not delimit the body as Git does (GIX-46).
Decoded extra headers retain
`gpgsig`. Raw Gix object bytes are used only for object streams. If repository
capabilities require CLI fallback, metadata uses `git cat-file`: general formatted
Expand Down Expand Up @@ -1019,6 +1021,7 @@ identify the historical fixture where needed.
| GIX-43 | Bug (open) | With Git 2.54.0 and GixPython 0.4.0, `commit.sh spaced-email` stores spaces inside the email brackets ahead of a date with trailing fields. Git's `%ae` and `%ce` preserve these bytes, but native commit author and committer accessors trim them. The native tagger accessor preserves the spaces. | Expose a signature identity that preserves the stored fields with Git-compatible delimiters. `object_metadata()` uses the existing CLI fallback if the native identity fails the raw header comparison. `test_deserialization_preserves_email_whitespace` verifies author, committer and tagger properties. |
| GIX-44 | Bug (open) | With Git 2.54.0 and GixPython 0.3.0, the `branch-dot-alias` case of `submodule-cases.sh` sets `HEAD` to `refs/heads/dev`, which points to `refs/heads/master`. `Repository.head_name()` and `Repository.head_ref().name()` return `refs/heads/dev`. `git symbolic-ref HEAD` returns `refs/heads/master`, and `git submodule update --remote` selects `origin/master` for `branch = .`. `test_update_to_latest_revision_follows_superproject_branch_alias` verifies branch selection on clone and later updates. Redirect `dev` to `refs/heads/missing` and Git returns that terminal name, while `Reference.follow_to_object()` raises a missing-ref error. | Expose the terminal symbolic target with Git-compatible handling of unborn, detached and invalid references. `Submodule._branch_for_update()` uses recursive `git symbolic-ref --quiet -- HEAD` through the CLI fallback. |
| GIX-45 | Bug (open) | Git 2.54.0 `submodule update --remote --no-fetch` rejects a bare `branch` key in `.gitmodules` with `missing value for 'submodule.module.branch'`, including before or after `branch = dev`. In GixPython 0.3.0 and 0.4.0, `ModulesFile.from_bytes()` accepts the bare key and `ModulesFile.branch()` returns `None` for an absent or single bare key. `ConfigFile.boolean()` distinguishes these two inputs with `None` and `True`, respectively. When the bare key precedes `branch = dev`, both `ModulesFile.branch().name_bytes()` and `ConfigFile.string()` return `b"dev"`. For an explicit `branch =` with an `origin` remote, Git attempts to resolve `refs/remotes/origin/`, `ModulesFile.branch().name_bytes()` returns `b"HEAD"`, and `ConfigFile.string()` returns `b""`. | Reject valueless branches in a Git-compatible mode or expose all raw values, including implicit ones. `submodule_config()` falls back to the Git config reader for possible bare `branch` keys and uses `ConfigFile.string()` for assigned values. `test_valueless_branch_is_invalid` covers listing and rereads with a single bare key and one followed by an assignment. |
| GIX-46 | Bug (open) | With Git 2.54.0 and GixPython 0.3.0, `Tag.decode()` omits the line feed that separates a tag message from a trailing `PGP SIGNATURE`, `PGP MESSAGE`, `SIGNED MESSAGE` or `SSH SIGNATURE` armor block. A tag made with `git tag -s -m 'Release 1.0'` and `gpg.format=ssh` decodes to the message `Release 1.0` and a signature starting at `-----BEGIN SSH SIGNATURE-----`, while `git cat-file tag` stores `Release 1.0\n` before the armor; joining both fields lost that line feed in `TagObject.message`. A body that starts with the armor and one that starts with an empty line before it therefore decode to the same fields. A body of only line feeds gains one: `\n\n` decodes as `\n\n\n` and an empty body as `\n`. The `tag-message` read-only `refs.sh` fixture in `test_tag_message_matches_git` reproduces the signed, empty-line and line-feed cases for SHA-1 and SHA-256. | Report a message and signature that reproduce the tag body, including the separating line feed, and report bodies of only line feeds unchanged, at least in a Git-strict decoding mode. `object_metadata()` selects CLI when Gix splits off a signature or reports a message of two or more line feeds and nothing else; an empty body decoded as `\n` already yields GitPython's empty message after its final line-feed trim. This adapter guard does not close the upstream compatibility bug. |

GIX-14 also covers configured worktree symlink resolution. On macOS with
GixPython 0.3.0, CPython 3.12.14 and Git 2.54.0, set a submodule's
Expand Down
6 changes: 6 additions & 0 deletions git/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ def object_metadata(command: Any, oid: str, kind: str) -> Any:
"committer": obj.committer(),
}
else:
# Gix omits the line feed before a signature, so a body starting with the
# signature decodes like one starting with an empty line, and adds a line
# feed to a body of only line feeds (GIX-46). An empty body decodes as one
# line feed, which TagObject's final line-feed trim already removes.
if data.signature is not None or (len(data.message) > 1 and not data.message.strip(b"\n")):
raise _Unsupported("tag message boundaries (GIX-46)")
result = {
"target": data.target.decode("ascii"),
"target_kind": data.target_kind,
Expand Down
25 changes: 25 additions & 0 deletions test/test_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,31 @@ def test_tag_without_tagger_initializes_all_metadata(object_format, message):
assert tag.message == message


@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
@pytest.mark.parametrize(
"variant, body",
[
pytest.param(variant, body, id=variant)
for variant, body in (
("pgp", "release\n-----BEGIN PGP SIGNATURE-----\nc2ln\n-----END PGP SIGNATURE-----\n"),
("ssh", "release\n-----BEGIN SSH SIGNATURE-----\nc2ln\n-----END SSH SIGNATURE-----\n"),
("empty-line", "\n-----BEGIN PGP SIGNATURE-----\nc2ln\n-----END PGP SIGNATURE-----\n"),
("line-feeds", "\n\n"),
)
],
)
def test_tag_message_matches_git(object_format, variant, body):
with fixture_repo("refs.sh", "tag-message", object_format, variant) as repo:
oid = (Path(repo.working_tree_dir).parent / "tag-id").read_text().strip()
raw = repo.git.cat_file("tag", oid, stdout_as_string=False, strip_newline_in_stdout=False)
assert raw.partition(b"\n\n")[2] == body.encode()
before = _backend.statistics()
assert TagObject(repo, bytes.fromhex(oid)).message == body[:-1]
if _backend.name == "gix":
key = ("tag.decode", "CLI: tag message boundaries (GIX-46)")
assert _backend.statistics().get(key, 0) == before.get(key, 0) + 1


@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
def test_head_rename_retains_literal_prefixed_branch_name(object_format):
with fixture_repo("refs.sh", "rename-prefixed", object_format, write=True) as repo:
Expand Down
13 changes: 13 additions & 0 deletions tests/fixtures/refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ case "$1" in
fi
} | git hash-object -w -t tag --literally --stdin >../tag-id
;;
tag-message)
{
printf 'object %s\ntype commit\ntag v1\n' "$(git rev-parse HEAD)"
printf 'tagger T <t@example.com> 1700000000 +0000\n\n'
case "$3" in
pgp) printf 'release\n-----BEGIN PGP SIGNATURE-----\nc2ln\n-----END PGP SIGNATURE-----\n' ;;
ssh) printf 'release\n-----BEGIN SSH SIGNATURE-----\nc2ln\n-----END SSH SIGNATURE-----\n' ;;
empty-line) printf '\n-----BEGIN PGP SIGNATURE-----\nc2ln\n-----END PGP SIGNATURE-----\n' ;;
line-feeds) printf '\n\n' ;;
*) exit 1 ;;
esac
} | git hash-object -w -t tag --literally --stdin >../tag-id
;;
rename-prefixed)
git branch topic
printf 'second\n' >> file.txt
Expand Down
Loading