You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Support empty tags with or without trailing NL
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.
0 commit comments