Re: [Cogito] Various bugs

Subsystems: the rest

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [Cogito] Various bugs

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:18

Petr Baudis [off-list ref] writes:
quoted
quoted
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  [off-list ref] 1139281078 -0800
    committer Junio C Hamano [off-list ref] 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)

Re: [Cogito] Various bugs

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:18


On Mon, 6 Feb 2006, Junio C Hamano wrote:
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  [off-list ref] 1139281078 -0800
    committer Junio C Hamano [off-list ref] 1139281078 -0800

That is, the user said GIT_AUTHOR_NAME is empty, so he gets a
commit with an empty author name.
Yes. That said, we should probably disallow that in git-commit-tree (and 
let the user fix it up some way).
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.
No, don't use the default name.

An empty GIT_AUTHOR_NAME should _not_ mean that we use the default name 
(which is usually the committer), because rather than meaning "default", 
it most likely means "buggy import script". 

I'd rather have an email import of mine say that it cannot commit, than 
have it put "Linus Torvalds" in the author line (and some random email).

			Linus

Re: [Cogito] Various bugs

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:18

Dear diary, on Tue, Feb 07, 2006 at 04:53:57PM CET, I got a letter
where Linus Torvalds [off-list ref] said that...

On Mon, 6 Feb 2006, Junio C Hamano wrote:
quoted
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  [off-list ref] 1139281078 -0800
    committer Junio C Hamano [off-list ref] 1139281078 -0800

That is, the user said GIT_AUTHOR_NAME is empty, so he gets a
commit with an empty author name.
That is what I expect and I must have done something wrong the last
night since it works for me now as well. Sorry. So I'm all alone at
this bug again. ;-)
Yes. That said, we should probably disallow that in git-commit-tree (and 
let the user fix it up some way).
What way? Sometimes you just receive mails from people who have only
email addy in the from line, or you can be importing from some other VCS
where the mapping does not exist and the importers may not deem it
necessary to have it in GIT. Sure, it may be kernel policy to disallow
this, but I wouldn't enforce this for all projects in GIT.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Of the 3 great composers Mozart tells us what it's like to be human,
Beethoven tells us what it's like to be Beethoven and Bach tells us
what it's like to be the universe.  -- Douglas Adams

Re: [Cogito] Various bugs

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:18


On Tue, 7 Feb 2006, Petr Baudis wrote:
quoted
Yes. That said, we should probably disallow that in git-commit-tree (and 
let the user fix it up some way).
What way? Sometimes you just receive mails from people who have only
email addy in the from line, or you can be importing from some other VCS
where the mapping does not exist and the importers may not deem it
necessary to have it in GIT. Sure, it may be kernel policy to disallow
this, but I wouldn't enforce this for all projects in GIT.
Umm. Having an empty name is _wrong_. It makes things like the shortlogs 
break.

Yes, it has happened in the kernel a few times, but those were bugs, and 
I'd have been very happy if git-write-tree had just aborted on me.

If you don't have any better name than the email/user-name, just use that 
(but at least for the kernel, I'd much prefer a round of "google" first to 
see if something better is available). An _empty_ name is never 
acceptable.

		Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help