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

Re: [Cogito] Various bugs

From
Junio C Hamano <junkio@cox.net>
Date
Feb 7, 2006, 03:03 UTC
Message-ID
<7v8xsn50rf.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060207021006.GM31278@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
Show 10 quoted lines
>> > I'm puzzled. GIT should handle this fine.
>> >
>> > 	export GIT_AUTHOR_NAME=''
>> > 	git-commit-tree $(cg-object-id -t)
>> >
>> > works as expected, but for some reason escaping me it does not work
>> > inside of cg-commit. Insights welcomed.
>> ...
> Thanks, I've updated the cg-commit version. Note that the empty
> GIT_AUTHOR_NAME problem seems to exist in git-commit as well.
It depends on what you expect, but it meets _my_ expectation:
    $ GIT_AUTHOR_NAME='' git-commit-tree $(git-write-tree) </dev/null
    Committing initial tree a2b59c3848164a2c9c3c75fbaadccaed9485da92
    ef90563fa278735af367e7606ea7eb2559121ca7
    $ git-cat-file commit ef90563fa278735af367e7606ea7eb2559121ca7
    tree a2b59c3848164a2c9c3c75fbaadccaed9485da92
    author  <junkio@cox.net> 1139281078 -0800
    committer Junio C Hamano <junkio@cox.net> 1139281078 -0800

That is, the user said GIT_AUTHOR_NAME is empty, so he gets a commit with an empty author name.

get_ident() in ident.c does this. getenv("GIT_AUTHOR_NAME") and friends are passed to it, and git_default_* are takenfrom gecos. It might match some peoples' expectation (but not mine) if we did this instead.

diff --git a/ident.c b/ident.c
index 0461b8b..7ec7516 100644
--- a/ident.c
+++ b/ident.c
@@ -163,9 +163,9 @@ static const char *get_ident(const char 
 	char date[50];
 	int i;
 
-	if (!name)
+	if (!name || !*name)
 		name = git_default_name;
-	if (!email)
+	if (!email || !*email)
 		email = git_default_email;
 	strcpy(date, git_default_date);
 	if (date_str)
Previous: Petr BaudisNext: Linus Torvalds
Message 5 of 10 in “[Cogito] Various bugs”
  1. Jonas FonsecaJan 31, 2006
  2. Petr BaudisFeb 7, 2006
  3. Junio C HamanoFeb 7, 2006
  4. Petr BaudisFeb 7, 2006
  5. Junio C HamanoFeb 7, 2006
  6. Linus TorvaldsFeb 7, 2006
  7. Petr BaudisFeb 7, 2006
  8. Linus TorvaldsFeb 7, 2006
  9. Junio C HamanoFeb 7, 2006
  10. Jonas FonsecaFeb 7, 2006

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.