Please sign in to comment.
ident: check /etc/mailname if email is unknown
Before falling back to gethostname(), check /etc/mailname if GIT_AUTHOR_EMAIL is not set in the environment or through config files. Only fall back if /etc/mailname cannot be opened or read. The /etc/mailname convention comes from Debian policy section 11.6 ("mail transport, delivery and user agents"), though maybe it could be useful sometimes on other machines, too. The lack of this support was noticed by various people in different ways: - Ian observed that git was choosing the address 'email@example.com' rather than 'firstname.lastname@example.org' as it should have done. - Jonathan noticed that operations like "git commit" were needlessly slow when using a resolver that was slow to handle reverse DNS lookups. Alas, after this patch, if /etc/mailname is set up and the [user] name and email configuration aren't, the committer email will not provide a charming reminder of which machine commits were made on any more. But I think it's worth it. Mechanics: the functionality of reading mailname goes in its own function, so people who care about other distros can easily add an implementation to a similar location without making copy_email() too long and losing clarity. While at it, we split out the fallback default logic that does gethostname(), too (rearranging it a little and adding a check for errors from gethostname while at it). Based on a patch by Gerrit Pape <email@example.com>. Requested-by: Ian Jackson <firstname.lastname@example.org> Signed-off-by: Jonathan Nieder <email@example.com> Improved-by: Junio C Hamano <firstname.lastname@example.org> Signed-off-by: Junio C Hamano <email@example.com>
- Loading branch information...
Showing with 61 additions and 15 deletions.