-
-
Notifications
You must be signed in to change notification settings - Fork 353
[gix-object] Support empty tags with or without trailing NL #1903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, that's great!
I definitely had problems getting the parsing right and by now tests are all we have :D.
Regarding the commit I force-pushed, it's only changing the subject, even though it looks like I am the author now.
This is due to the author being strangely formatted:
❯ gix cat @
tree 12ca5ffc6ce6ad1682ecafdd31bb2e223f5ad0b3
parent 6d5f77413e63cad45415d0f674c58d41091bffa1
author Pierre Chevalier pierrec@meta.com <> 1742556630 +0000
committer Sebastian Thiel <sebastian.thiel@icloud.com> 1742613444 +0800
gpgsig -----BEGIN PGP SIGNATURE-----
This already was the case in the original.
❯ gix cat 2435710b4
tree 12ca5ffc6ce6ad1682ecafdd31bb2e223f5ad0b3
parent 6d5f77413e63cad45415d0f674c58d41091bffa1
author Pierre Chevalier redacted@meta.com <> 1742556630 +0000
committer Pierre Chevalier <pierrechevalier-redacted> 1742565757 +0000
Thus I'd leave it to you to change the subject and force-push again so the authorship comes out correctly. And maybe there is a way to fix the author line while at it :).
When representing an annotated tag with an empty commit message, we used to only support a tag ending with two newlines (one after the tagger line + one after the empty commit message). This was due to a misconception that annotated tags ending with a single NL shouldn't exist in the wild since there isn't an obvious way to create them from with `git`. This misconception shows up in the discussion thread for [issue 603](GitoxideLabs#603) It turns out that both encodings of empty annotated tags appear in the wild. We must be able to parse either and roundtrip for either. Before [PR 604](GitoxideLabs#604), we used to special case the empty tag msg case and not add a NL. To be able to represent `b""`, `b"\n"`, `b"\n\n"`..., we special case any `message` that is a pure sequence of `b'\n'` and actually parse the `b'\n'` into the tag's message. This allows us to calculate the correct size that matches the number of bytes that git would produce, as well as round-trip to and from the commit encoding. The existing tests (in particular `round_trip` for `empty.txt` and `empty_missing_nl.txt`) convince me that the logic is sound. Also, the size being `139` bytes for `empty_missing_nl.txt` and `140` bytes for `empty.txt` matches the output of `cat file | wc -l` for each file.
5218202
to
f69890c
Compare
Thanks for the fast review. I've fixed the author/committer fields and rebased the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thanks! Thanks for the fast turnaround, too!
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
Summary: ignore-conflict-markers Upgrade gitoxide crates to latest release to propagate some upstream fixes: * [[gix-object] Support empty tags with or without trailing NL](GitoxideLabs/gitoxide#1903) * [[fix] Make Tree roundtrip by storing additional bit of information](GitoxideLabs/gitoxide#1917) * [fix: Make email with spaces round-trip](GitoxideLabs/gitoxide#1922) * [Make author and committer date roundtrip](GitoxideLabs/gitoxide#1935) Reviewed By: quark-zju Differential Revision: D74337531 fbshipit-source-id: 5361c7d4b0b52c683e05af8d19ac2169aebc8197
When representing an annotated tag with an empty commit message, we used to only support a tag ending with two newlines (one after the tagger line + one after the empty commit message).
This was due to a misconception that annotated tags ending with a single NL shouldn't exist in the wild since there isn't an obvious way to create them with
git
.This misconception shows up in the discussion thread for issue 603
It turns out that both encodings of empty annotated tags appear in the wild.
We must be able to parse either and roundtrip for either.
Before PR 604, we used to special case the empty tag msg case and not add a NL. To be able to represent
b""
,b"\n"
,b"\n\n"
..., we special case anymessage
that is a pure sequence ofb'\n'
and actually parse theb'\n'
into the tag's message.This allows us to calculate the correct size that matches the number of bytes that git would produce, as well as round-trip to and from the commit encoding.
The existing tests (in particular
round_trip
forempty.txt
andempty_missing_nl.txt
) convince me that the logic is sound. Also, the size being139
bytes forempty_missing_nl.txt
and140
bytes forempty.txt
matches the output ofcat file | wc -l
for each file.