Skip to content

The CommitRef from invalid_email_or_committer test cannot be materialized or round-tripped #2177

@ilyagr

Description

@ilyagr

Current behavior 😯

At the latest commit a78bf84...

Update: Got the same result at the actually latest commit 442f800.

I modified the test as follows:

diff --git a/gix-object/tests/object/commit/from_bytes.rs b/gix-object/tests/object/commit/from_bytes.rs
index b89213394..09f6653fd 100644
--- a/gix-object/tests/object/commit/from_bytes.rs
+++ b/gix-object/tests/object/commit/from_bytes.rs
@@ -37,9 +37,17 @@ fn invalid_email_of_committer() {
         email: b"gh <Gregor Hartmann<[email protected]".as_bstr(),
         time: "1282910542 +0200",
     };
+    let fixture = fixture_name("commit", "invalid-actor.txt");
+    let commit_ref = CommitRef::from_bytes(&fixture).expect("ignore strangely formed actor format");
+    let mut buf = vec![];
+    let write_result = commit_ref.write_to(&mut buf);
+    dbg!(&buf.as_bstr());
+    dbg!(&write_result);
+    assert!(write_result.is_ok(), "write result is not OK");
+    // The assert above fails
+
     assert_eq!(
-        CommitRef::from_bytes(&fixture_name("commit", "invalid-actor.txt"))
-            .expect("ignore strangely formed actor format"),
+        commit_ref,
         CommitRef {
             tree: b"220738fd4199e95a2b244465168366a73ebdf271".as_bstr(),
             parents: [b"209fbe2d632761b30b7b17422914e11b93692833".as_bstr()].into(),

The resulting test fails:

---- commit::from_bytes::invalid_email_of_committer stdout ----
[gix-object/tests/object/commit/from_bytes.rs:44:5] &buf.as_bstr() = "tree 220738fd4199e95a2b244465168366a73ebdf271\nparent 209fbe2d632761b30b7b17422914e11b93692833\nauthor Gregor Hartmann <"
[gix-object/tests/object/commit/from_bytes.rs:45:5] &write_result = Err(
    Custom {
        kind: Other,
        error: IllegalCharacter,
    },
)

thread 'commit::from_bytes::invalid_email_of_committer' (43952483) panicked at gix-object/tests/object/commit/from_bytes.rs:46:5:
write result is not OK

Expected behavior 🤔

The test should pass.

AFAIU, CommitRef should always be possible to materialize. If commits like the one in invalid-actor.txt exist in the wild, I'd want to round-trip them.

Git behavior

No response

Steps to reproduce 🕹

No response

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