Re: [PATCH] init: show "Reinit" message even in an (existing) empty repository
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 25, 2008, 09:55 UTC
- Message-ID
- <alpine.LSU.1.00.0803251052310.10660@wbgn129.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <7viqzbmf2h.fsf@gitster.siamese.dyndns.org>
Hi,
On Tue, 25 Mar 2008, Junio C Hamano wrote:
Show 16 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > diff --git a/builtin-init-db.c b/builtin-init-db.c
> > index 1975910..ceb4727 100644
> > --- a/builtin-init-db.c
> > +++ b/builtin-init-db.c
> > @@ -168,10 +168,9 @@ static int create_default_files(const char *git_dir, const char *template_path)
> > {
> > unsigned len = strlen(git_dir);
> > static char path[PATH_MAX];
> > - unsigned char sha1[20];
> > struct stat st1;
> > char repo_version_string[10];
> > int reinit;
>
> Here I saw a hand-edit, but that is less of a problem...Heh, yes. I originally set reinit = 0, and thought I was clever by patch editing. But I have less experience with that than necessary, and then, I am not as clever as I thought, either... ;-)
Show 12 quoted lines
> > int filemode;
> >
> > if (len > sizeof(path)-50)
> > @@ -220,7 +219,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
> > * branch, if it does not exist yet.
> > */
> > strcpy(path + len, "HEAD");
> > - reinit = !read_ref("HEAD", sha1);
> > + reinit = !access(path, R_OK);
>
> If this is a HEAD (or .git/HEAD) that is a dangling symlink (we do still
> support them, don't we?) wouldn't this access fail?Right. I already saw your commit, and while I would have to think hard if it is implementing the correct logic (what does access() do with a dangling symlink? Is || correct?), I just trust you.
Although I have to admit that having the authorship of this commit is giving me more credit than I deserve.
Thanks, Dscho