[PATCH] Fix git-init-db creating crap directories (zeroth try)
- From
Petr Baudis <pasky@suse.cz>
- Date
- Sep 20, 2005, 00:19 UTC
- Message-ID
- <20050920001949.GL18320@pasky.or.cz>
- In-Reply-To
- <432F5345.3020303@zytor.com>
Dear diary, on Tue, Sep 20, 2005 at 02:09:41AM CEST, I got a letter where "H. Peter Anvin" <hpa@zytor.com> told me that...
Show 14 quoted lines
> Petr Baudis wrote: > >diff --git a/init-db.c b/init-db.c > >--- a/init-db.c > >+++ b/init-db.c > >@@ -153,7 +153,8 @@ static void copy_templates(const char *g > > return; > > } > > > >- memcpy(path, git_dir, len); > >+ memcpy(path, git_dir, len-1); > >+ path[len] = 0; > > copy_templates_1(path, len, > > Wrong! You're not initializing path[len-1]!
Oops, sorry. That's what you get when you want to make things marginally better. ;-) We indeed want to pass copy_templates_1() the trailing slash as well.
Let's just settle with the original patch then.
--
The base target directory for the templates copying was initialized to git_dir, but git_dir[len] is not zero but / at the time we do the initialization. This is not what we want for our target directory string since we pass it to mkdir(), so make it zero-terminated manually.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
diff --git a/init-db.c b/init-db.c --- a/init-db.c +++ b/init-db.c @@ -154,6 +154,7 @@ static void copy_templates(const char *g } memcpy(path, git_dir, len); + path[len] = 0; copy_templates_1(path, len, template_path, template_len, dir);
-- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ VI has two modes: the one in which it beeps and the one in which it doesn't.