threads / discuss / 59649

Inconsistent names in `git shortlog`

Subject: Inconsistent names in `git shortlog`

## tl;dr

4 messages between Apr 25, 2023 and Apr 25, 2023.

replies: 3people: 4as markdown or json

Blyxyas· Apr 25, 2023, 00:00 UTC · lore

`git shortlog` (specifically talking about `git shortlog -sn`, but applies to the whole subcommand) produces a list of names based on the contributors to a Git repository. But it turns out that the output of the shortlog is very inconsistent in that sometimes it uses the username and other times the full name. This can happen even in the same repo.

This isn't a big deal on its own, but there are some external tools (like thanks.rust-lang.org) that use the output of `git shortlog` to thank contributors, and it has some cases of people going just by their first name (no surnames), or people appearing multiple times, once with their username and one with their real name.

There should be a convention established. I would personally prefer using usernames, as the huge impact of Github would mean that it's easier to go to their profile just by copy-pasting their shortlog name. Maybe add a `--realname` / `-r` flag to the command to show the real names and show usernames by default?

brian m. carlson· Apr 25, 2023, 00:40 UTC · re: Blyxyas · lore

Re: Inconsistent names in `git shortlog`

On 2023-04-25 at 00:00:27, Blyxyas wrote:
Show 6 quoted lines
> `git shortlog` (specifically talking about `git shortlog -sn`, but
> applies to the whole subcommand) produces a list of names based on the
> contributors to a Git repository.
> But it turns out that the output of the shortlog is very inconsistent
> in that sometimes it uses the username and other times the full name.
> This can happen even in the same repo.

I don't think `git shortlog` considers anything but what's in the author name field, as far as I can tell. It may be that some people have placed a username in that field, which is contrary to the intention that it be a personal name, but we can't force people to use a particular name.

git-commit(1) documents this:
  The author and committer names are by convention some form of a
  personal name (that is, the name by which other humans refer to you),
  although Git does not enforce or require any particular form.
  Arbitrary Unicode may be used, subject to the constraints listed above
  [which I have elided here]. This name has no effect on authentication;
  for that, see the credential.username variable in git-config(1).

I added this documentation because many people _do_ think it has something to do with authentication and thus put a username there under that mistaken impression. I suspect that's what's happened in the situation you mention.

Show 5 quoted lines
> There should be a convention established. I would personally prefer
> using usernames, as the huge impact of Github would mean that it's
> easier to go to their profile just by copy-pasting their shortlog
> name. Maybe add a `--realname` / `-r` flag to the command to show the
> real names and show usernames by default?

There are many Git users who don't use GitHub, and the documented intention is that it be a personal name, so I'd recommend that people use that. Regardless, we don't know what a person's GitHub username is or if they have one, and Git wouldn't want to prioritize one particular forge over another, so we wouldn't add any sort of API requests to GitHub in particular.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Jeff King· Apr 25, 2023, 06:52 UTC · re: Blyxyas · lore

Re: Inconsistent names in `git shortlog`

On Tue, Apr 25, 2023 at 02:00:27AM +0200, Blyxyas wrote:
Show 5 quoted lines
> This isn't a big deal on its own, but there are some external tools
> (like thanks.rust-lang.org) that use the output of `git shortlog` to
> thank contributors, and it has some cases of people going just by
> their first name (no surnames), or people appearing multiple times,
> once with their username and one with their real name.

I agree with everything brian said elsewhere, but I wanted to add one thing: for this "multiple times" problem, it can be solved with a mailmap file, which associates names such that ones you don't like can be rewritten to ones that you do. See "git help mailmap" for details and examples.

-Peff
Junio C Hamano· Apr 25, 2023, 15:46 UTC · re: Jeff King · lore

Re: Inconsistent names in `git shortlog`

Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Tue, Apr 25, 2023 at 02:00:27AM +0200, Blyxyas wrote:
>
>> This isn't a big deal on its own, but there are some external tools
>> (like thanks.rust-lang.org) that use the output of `git shortlog` to
>> thank contributors, and it has some cases of people going just by
>> their first name (no surnames), or people appearing multiple times,
>> once with their username and one with their real name.
>
> I agree with everything brian said elsewhere, but I wanted to add one
> thing: for this "multiple times" problem, it can be solved with a
> mailmap file, which associates names such that ones you don't like can
> be rewritten to ones that you do. See "git help mailmap" for details and
> examples.

And another, potentially more effective, tool is to have a project convention. Teach the participant of your project to be consistent in the first place.

← back to recent threads