Skip to content

gix_date::Time cannot represent any timestamp, preventing Signature to roundtrip #1923

Closed
@pierrechevalier83

Description

@pierrechevalier83

Current behavior 😯

Some timestamps can't be represented by gix_date::Time, which means that we don't roundtrip when parsing them into a Commit.

For instance, in the wild, we see this commit:

git cat-file -p 5e6ecdad9f69b1ff789a17733b8edc6fd7091bd8
tree 0d1971c86d047f9530aee85a50b8fc1ca12723ba
parent 9471b0ab889a4684f87952cb951f7f4dc3f59dda
author Shrikant Sharat Kandula <shrikantsharat.k@gmail.com> 1313584730 +051800
committer Shrikant Sharat Kandula <shrikantsharat.k@gmail.com> 1313584730 +051800
Typo in documentation
The kwarg is named `headers`, not `header`. Also, its a dict, not a set.

Notice that in the author and commiter fields, the timezone offset: +051800 does not match the expected [<sign><HH><MM>] format.

Expected behavior 🤔

I think the time member of Signature should be a BString and the time member of SignatureRef should be a & BStr. We should only parse the timestamp into a gix_date::Time when needed.

This would allow round-tripping.

Git behavior

No response

Steps to reproduce 🕹

I wrote this failing test, to show failure to roundtrip:

With that commit, cargo test from gix-actor outputs:

thread 'signature::round_trip' panicked at gix-actor/tests/signature/mod.rs:80:9:
assertion `left == right` failed
  left: "Sebastian Thiel <byronimo@gmail.com> 1313584730 +0000"
 right: "Sebastian Thiel <byronimo@gmail.com> 1313584730 +051800"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    signature::round_trip

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedan issue is accepted as shortcoming to be fixedhelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions