threads / discuss / 3197

[Cogito] Various bugs

Subject: [Cogito] Various bugs

## tl;dr

10 messages between Jan 31, 2006 and Feb 7, 2006.

replies: 9people: 4as markdown or json

Jonas Fonseca· Jan 31, 2006, 04:13 UTC · lore
A few Cogito bugs I found yesterday.
 - cg-fetch between local repos fails when the cloned branch URL does
   not point to a .git directory and a needed object from the repository
   being cloned is packed. git-local-fetch expects a .git directory.
 - cg-commit -c will do the wrong thing (use the invokers gecos info)
   when the author name is empty. One workaround is to make
   pick_author_script append a space at the end of the GIT_* variables.
   GIT will strip those and no gecos info is used.
 - cg-status reports a deleted file both as deleted and as unknown:
	fonseca@antimatter:~/src/elinks/0.12 > git --version
	git version 1.1.6.g1506
	fonseca@antimatter:~/src/elinks/0.12 > cg --version
	cogito-0.17pre.GIT (d3aa9a2b3375e36c774ea477492db76baa1db03e)
	fonseca@antimatter:~/src/elinks/0.12 > cg rm AUTHORS
	Removing file AUTHORS
	fonseca@antimatter:~/src/elinks/0.12 > cg status | grep AUTHORS
	? AUTHORS
	D AUTHORS
-- 
Jonas Fonseca
Petr Baudis· Feb 7, 2006, 00:36 UTC · re: Jonas Fonseca · lore

Re: [Cogito] Various bugs

Dear diary, on Tue, Jan 31, 2006 at 05:13:18AM CET, I got a letter where Jonas Fonseca <fonseca@diku.dk> said that...

Show 5 quoted lines
> A few Cogito bugs I found yesterday.
> 
>  - cg-fetch between local repos fails when the cloned branch URL does
>    not point to a .git directory and a needed object from the repository
>    being cloned is packed. git-local-fetch expects a .git directory.

Can't reproduce and I don't buy it. The very first line of local fetch handler is

	[ -d "$uri/.git" ] && uri="$uri/.git"
>  - cg-commit -c will do the wrong thing (use the invokers gecos info)
>    when the author name is empty. One workaround is to make
>    pick_author_script append a space at the end of the GIT_* variables.
>    GIT will strip those and no gecos info is used.

I'd rather fix this in GIT than workaround in Cogito. Will follow up with a patch.

... Hmm. ...

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.

Show 11 quoted lines
>  - cg-status reports a deleted file both as deleted and as unknown:
> 
> 	fonseca@antimatter:~/src/elinks/0.12 > git --version
> 	git version 1.1.6.g1506
> 	fonseca@antimatter:~/src/elinks/0.12 > cg --version
> 	cogito-0.17pre.GIT (d3aa9a2b3375e36c774ea477492db76baa1db03e)
> 	fonseca@antimatter:~/src/elinks/0.12 > cg rm AUTHORS
> 	Removing file AUTHORS
> 	fonseca@antimatter:~/src/elinks/0.12 > cg status | grep AUTHORS
> 	? AUTHORS
> 	D AUTHORS

This is fine, I'd say. The file was not deleted from the tree, either do that manually by rm or say cg-rm -f.

-- 
				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
Junio C Hamano· Feb 7, 2006, 02:03 UTC · re: Petr Baudis · lore

Re: [Cogito] Various bugs

Petr Baudis <pasky@suse.cz> writes:
Show 7 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.

They probably do not have anything to do with the problem at hand, but I just noticed your version of pick-author code in cg-commit lacks two changes I added to git-commit:

 (1) the pick_author_script you have in cg-commit lacks the
     support for names with single-quotes in them
     (aa66c7ec77d474b737da607d6cb2d07f56628def).
 (2) I run the sed script with LANG and LC_ALL set to C locale.
     I think I had some trouble without them with high-bit
     names, (e3e291fc07b49b74bb655ca854bdb19e849e044c) but the
     detail escapes me.
Petr Baudis· Feb 7, 2006, 02:10 UTC · re: Junio C Hamano · lore

Re: [Cogito] Various bugs

Dear diary, on Tue, Feb 07, 2006 at 03:03:13AM CET, I got a letter where Junio C Hamano <junkio@cox.net> said that...

Show 22 quoted lines
> Petr Baudis <pasky@suse.cz> writes:
> 
> > 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.
> 
> They probably do not have anything to do with the problem at
> hand, but I just noticed your version of pick-author code in
> cg-commit lacks two changes I added to git-commit:
> 
>  (1) the pick_author_script you have in cg-commit lacks the
>      support for names with single-quotes in them
>      (aa66c7ec77d474b737da607d6cb2d07f56628def).
> 
>  (2) I run the sed script with LANG and LC_ALL set to C locale.
>      I think I had some trouble without them with high-bit
>      names, (e3e291fc07b49b74bb655ca854bdb19e849e044c) but the
>      detail escapes me.

Thanks, I've updated the cg-commit version. Note that the empty GIT_AUTHOR_NAME problem seems to exist in git-commit as well.

-- 
				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
Junio C Hamano· Feb 7, 2006, 03:03 UTC · re: Petr Baudis · lore

Re: [Cogito] Various bugs

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)
Linus Torvalds· Feb 7, 2006, 15:53 UTC · re: Junio C Hamano · lore

Re: [Cogito] Various bugs

On Mon, 6 Feb 2006, Junio C Hamano wrote:
Show 13 quoted lines
> 
> 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.

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
Petr Baudis· Feb 7, 2006, 16:49 UTC · re: Linus Torvalds · lore

Re: [Cogito] Various bugs

Dear diary, on Tue, Feb 07, 2006 at 04:53:57PM CET, I got a letter where Linus Torvalds <torvalds@osdl.org> said that...

Show 16 quoted lines
> 
> 
> 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  <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.

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
Linus Torvalds· Feb 7, 2006, 16:56 UTC · re: Petr Baudis · lore

Re: [Cogito] Various bugs

On Tue, 7 Feb 2006, Petr Baudis wrote:
Show 9 quoted lines
> 
> > 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
Junio C Hamano· Feb 7, 2006, 20:49 UTC · re: Linus Torvalds · lore

Re: [Cogito] Various bugs

Linus Torvalds <torvalds@osdl.org> writes:
Show 6 quoted lines
> 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).
I am inclined to agree.  Something like this?

This would also make 'git-var GIT_COMMITTER_IDENT' to barf, which I think is a good thing.

---
diff --git a/ident.c b/ident.c
index 0461b8b..23b8cfc 100644
--- a/ident.c
+++ b/ident.c
@@ -167,6 +167,11 @@ static const char *get_ident(const char 
 		name = git_default_name;
 	if (!email)
 		email = git_default_email;
+
+	if (!*name || !*email)
+		die("empty ident %s <%s> not allowed",
+		    name, email);
+
 	strcpy(date, git_default_date);
 	if (date_str)
 		parse_date(date_str, date, sizeof(date));
Jonas Fonseca· Feb 7, 2006, 13:55 UTC · re: Petr Baudis · lore

Re: [Cogito] Various bugs

Petr Baudis <pasky@suse.cz> wrote Tue, Feb 07, 2006:
Show 12 quoted lines
> Dear diary, on Tue, Jan 31, 2006 at 05:13:18AM CET, I got a letter
> where Jonas Fonseca <fonseca@diku.dk> said that...
> > A few Cogito bugs I found yesterday.
> > 
> >  - cg-fetch between local repos fails when the cloned branch URL does
> >    not point to a .git directory and a needed object from the repository
> >    being cloned is packed. git-local-fetch expects a .git directory.
> 
> Can't reproduce and I don't buy it. The very first line of local fetch
> handler is
> 
> 	[ -d "$uri/.git" ] && uri="$uri/.git"

I cannot reproduce it either and my strace file is long gone thanks to cg-clean. Come to think of it it might have been caused by a pack file not following the more strict name rules which recently was introduced in GIT.

Show 14 quoted lines
> >  - cg-status reports a deleted file both as deleted and as unknown:
> > 
> > 	fonseca@antimatter:~/src/elinks/0.12 > git --version
> > 	git version 1.1.6.g1506
> > 	fonseca@antimatter:~/src/elinks/0.12 > cg --version
> > 	cogito-0.17pre.GIT (d3aa9a2b3375e36c774ea477492db76baa1db03e)
> > 	fonseca@antimatter:~/src/elinks/0.12 > cg rm AUTHORS
> > 	Removing file AUTHORS
> > 	fonseca@antimatter:~/src/elinks/0.12 > cg status | grep AUTHORS
> > 	? AUTHORS
> > 	D AUTHORS
> 
> This is fine, I'd say. The file was not deleted from the tree, either do
> that manually by rm or say cg-rm -f.

Yes, I guess you are right, this is a special case. But I think it needs to be noted that this is 'normal'. Something like this vague patch signed-off-by me.

diff --git a/cg-status b/cg-status
index 6abc52f..d38c61f 100755
--- a/cg-status
+++ b/cg-status
@@ -21,12 +21,12 @@
 # D::
 #	'<file>' has been deleted.
 # !::
-#	'<file>' is gone from your working copy but not deleted by cg-rm.
+#	'<file>' is gone from your working copy but not deleted by `cg-rm`.
 # M::
 #	'<file>' has been touched or modified.
 # m::
 #	'<file>' has been touched or modified, but will not be automatically
-#	committed the next time you call cg-commit. This is used during a
+#	committed the next time you call `cg-commit`. This is used during a
 #	merge to mark files which contained local changes before the merge.
 #
 # OPTIONS
@@ -55,6 +55,14 @@
 #	Path to the directory to use as the base for the working tree
 #	file list (instead of the current directory).
 #
+# NOTES
+# -----
+# If a file has been removed with `cg-rm` without using the `-f` option
+# to remove it physically from the tree it will be reported as both being
+# deleted and unknown. The reason for this is that the file is internally
+# marked as deleted and thus also untracked. After next commit it will only
+# be reported as being untracked.
+#
 # FILES
 # -----
 # $GIT_DIR/info/exclude::
-- 
Jonas Fonseca

← back to recent threads