Skip to content
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

Improve the default user name & email logic #487

Merged
merged 3 commits into from Oct 15, 2015

Conversation

dscho
Copy link
Member

@dscho dscho commented Oct 13, 2015

The concept of using getpwuid() is slightly incompatible with the design of the related functions in the Win32 API. While it does have a way to provide the user's display name (which is called "gecos"), there is no POSIX function to obtain the email address of the current user.

So let's work a little bit harder to provide sensible defaults.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Oct 13, 2015

Cc @lutzroeder

@buildhive
Copy link

Git for Windows » git #15 FAILURE
Looks like there's a problem with this pull request
(what's this?)

@dscho
Copy link
Member Author

dscho commented Oct 13, 2015

Oh @buildhive! I tested with Linux locally and it works without problems. That test case is completely unrelated to the changes in this Pull Request, anyway.

So I only await the comments of @lutzroeder before merging...

@dscho
Copy link
Member Author

dscho commented Oct 15, 2015

Should USER_EMAIL be called USER_PRINCIPAL_NAME as this is what is actually querying?

Personally, I find the name USER_PRINCIPAL_NAME referring to the user's email address perfectly confusing 😜

if we stick with EXTENDED_NAME_FORMAT (name of the Windows enum) it should use similar/same names to avoid confusion?

I guess you're right. I need to use NameUserPrincipal and NameDisplay instead. Even if they are not exactly intuitive names, they should match the original definition.

We do have the excellent GetUserInfoEx() function to obtain more
detailed information of the current user (if the user is part of a
Windows domain); Let's use it.

Suggested by Lutz Roeder.

To avoid the cost of loading Secur32.dll (even lazily, loading DLLs
takes a non-neglibile amount of time), we use the established technique
to load DLLs only when, and if, needed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When a user is registered in a Windows domain, it is really easy to
obtain the email address. So let's do that.

Suggested by Lutz Roeder.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Oct 15, 2015

And now I made it so. @lutzroeder could you have another look, please?

@lutzroeder
Copy link

Looks good

dscho added a commit that referenced this pull request Oct 15, 2015
Improve the default user name & email logic
@dscho dscho merged commit 5269287 into git-for-windows:master Oct 15, 2015
@dscho dscho deleted the default-username branch October 15, 2015 11:05
@dscho
Copy link
Member Author

dscho commented Oct 15, 2015

Thanks!

@buildhive
Copy link

Git for Windows » git #17 FAILURE
Looks like there's a problem with this pull request
(what's this?)

dscho added a commit that referenced this pull request Oct 19, 2015
Improve the default user name & email logic
dscho added a commit that referenced this pull request Nov 9, 2015
Improve the default user name & email logic
dscho added a commit that referenced this pull request Dec 11, 2015
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jan 5, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jan 28, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Feb 6, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Feb 23, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Mar 15, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Mar 18, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Mar 29, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Apr 4, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Apr 30, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request May 20, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jun 9, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jun 9, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jun 9, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jun 14, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 12, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 16, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 23, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 23, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 23, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 27, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 27, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Jul 29, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Aug 2, 2016
Improve the default user name & email logic
dscho added a commit that referenced this pull request Aug 2, 2016
Improve the default user name & email logic
dscho pushed a commit that referenced this pull request Aug 2, 2016
Improve the default user name & email logic
dscho pushed a commit that referenced this pull request Aug 2, 2016
Improve the default user name & email logic
dscho pushed a commit that referenced this pull request Aug 5, 2016
Improve the default user name & email logic
dscho pushed a commit that referenced this pull request Aug 6, 2016
Improve the default user name & email logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants