Skip to content

I'm on the Authors list twice #923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
illegitimate-egg opened this issue Jan 8, 2023 · 17 comments
Closed
1 task done

I'm on the Authors list twice #923

illegitimate-egg opened this issue Jan 8, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@illegitimate-egg
Copy link

Duplicates

  • I have searched the existing issues

Current behavior 😯

Onefetch reports two Authors, when there is only one. Both authors are the same person.

Expected behavior 🤔

Onefetch reports one Author.

Steps to reproduce 🕹

  1. git clone https://github.com/illegitimate-egg/ncurses-prime
  2. onefetch

Additional context/Screenshots 🔦

image

Possible Solution 💡

No response

@illegitimate-egg illegitimate-egg added the bug Something isn't working label Jan 8, 2023
@o2sh
Copy link
Owner

o2sh commented Jan 8, 2023

Hi @illegitimate-egg,

All your commits were not made with the same email address:

image

To fix it you need to create a .mailmap file a the root of your repo (more info about mailmap) where you can specify the correct mapping.

With this mapping:
image

You'll get this:
image

@illegitimate-egg
Copy link
Author

Oh, thanks!

@spenserblack
Copy link
Collaborator

Do you think it's worth adding this to an FAQ? 🤔

@illegitimate-egg
Copy link
Author

Do you think it's worth adding this to an FAQ? 🤔

It's more of a problem with me being inexperienced with git

@spenserblack
Copy link
Collaborator

To be fair, I think mailmap isn't a well-known feature 🙂

@o2sh
Copy link
Owner

o2sh commented Jan 8, 2023

Do you think it's worth adding this to an FAQ? 🤔

image

Hopefully, people should stumble upon this issue before creating a duplicate.

@spenserblack
Copy link
Collaborator

Oh yeah, good point 😆

@jtmr05
Copy link
Contributor

jtmr05 commented Jan 9, 2023

The opposite is also happening: git shortlog -nse lists two different entries for the same email address but with different names, one being the Github Public Profile name and the other the actual account username. It would be nicer if entries with the same email address were added together, instead of simply following git shortlog's output.

@beutlich
Copy link

beutlich commented Jan 25, 2024

Even with having a .mailmap file available I see duplicated authors. Can anyone confirm with this repo?

@spenserblack
Copy link
Collaborator

spenserblack commented Jan 25, 2024

@beutlich Looks like your .mailmap lists every author and their email. The two most common use cases for mailmaps (IMO) is to fix the name mapped to an email, and provide a secondary email (and name) mapped to the author's primary info. For example, with this change alone, you're listed only once, since these are your two most frequently used emails:

diff --git a/.mailmap b/.mailmap
index 864f8ad46..5b7291e7b 100644
--- a/.mailmap
+++ b/.mailmap
@@ -114,8 +114,7 @@ Stephan Ziegler <[email protected]>
 Sven Erik Mattson <svenerik@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
 Thomas Beutlich <beutlich@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
 Thomas Beutlich <[email protected]>
-Thomas Beutlich <[email protected]>
-Thomas Beutlich <[email protected]>
+Thomas Beutlich <[email protected]> <[email protected]>
 Thomas Bödrich <ThomasBoedrich@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
 Volker Waurich <[email protected]>
 carlj-w <[email protected]>

Also, this would work:

diff --git a/.mailmap b/.mailmap
index 864f8ad46..aede18718 100644
--- a/.mailmap
+++ b/.mailmap
@@ -112,10 +112,9 @@ Stefan Wischhusen <wischhusen@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
 Stefan Wischhusen <[email protected]>
 Stephan Ziegler <[email protected]>
 Sven Erik Mattson <svenerik@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
-Thomas Beutlich <beutlich@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
-Thomas Beutlich <[email protected]>
-Thomas Beutlich <[email protected]>
-Thomas Beutlich <[email protected]>
+<[email protected]> <beutlich@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
+<[email protected]> <[email protected]>
+<[email protected]> <[email protected]>
 Thomas Bödrich <ThomasBoedrich@7ce873d0-865f-4ce7-a662-4bb36ea78beb>
 Volker Waurich <[email protected]>
 carlj-w <[email protected]>

More information here: https://git-scm.com/docs/gitmailmap

AFAIK This behavior is consistent with git shortlog --email.

@beutlich
Copy link

Thanks for the fast reply @spenserblack.

I generated that .mailmap file with line-wise author listing based on https://kevin.burke.dev/kevin/easy-maintenance-of-your-authors-file/ and it worked out in git or TortoiseGit.

Is there any chance that onefetch could also consider these line-wise author mapping?

@spenserblack
Copy link
Collaborator

spenserblack commented Jan 25, 2024

See #447 (and the linked PRs/issues in that discussion) for some more context, but I think we're pretty much set on sticking with email as the identifier.

I don't think that script was really intended to generate a .mailmap file -- quickly skimming that page seems to imply it was used to make a human-readable authors document to provide credit to contributors. Since your .mailmap was generated from a git log, I'm not really sure what it's actually accomplishing TBH. By "working out" do you mean "not breaking"? In fact, by updating your .mailmap to map all emails to the same person, I'd say it would fix the linked script by combining duplicates into one user (I tested this out on our own repository, where we have both same name + different email and same email + different name issues in our log 😅).

If you search for .mailmap files you should see that Author Name <[email protected]> <[email protected]> is a popular format. Besides onefetch, I'd say it's a pretty good standard to have a .mailmap when one author changes their info. It will also fix your own git log by providing a canonical email address/name in the author information.

@beutlich
Copy link

Thank your for your fast feedback.

By "working out" do you mean "not breaking"?

Sorry for not being excat enough. The given .mailmap file with line-wise authors is correctly taken into account by both

  • git command git shortlog -sn --since="25 January 2014"
  • TortoiseGit Statistics dialog if set
    grafik

Also, https://git-scm.com/docs/gitmailmap mentions

Joe R. Developer <[email protected]>
Jane Doe <[email protected]>
Jane Doe <jane@desktop.(none)>

as the corrected example to fix the names.

Given these points, my expectation was that this kind of formatting is a valid format for .mailmap (even it its original intent of generation was some AUTHORS file).

@spenserblack
Copy link
Collaborator

Also, https://git-scm.com/docs/gitmailmap mentions

Joe R. Developer <[email protected]>
Jane Doe <[email protected]>
Jane Doe <jane@desktop.(none)>

as the corrected example to fix the names.

Yes, which I interpret as the email being the person's identifier, and the name being a label. I.e. "this email has this name," not "this name has this email." Do you notice any change at all when you uncheck "use .mailmap"? Because, since your .mailmap is just a repetition of what is in the original commit information, I don't expect it would have any noticeable effect.

You might want to see TortoiseGit's own .mailmap 😉

You are correct that git shortlog -sn will combine the records, but git shortlog -sne will separate them (unless you fix the .mailmap like the patches from #923 (comment) demonstrate). We consider email to be the "more unique" and therefore more reliable identifier between between the committer's name and their email. Note that some popular tools, such as GitHub itself, use the email as the identifier, not the name. See spenserblack/test-repo@7d50c70, spenserblack/test-repo@b83afd5, and spenserblack/test-repo@037f07e, which are commits with a different author name, different author email, and committer email and author email each.

If your statement is "onefetch is not using the .mailmap correctly," currently I'm still not convinced that your .mailmap is valid (well, it's syntactically valid, but repeating all commit names and emails as proper names and emails is not that useful AFAIK). It's effectively stating that each record is a different person, since each line is only giving their proper name and email, not mapping their proper name and email to commit names and emails.

However, if your statement is "onefetch should combine matching author names into one record," then I believe there is some potential merit in that, given the low chances of two people having the same name in small to medium-sized projects, and I'd recommend raising a new issue so we could discuss that specifically. Even if we've already discussed and switched away from that, it could be good to at least reconsider.

@beutlich
Copy link

Thanks for the detailed reply and your offers. I now adapted the corresponding .mailmap file to the expected format. Unfortunately this was manual work.

@spenserblack
Copy link
Collaborator

🤔 It's never pleasant to do manual work 😅
For the most accuracy I think it's unavoidable -- a mailmap provides information the machine can't know with certainty: name changes, new emails, etc.

However, if you've gotten your mailmap into a good initial state now, it shouldn't be too difficult to write a script to detect any names or emails in the log that aren't in the mailmap. You could run this script in a GitHub workflow so that you're made aware when a new author is added (this can be triggered by a PR to catch it ahead of time or on push to the main branch to handle squash merges).

Personally, I've never bothered to add every author to a mailmap. Just the ones where I know the same person used two or more committer names/emails.

@beutlich
Copy link

beutlich commented Jan 28, 2024

Hm, as a side-effect of the .mailmap format change GitHub no longer displays the correct author avatar in the commit history.

grafik

Edit: Seems to be a browser caching issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants