Re: [PATCH] Fix git-init-db creating crap directories (zeroth try)
- From
Petr Baudis <pasky@suse.cz>
- Date
- Sep 20, 2005, 01:51 UTC
- Message-ID
- <20050920015154.GA25115@pasky.or.cz>
- In-Reply-To
- <432F5B07.2060803@zytor.com>
Dear diary, on Tue, Sep 20, 2005 at 02:42:47AM CEST, I got a letter where "H. Peter Anvin" <hpa@zytor.com> told me that...
Show 18 quoted lines
> Petr Baudis wrote: > >>> > >>>- 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. > > > > But if len is the index of the '/', then you're not.
But fortunately len is not the index of the '/', len-1 is. len is the length of the leading path fragment including the trailing slash.
-- 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.