Configuring git log to use mailmap by default
Asked Answered
A

5

30

Is there a way to configure git log to use a mailmap file by default? Without having to specify a format (or an alias for one).

Antiquary answered 8/12, 2012 at 11:49 Comment(6)
That question is quite unclear. Do you want to specify a default output format in which log respects a .mailmap, as specified by the git-log man page or do you mean to supply a defailt mailmap file?Gerek
Neither. I explicitly do not want to specify the format but I'm not concerned with where the mailmap file is either. I do want git log commands to use the mailmap file though, they don't by default.Antiquary
Well, if you always want to use a mailmap file, you'll have to specify a default, or git wont know what to do. the git-log man refers to the git-shortlog and git-config man about "mailmap.file"Gerek
This isn't really relevant to the question, but the default is to use one in the root of the repository.Antiquary
It is very relevant, because that's what youre asking. You should have mentioned that in the question right away. The links I posted explains how git log uses .mailmap and how you can set a default with git config. If you need more help, I'll draw up a proper answer when I can. Meanwhile, you should remove the "logging" tag since this question has nothing to do with logging.Gerek
No, it's fundamentally, absolutely, categorically not what I'm asking. Perhaps English isn't your first language but as the documentation implies, git log does not use a .mailmap in the default location at the root of the repository by default. git shortlog does, git log does not. I couldn't care less if I had to explicitly define the location of the mailmap file anyway - I just want git log to use it without specifying a custom format. This is nothing to do with where the .mailmap actually resides or the configuration to find it.Antiquary
S
30

I have Git 2.4.1. If you set log.mailmap config to true, that will set it to work with git log also

git config --global log.mailmap true
Semiyearly answered 17/6, 2015 at 18:58 Comment(1)
In case it helps future visitors who are using a pretty-formats log, the setting above is ignored. Instead, look up the .mailmap-respecting placeholders (%aN, %aE for author and %cN, %cE for committer).Mawkish
P
16

You can set up defaults in your .gitconfig file. The documentation says:

log.mailmap

If true, makes git-log, git-show, and git-whatchanged assume --use-mailmap.

This will look for a .mailmap only in the root of the working tree.

To set:

git config --global log.mailmap true

Global mailmap file

mailmap.file

The location of an augmenting mailmap file. The default mailmap, located in the root of the repository, is loaded first, then the mailmap file pointed to by this variable. The location of the mailmap file may be in a repository subdirectory, or somewhere outside of the repository itself. See git-shortlog and git-blame.

To set:

git config --global mailmap.file ~/.mailmap

Advanced

You can also use a repository blob as a mailmap file, see mailmap.blob in the documentation linked to above.

Profitable answered 7/10, 2016 at 6:19 Comment(0)
S
6

As of git 1.8.2, git log takes a --use-mailmap parameter to enable this behavior.

Sassenach answered 7/1, 2015 at 19:9 Comment(0)
A
5

It appears that this isn't a feature, yet, due to hysterical raisins.

Antiquary answered 8/12, 2012 at 20:59 Comment(1)
aboriginal lynx died, but the archive has a copy: git.661346.n2.nabble.com/…Niobe
M
4

Warning Git 2.23 (Q3 2019) states that a future version of Git would use log.mailmap by default

The "git log" command learns to issue a warning when log.mailmap configuration is not set and --[no-]mailmap option is not used, to prepare users for future versions of Git that uses the mailmap by default.

See commit ef60740, commit 2d9c569, commit f0596ec (15 Jul 2019) by Ariadne Conill (``).
(Merged by Junio C Hamano -- gitster -- in commit c7cf2de, 25 Jul 2019)

log: add warning for unspecified log.mailmap setting

Based on discussions around changing the log.mailmap default to being enabled, it was decided that a transitional period is required.

Accordingly, we announce this transitional period with a warning message.

The warning message is:

log.mailmap is not set; its implicit value will change in an upcoming release.

  • To squelch this message and preserve current behaviour, set the log.mailmap configuration value to false.

  • To squelch this message and adopt the new behaviour now, set the log.mailmap configuration value to true.

Initial description:

People who have changed their name or email address will usually know that they need to set 'log.mailmap' in order to have their new details reflected for old commits with 'git log', but others who interact with them may not know or care enough to enable this option.

Change the default for 'git log' and friends to always use mailmap so that everyone gets to see canonical names and email addresses.


With Git 2.27 (Q2 2020), "git log" learns "--[no-]mailmap" as a synonym to "--[no-]use-mailmap"

See commit 88acccd, commit c28b036, commit 7c28058 (16 Mar 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 9404128, 28 Apr 2020)

log: give --[no-]use-mailmap a more sensible synonym --[no-]mailmap

The option name "--use-mailmap" looks OK, but it becomes awkward when you have to negate it, i.e. "--no-use-mailmap".

I, perhaps with many other users, always try "--no-mailmap" and become unhappy to see it fail.

Add an alias "--[no-]mailmap" to remedy this.

Myrmecology answered 27/7, 2019 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.