{"thread":{"id":"1844","subject":"Garbage in .git directories???","startedAt":"2005-09-18T02:41:30Z","lastAt":"2005-09-20T03:37:32Z","messageCount":22,"participants":["Dmitry Torokhov","Linus Torvalds","Junio C Hamano","H. Peter Anvin","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"8770","messageId":"200509172141.31591.dtor_core@ameritech.net","threadId":"1844","inReplyTo":null,"subject":"Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-18T02:41:30Z","receivedAt":"2005-09-18T02:41:30Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"Hi,\n\nI just did:\n\ngit clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git work\n\nand it seems there is some garbage in .git directory:\n\n[dtor@anvil work]$ ls -la .git/\ntotal 40\ndrwxrwxr-x    9 dtor dtor 4096 Sep 17 21:17 .\ndrwxrwxr-x    3 dtor dtor 4096 Sep 17 21:17 ..\ndrwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 branches\n-rw-rw-r--    1 dtor dtor   58 Sep 17 21:17 description\nlrwxrwxrwx    1 dtor dtor   17 Sep 17 21:17 HEAD -> refs/heads/master\ndrwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 hooks\ndrwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 info\ndrwxr-xr-x  260 dtor dtor 4096 Sep 17 17:41 objects\ndrwxrwxr-x    4 dtor dtor 4096 May  1 19:15 refs\ndrwxrwxr-x    2 dtor dtor 4096 Sep 17 21:28 remotes\ndrwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?���?E ???#V?C??ſl??E#V?C??;H\n                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe similar garbage(?) shows when I clone git's repository.\n\nIs this expected?\n\n-- \nDmitry\n"},{"id":"8783","messageId":"Pine.LNX.4.58.0509181009160.26803@g5.osdl.org","threadId":"1844","inReplyTo":"200509172141.31591.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-18T17:10:35Z","receivedAt":"2005-09-18T17:10:35Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 17 Sep 2005, Dmitry Torokhov wrote:\n> \n> git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git work\n> \n> and it seems there is some garbage in .git directory:\n>\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?���?E ???#V?C??ſl??E#V?C??;H\n>                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n> The similar garbage(?) shows when I clone git's repository.\n> \n> Is this expected?\n\nAbsolutely not. And I don't see it when I try. What filesystem are you \nrunning this on? Looks like something did a \"mkdir()\" with an \nuninitialized pointer, but I don't see how that would happen.\n\n\t\tLinus\n"},{"id":"8793","messageId":"200509181254.14646.dtor_core@ameritech.net","threadId":"1844","inReplyTo":"Pine.LNX.4.58.0509181009160.26803@g5.osdl.org","subject":"Re: Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-18T17:54:13Z","receivedAt":"2005-09-18T17:54:13Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"On Sunday 18 September 2005 12:10, Linus Torvalds wrote:\n> \n> On Sat, 17 Sep 2005, Dmitry Torokhov wrote:\n> > \n> > git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git work\n> > \n> > and it seems there is some garbage in .git directory:\n> >\n> > drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?���?E ???#V?C??ſl??E#V?C??;H\n> >                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n> > The similar garbage(?) shows when I clone git's repository.\n> > \n> > Is this expected?\n> \n> Absolutely not. And I don't see it when I try. What filesystem are you \n> running this on? Looks like something did a \"mkdir()\" with an \n> uninitialized pointer, but I don't see how that would happen.\n> \n> \t\tLinus\n> \n\nIt is ext3 on 2.6.12-rc6.\n\n-- \nDmitry\n"},{"id":"8828","messageId":"200509182333.58227.dtor_core@ameritech.net","threadId":"1844","inReplyTo":"200509181254.14646.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-19T04:33:57Z","receivedAt":"2005-09-19T04:33:57Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"On Sunday 18 September 2005 12:54, Dmitry Torokhov wrote:\n> On Sunday 18 September 2005 12:10, Linus Torvalds wrote:\n> > \n> > On Sat, 17 Sep 2005, Dmitry Torokhov wrote:\n> > > \n> > > git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git work\n> > > \n> > > and it seems there is some garbage in .git directory:\n> > >\n> > > drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?���?E ???#V?C??ſl??E#V?C??;H\n> > >                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n> > > The similar garbage(?) shows when I clone git's repository.\n> > > \n> > > Is this expected?\n> > \n> > Absolutely not. And I don't see it when I try. What filesystem are you \n> > running this on? Looks like something did a \"mkdir()\" with an \n> > uninitialized pointer, but I don't see how that would happen.\n> > \n> > \t\tLinus\n> > \n> \n> It is ext3 on 2.6.12-rc6.\n> \n\nCouple more points - just using rsync to get the data (without using git)\ndoes not not produce that wierd directory, only got clone does.\n\nBtw, after doing a pull from git repository git cone now produces the\nfollowing:\n\nsent 403 bytes  received 2164 bytes  570.44 bytes/sec\ntotal size is 533  speedup is 0.21\nrsync: link_stat \"/scm/git/git.git/objects/info/alternates\" (in pub) failed: No such file or directory (2)\nrsync error: some files could not be transferred (code 23) at main.c(1173)\n\n\n-- \nDmitry\n"},{"id":"8832","messageId":"7vzmq9y6mu.fsf@assigned-by-dhcp.cox.net","threadId":"1844","inReplyTo":"200509182333.58227.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-19T05:21:45Z","receivedAt":"2005-09-19T05:21:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Torokhov <dtor_core@ameritech.net> writes:\n\n> Btw, after doing a pull from git repository git cone now produces the\n> following:\n>\n> sent 403 bytes  received 2164 bytes  570.44 bytes/sec\n> total size is 533  speedup is 0.21\n> rsync: link_stat \"/scm/git/git.git/objects/info/alternates\" (in pub) failed: No such file or directory (2)\n> rsync error: some files could not be transferred (code 23) at main.c(1173)\n\nThe garbage directory does ont reproduce for me, but I know what\nthis is.  It is an harmless error message -- I'll hide it in the\nnext update.  It is checking to see if the remote repository\nuses alternates just in case -- since git.git does not use it,\nit just does not find one (and needlessly complains).\n"},{"id":"8867","messageId":"Pine.LNX.4.58.0509190747210.9106@g5.osdl.org","threadId":"1844","inReplyTo":"200509182333.58227.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-19T14:51:55Z","receivedAt":"2005-09-19T14:51:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 18 Sep 2005, Dmitry Torokhov wrote:\n> \n> Couple more points - just using rsync to get the data (without using git)\n> does not not produce that wierd directory, only got clone does.\n\nDoes a plain \"git-init-db\" in a newly created empty directory do the same?  \nThere was a bug (a long time ago)  that created garbage instead of the\ntemplate files, I think.\n\nAlso, is there something inside of the garbage subdirectory?\n\n> Btw, after doing a pull from git repository git cone now produces the\n> following:\n\nIgnore that one, looks like a silly error. Unrelated.\n\n\t\tLinus\n"},{"id":"8869","messageId":"d120d50005091908001e8339fd@mail.gmail.com","threadId":"1844","inReplyTo":"Pine.LNX.4.58.0509190747210.9106@g5.osdl.org","subject":"Re: Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dmitry.torokhov@gmail.com","sentAt":"2005-09-19T15:00:29Z","receivedAt":"2005-09-19T15:00:29Z","isPatch":false,"sender":{"key":"dmitry.torokhov@gmail.com","avatar":null},"body":"On 9/19/05, Linus Torvalds <torvalds@osdl.org> wrote:\n> \n> \n> On Sun, 18 Sep 2005, Dmitry Torokhov wrote:\n> >\n> > Couple more points - just using rsync to get the data (without using git)\n> > does not not produce that wierd directory, only got clone does.\n> \n> Does a plain \"git-init-db\" in a newly created empty directory do the same?\n> There was a bug (a long time ago)  that created garbage instead of the\n> template files, I think.\n> \n\nWill test once get home...\n\n> Also, is there something inside of the garbage subdirectory?\n> \n\nNo, they are always empty.\n\n-- \nDmitry\n"},{"id":"8892","messageId":"432F0D1B.60303@zytor.com","threadId":"1844","inReplyTo":"200509172141.31591.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-19T19:10:19Z","receivedAt":"2005-09-19T19:10:19Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Dmitry Torokhov wrote:\n> \n> git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git work\n> \n> and it seems there is some garbage in .git directory:\n> \n> [dtor@anvil work]$ ls -la .git/\n> total 40\n> drwxrwxr-x    9 dtor dtor 4096 Sep 17 21:17 .\n> drwxrwxr-x    3 dtor dtor 4096 Sep 17 21:17 ..\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 branches\n> -rw-rw-r--    1 dtor dtor   58 Sep 17 21:17 description\n> lrwxrwxrwx    1 dtor dtor   17 Sep 17 21:17 HEAD -> refs/heads/master\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 hooks\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 info\n> drwxr-xr-x  260 dtor dtor 4096 Sep 17 17:41 objects\n> drwxrwxr-x    4 dtor dtor 4096 May  1 19:15 refs\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:28 remotes\n> drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?�?E ???#V?C??ſl??E#V?C??;H\n>                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n> \n> The similar garbage(?) shows when I clone git's repository.\n> \n\nFWIW, using cg-clone (using git-core 0.99.6 and cogito 0.14.1) I keep \nfinding a directory in .git which consists of a single DEL character (\\177).\n\n\t-hpa\n"},{"id":"8896","messageId":"20050919194445.GD18320@pasky.or.cz","threadId":"1844","inReplyTo":"432F0D1B.60303@zytor.com","subject":"Re: Garbage in .git directories???","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-19T19:44:45Z","receivedAt":"2005-09-19T19:44:45Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Mon, Sep 19, 2005 at 09:10:19PM CEST, I got a letter\nwhere \"H. Peter Anvin\" <hpa@zytor.com> told me that...\n> Dmitry Torokhov wrote:\n> >\n> >git clone \n> >rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git \n> >work\n> >\n> >and it seems there is some garbage in .git directory:\n> >\n> >[dtor@anvil work]$ ls -la .git/\n> >total 40\n> >drwxrwxr-x    9 dtor dtor 4096 Sep 17 21:17 .\n> >drwxrwxr-x    3 dtor dtor 4096 Sep 17 21:17 ..\n> >drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 branches\n> >-rw-rw-r--    1 dtor dtor   58 Sep 17 21:17 description\n> >lrwxrwxrwx    1 dtor dtor   17 Sep 17 21:17 HEAD -> refs/heads/master\n> >drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 hooks\n> >drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 info\n> >drwxr-xr-x  260 dtor dtor 4096 Sep 17 17:41 objects\n> >drwxrwxr-x    4 dtor dtor 4096 May  1 19:15 refs\n> >drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:28 remotes\n> >drwxrwxr-x    2 dtor dtor 4096 Sep 17 21:17 V?Cl?????E \n> >???#V?C????l??E#V?C??;H\n> >                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n> >\n> >The similar garbage(?) shows when I clone git's repository.\n> >\n> \n> FWIW, using cg-clone (using git-core 0.99.6 and cogito 0.14.1) I keep \n> finding a directory in .git which consists of a single DEL character (\\177).\n\nDoes cg-init produce it too? It really seems that this has to be a bug\nin git-init-db. If that is the case, could you try temporarily renaming\nthe templates directory?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nIf you want the holes in your knowledge showing up try teaching\nsomeone.  -- Alan Cox\n"},{"id":"8918","messageId":"432F46BE.5000406@zytor.com","threadId":"1844","inReplyTo":"20050919194445.GD18320@pasky.or.cz","subject":"Re: Garbage in .git directories???","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-19T23:16:14Z","receivedAt":"2005-09-19T23:16:14Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Petr Baudis wrote:\n>>\n>>FWIW, using cg-clone (using git-core 0.99.6 and cogito 0.14.1) I keep \n>>finding a directory in .git which consists of a single DEL character (\\177).\n> \n> Does cg-init produce it too? It really seems that this has to be a bug\n> in git-init-db. If that is the case, could you try temporarily renaming\n> the templates directory?\n\ncg-init does produce it, too.  I'm not sure what you mean with \ntemporarily renaming the templates directory?\n\n\t-hpa\n"},{"id":"8920","messageId":"20050919234030.GI18320@pasky.or.cz","threadId":"1844","inReplyTo":"432F46BE.5000406@zytor.com","subject":"Re: Garbage in .git directories???","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-19T23:40:30Z","receivedAt":"2005-09-19T23:40:30Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Sep 20, 2005 at 01:16:14AM CEST, I got a letter\nwhere \"H. Peter Anvin\" <hpa@zytor.com> told me that...\n> Petr Baudis wrote:\n> >>\n> >>FWIW, using cg-clone (using git-core 0.99.6 and cogito 0.14.1) I keep \n> >>finding a directory in .git which consists of a single DEL character \n> >>(\\177).\n> >\n> >Does cg-init produce it too? It really seems that this has to be a bug\n> >in git-init-db. If that is the case, could you try temporarily renaming\n> >the templates directory?\n> \n> cg-init does produce it, too.  I'm not sure what you mean with \n> temporarily renaming the templates directory?\n\nPreventing git-init-db to copy its stuff into your .git/ - I think the\nbug is likely somewhere there. Actually, this can be prevented by\npassing an argument to git-init-db:\n\n\tgit-init-db --template=somethingnonexisting\n\nAnother idea - try this patch:\n\ndiff --git a/init-db.c b/init-db.c\n--- a/init-db.c\n+++ b/init-db.c\n@@ -154,6 +154,7 @@ static void copy_templates(const char *g\n \t}\n \n \tmemcpy(path, git_dir, len);\n+\tpath[len] = 0;\n \tcopy_templates_1(path, len,\n \t\t\t template_path, template_len,\n \t\t\t dir);\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nVI has two modes: the one in which it beeps and the one in which\nit doesn't.\n"},{"id":"8921","messageId":"432F50BC.5000304@zytor.com","threadId":"1844","inReplyTo":"20050919234030.GI18320@pasky.or.cz","subject":"Re: Garbage in .git directories???","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-19T23:58:52Z","receivedAt":"2005-09-19T23:58:52Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Petr Baudis wrote:\n> Dear diary, on Tue, Sep 20, 2005 at 01:16:14AM CEST, I got a letter\n> \n> Another idea - try this patch:\n> \n> diff --git a/init-db.c b/init-db.c\n> --- a/init-db.c\n> +++ b/init-db.c\n> @@ -154,6 +154,7 @@ static void copy_templates(const char *g\n>  \t}\n>  \n>  \tmemcpy(path, git_dir, len);\n> +\tpath[len] = 0;\n>  \tcopy_templates_1(path, len,\n>  \t\t\t template_path, template_len,\n>  \t\t\t dir);\n> \n\nThis seems to have worked.\n\n\t-hpa\n"},{"id":"8922","messageId":"20050920000731.GJ18320@pasky.or.cz","threadId":"1844","inReplyTo":"432F50BC.5000304@zytor.com","subject":"[PATCH] Fix git-init-db creating crap directories","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-20T00:07:31Z","receivedAt":"2005-09-20T00:07:31Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Sep 20, 2005 at 01:58:52AM CEST, I got a letter\nwhere \"H. Peter Anvin\" <hpa@zytor.com> told me that...\n> Petr Baudis wrote:\n> >Dear diary, on Tue, Sep 20, 2005 at 01:16:14AM CEST, I got a letter\n> >\n> >Another idea - try this patch:\n> >\n> >diff --git a/init-db.c b/init-db.c\n> >--- a/init-db.c\n> >+++ b/init-db.c\n> >@@ -154,6 +154,7 @@ static void copy_templates(const char *g\n> > \t}\n> > \n> > \tmemcpy(path, git_dir, len);\n> >+\tpath[len] = 0;\n> > \tcopy_templates_1(path, len,\n> > \t\t\t template_path, template_len,\n> > \t\t\t dir);\n> >\n> \n> This seems to have worked.\n\nGreat. Resending a marginally better version with a cool log message and\neverything.\n\n--\n\nThe base target directory for the templates copying was initialized\nto git_dir, but git_dir[len] is not zero but / at the time we do the\ninitialization. This is not what we want for our target directory string\nsince we pass it to mkdir(), so make it zero-terminated manually.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\ncommit dbe1fe2f0d6de58bc0c9f98e6cf9573874612890\ntree 30398d409fa27e95e3e592c803f6cd5a93652234\nparent 79d2a11ec497fe940ca9a1fd8e0b9f295d39c290\nauthor Petr Baudis <pasky@suse.cz> Tue, 20 Sep 2005 01:55:53 +0200\ncommitter Petr Baudis <xpasky@machine.(none)> Tue, 20 Sep 2005 01:55:53 +0200\n\n init-db.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/init-db.c b/init-db.c\n--- a/init-db.c\n+++ b/init-db.c\n@@ -153,7 +153,8 @@ static void copy_templates(const char *g\n \t\treturn;\n \t}\n \n-\tmemcpy(path, git_dir, len);\n+\tmemcpy(path, git_dir, len-1);\n+\tpath[len] = 0;\n \tcopy_templates_1(path, len,\n \t\t\t template_path, template_len,\n \t\t\t dir);\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nVI has two modes: the one in which it beeps and the one in which\nit doesn't.\n"},{"id":"8931","messageId":"200509191909.22026.dtor_core@ameritech.net","threadId":"1844","inReplyTo":"Pine.LNX.4.58.0509190747210.9106@g5.osdl.org","subject":"Re: Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-20T00:09:21Z","receivedAt":"2005-09-20T00:09:21Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"On Monday 19 September 2005 09:51, Linus Torvalds wrote:\n> \n> On Sun, 18 Sep 2005, Dmitry Torokhov wrote:\n> > \n> > Couple more points - just using rsync to get the data (without using git)\n> > does not not produce that wierd directory, only got clone does.\n> \n> Does a plain \"git-init-db\" in a newly created empty directory do the same?  \n> There was a bug (a long time ago)  that created garbage instead of the\n> template files, I think.\n>\n\nYes, plain git-init-db produces the garbage.\n\n[dtor@anvil tst]$ git-init-db\ndefaulting to local storage area\n[dtor@anvil tst]$ ls -l .git/\ntotal 32\ndrwxrwxr-x    2 dtor dtor 4096 Sep 19 19:08 branches\n-rw-rw-r--    1 dtor dtor   58 Sep 19 19:08 description\nlrwxrwxrwx    1 dtor dtor   17 Sep 19 19:08 HEAD -> refs/heads/master\ndrwxrwxr-x    2 dtor dtor 4096 Sep 19 19:08 hooks\ndrwxrwxr-x    2 dtor dtor 4096 Sep 19 19:08 info\ndrwxrwxr-x  260 dtor dtor 4096 Sep 19 19:08 objects\ndrwxrwxr-x    4 dtor dtor 4096 Sep 19 19:08 refs\ndrwxrwxr-x    2 dtor dtor 4096 Sep 19 19:08 remotes\ndrwxrwxr-x    2 dtor dtor 4096 Sep 19 19:08 V?Cl???E ???#V?C??տl??E#V?C??;H\n[dtor@anvil tst]$ git --version\ngit version 0.99.7\n\n(Actually this is last night's pull).\n\n\n-- \nDmitry\n"},{"id":"8923","messageId":"432F5345.3020303@zytor.com","threadId":"1844","inReplyTo":"20050920000731.GJ18320@pasky.or.cz","subject":"Re: [PATCH] Fix git-init-db creating crap directories","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-20T00:09:41Z","receivedAt":"2005-09-20T00:09:41Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Petr Baudis wrote:\n> diff --git a/init-db.c b/init-db.c\n> --- a/init-db.c\n> +++ b/init-db.c\n> @@ -153,7 +153,8 @@ static void copy_templates(const char *g\n>  \t\treturn;\n>  \t}\n>  \n> -\tmemcpy(path, git_dir, len);\n> +\tmemcpy(path, git_dir, len-1);\n> +\tpath[len] = 0;\n>  \tcopy_templates_1(path, len,\n\nWrong!  You're not initializing path[len-1]!\n\n\t-hpa\n"},{"id":"8925","messageId":"20050920001949.GL18320@pasky.or.cz","threadId":"1844","inReplyTo":"432F5345.3020303@zytor.com","subject":"[PATCH] Fix git-init-db creating crap directories (zeroth try)","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-20T00:19:50Z","receivedAt":"2005-09-20T00:19:50Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Sep 20, 2005 at 02:09:41AM CEST, I got a letter\nwhere \"H. Peter Anvin\" <hpa@zytor.com> told me that...\n> Petr Baudis wrote:\n> >diff --git a/init-db.c b/init-db.c\n> >--- a/init-db.c\n> >+++ b/init-db.c\n> >@@ -153,7 +153,8 @@ static void copy_templates(const char *g\n> > \t\treturn;\n> > \t}\n> > \n> >-\tmemcpy(path, git_dir, len);\n> >+\tmemcpy(path, git_dir, len-1);\n> >+\tpath[len] = 0;\n> > \tcopy_templates_1(path, len,\n> \n> Wrong!  You're not initializing path[len-1]!\n\nOops, sorry. That's what you get when you want to make things marginally\nbetter. ;-) We indeed want to pass copy_templates_1() the trailing slash\nas well.\n\nLet's just settle with the original patch then.\n\n--\n\nThe base target directory for the templates copying was initialized\nto git_dir, but git_dir[len] is not zero but / at the time we do the\ninitialization. This is not what we want for our target directory string\nsince we pass it to mkdir(), so make it zero-terminated manually.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\ndiff --git a/init-db.c b/init-db.c\n--- a/init-db.c\n+++ b/init-db.c\n@@ -154,6 +154,7 @@ static void copy_templates(const char *g\n \t}\n \n \tmemcpy(path, git_dir, len);\n+\tpath[len] = 0;\n \tcopy_templates_1(path, len,\n \t\t\t template_path, template_len,\n \t\t\t dir);\n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nVI has two modes: the one in which it beeps and the one in which\nit doesn't.\n"},{"id":"8932","messageId":"432F5B07.2060803@zytor.com","threadId":"1844","inReplyTo":"20050920001949.GL18320@pasky.or.cz","subject":"Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-20T00:42:47Z","receivedAt":"2005-09-20T00:42:47Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Petr Baudis wrote:\n>>>\n>>>-\tmemcpy(path, git_dir, len);\n>>>+\tmemcpy(path, git_dir, len-1);\n>>>+\tpath[len] = 0;\n>>>\tcopy_templates_1(path, len,\n>>\n>>Wrong!  You're not initializing path[len-1]!\n> \n> \n> Oops, sorry. That's what you get when you want to make things marginally\n> better. ;-) We indeed want to pass copy_templates_1() the trailing slash\n> as well.\n> \n> Let's just settle with the original patch then.\n> \n\nBut if len is the index of the '/', then you're not.\n\nThink about it: the memcpy(path, git_dir, len) copies bytes 0..len-1. \nThus you need to use path[len] = 0 to terminate.\n\nIf you want to copy len-1 characters, then you need to use path[len-1] = 0.\n\n\t-hpa\n"},{"id":"8933","messageId":"Pine.LNX.4.58.0509191744550.2553@g5.osdl.org","threadId":"1844","inReplyTo":"200509191909.22026.dtor_core@ameritech.net","subject":"Re: Garbage in .git directories???","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-20T00:45:44Z","receivedAt":"2005-09-20T00:45:44Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 19 Sep 2005, Dmitry Torokhov wrote:\n>\n> Yes, plain git-init-db produces the garbage.\n\nHmm. It doesn't do it for me, but I suspect it will be obvious where it\nhappens if you send us the output from \"strace git-init-db\"\n\nThanks,\n\n\t\tLinus\n"},{"id":"8939","messageId":"20050920015154.GA25115@pasky.or.cz","threadId":"1844","inReplyTo":"432F5B07.2060803@zytor.com","subject":"Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-09-20T01:51:54Z","receivedAt":"2005-09-20T01:51:54Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Sep 20, 2005 at 02:42:47AM CEST, I got a letter\nwhere \"H. Peter Anvin\" <hpa@zytor.com> told me that...\n> Petr Baudis wrote:\n> >>>\n> >>>-\tmemcpy(path, git_dir, len);\n> >>>+\tmemcpy(path, git_dir, len-1);\n> >>>+\tpath[len] = 0;\n> >>>\tcopy_templates_1(path, len,\n> >>\n> >>Wrong!  You're not initializing path[len-1]!\n> >\n> >\n> >Oops, sorry. That's what you get when you want to make things marginally\n> >better. ;-) We indeed want to pass copy_templates_1() the trailing slash\n> >as well.\n> >\n> >Let's just settle with the original patch then.\n> >\n> \n> But if len is the index of the '/', then you're not.\n\nBut fortunately len is not the index of the '/', len-1 is. len is the length\nof the leading path fragment including the trailing slash.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nVI has two modes: the one in which it beeps and the one in which\nit doesn't.\n"},{"id":"8945","messageId":"7v1x3kebq3.fsf@assigned-by-dhcp.cox.net","threadId":"1844","inReplyTo":"20050920015154.GA25115@pasky.or.cz","subject":"Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-20T02:04:20Z","receivedAt":"2005-09-20T02:04:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>> >Oops, sorry. That's what you get when you want to make things marginally\n>> >better. ;-) We indeed want to pass copy_templates_1() the trailing slash\n>> >as well.\n\nOriginal patch from you is the right one.  Thanks.\n"},{"id":"8956","messageId":"432F81A4.10107@zytor.com","threadId":"1844","inReplyTo":"20050920015154.GA25115@pasky.or.cz","subject":"Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-20T03:27:32Z","receivedAt":"2005-09-20T03:27:32Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Petr Baudis wrote:\n>>\n>>But if len is the index of the '/', then you're not.\n> \n> But fortunately len is not the index of the '/', len-1 is. len is the length\n> of the leading path fragment including the trailing slash.\n> \n\nThen you'd need len-1 both inside the memcpy() and the assignment, of \ncourse.\n\n\t-hpa\n"},{"id":"8960","messageId":"200509192237.33042.dtor_core@ameritech.net","threadId":"1844","inReplyTo":"Pine.LNX.4.58.0509191744550.2553@g5.osdl.org","subject":"Re: Garbage in .git directories???","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-20T03:37:32Z","receivedAt":"2005-09-20T03:37:32Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"On Monday 19 September 2005 19:45, Linus Torvalds wrote:\n> \n> On Mon, 19 Sep 2005, Dmitry Torokhov wrote:\n> >\n> > Yes, plain git-init-db produces the garbage.\n> \n> Hmm. It doesn't do it for me, but I suspect it will be obvious where it\n> happens if you send us the output from \"strace git-init-db\"\n> \n\nPeter's fix for copy_templates() fixes the problem for me.\n\n-- \nDmitry\n"}]}