git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 3, 2011, 19:13 UTC
Message-ID
<7vty7pga7y.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20111003074433.GD17289@elie>
Jonathan Nieder <jrnieder@gmail.com> 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;
Previous: Jonathan NiederNext: Jonathan Nieder
Message 6 of 11 in “ident: check /etc/mailname if email is unknown”
  1. ident: check /etc/mailname if email is unknownJonathan Nieder, Oct 3, 2011
  2. Junio C HamanoOct 3, 2011
  3. ident: check /etc/mailname if email is unknownJonathan Nieder, Oct 3, 2011
  4. Johannes SixtOct 3, 2011
  5. Jonathan NiederOct 3, 2011
  6. Junio C HamanoOct 3, 2011
  7. ident: do not retrieve default ident when unnecessaryJonathan Nieder, Oct 6, 2011
  8. Junio C HamanoOct 6, 2011
  9. Jonathan NiederOct 6, 2011
  10. Ian JacksonOct 3, 2011
  11. Junio C HamanoOct 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.