Skip to content

gix-mailmap parser treats mappings with old but not new names as an error #1416

@emilazy

Description

@emilazy

Current behavior 😯

<b> test <a> is silently discarded, unlike <b> <a> and test2 <b> test1 <a>

Expected behavior 🤔

Old names, new names, and new emails should be treated uniformly; any combination that includes an old email address should parse and function.

Git behavior

Git treats this entry as valid and maps signatures accordingly:

emily@yuyuko ~/gix-mailmap-bug> git init
Initialized empty Git repository in /Users/emily/gix-mailmap-bug/.git/
emily@yuyuko ~/gix-mailmap-bug (main)> echo '<b> test <a>' >.mailmap
emily@yuyuko ~/gix-mailmap-bug (main)> git check-mailmap 'test <a>'
test <b>

Steps to reproduce 🕹

emily@yuyuko ~/gix-mailmap-bug (main)> cat src/main.rs
use gix::actor::SignatureRef;
use gix::mailmap;

fn main() {
    let mailmap = mailmap::Snapshot::from_bytes(b"<b> test <a>");
    let signature = SignatureRef {
        name: "test".into(),
        email: "a".into(),
        time: Default::default(),
    };
    dbg!(mailmap.entries(), signature, mailmap.resolve(signature));
}
emily@yuyuko ~/gix-mailmap-bug (main)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/gix-mailmap-bug`
[src/main.rs:11:5] mailmap.entries() = []
[src/main.rs:11:5] signature = SignatureRef {
    name: "test",
    email: "a",
    time: Time {
        seconds: 0,
        offset: 0,
        sign: Plus,
    },
}
[src/main.rs:11:5] mailmap.resolve(signature) = Signature {
    name: "test",
    email: "a",
    time: Time {
        seconds: 0,
        offset: 0,
        sign: Plus,
    },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions