Re: [PATCH v2] ident: check /etc/mailname if email is unknown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> In the long term it would be nice to find a way to warn when the
> mailname we tried to retrieve was actually going to be used, but short
> of that, the least confusing behavior is to just not warn at all.

I would think that if we widely advertise that we read from /etc/mailname
if/when it exists, a user who wonders why it is not used would appreciate
it if Git tells them why when it cannot use it.

But I agree that has to happen _after_ we flip the logic so that
setup_ident() does not trigger when the user gave us the necessary
information.

I wonder if that "flipping the logic" would be as simple as something like
this. It probably is about time for us to stop using the static array that
is hardwired MAX_GITNAME bytes long and start using strbuf, so I didn't
bother with strlcpy().


 ident.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/ident.c b/ident.c
index edb4314..9cc55f7 100644
--- a/ident.c
+++ b/ident.c
@@ -239,6 +239,10 @@ const char *fmt_ident(const char *name, const char *email,
 	int warn_on_no_name = (flag & IDENT_WARN_ON_NO_NAME);
 	int name_addr_only = (flag & IDENT_NO_DATE);
 
+	if (name && !git_default_name[0])
+		strcpy(git_default_name, name);
+	if (email && !git_default_email[0])
+		strcpy(git_default_email, email);
 	setup_ident();
 	if (!name)
 		name = git_default_name;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]