Skip to content

Use git config to get mailmap path #32

@mklein994

Description

@mklein994

It would be nice to use git config to get the mailmap path, as determined by git. Currently it's hard-coded to .mailmap at the top of the repository, ignoring what's set by mailmap.file (see git-config(1)).

Here's an example. Let's say I have a couple of repositories in ~/projects/, like this:

[me@pc ~]$ tree -Fa
./
├── .gitconfig
└── projects/
    ├── .mailmap
    ├── my-app/
    │   ├── .git/
    │   └── ...
    ├── shared-lib/
    │   ├── .git/
    │   └── ...
    └── team-website/
        ├── .git/
        └── ...

With this in my ~/.gitconfig:

[mailmap]
  file = ~/projects/.mailmap

With this setup, I can share a common .mailmap file across projects. Conveniently, git provides a way to get this value in a machine-readable way:

[me@pc ~/projects/my-app]$ git config get --default=.mailmap --type=path mailmap.file
/home/me/projects/.mailmap
  • --default=.mailmap: Use .mailmap as the default value if git can't determine what it should be
  • --type=path: Resolve ~, $HOME, and ~user shorthands to their respective values

Reading through the docs again however, I'm realizing that to properly handle mailmap files, git will merge them from multiple sources (see git-config(1): mailmap.file), so it could get complicated quickly, but this could provide a useful start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions