From: Junio C Hamano Date: Tue, 25 Aug 2009 02:11:43 GMT Subject: Re: Possible regression: overwriting untracked files in a fresh repo Message-ID: <7vk50sve00.fsf@alter.siamese.dyndns.org> In-Reply-To: <20090825013601.GA3515@coredump.intra.peff.net> Jeff King writes: > diff --git a/builtin-checkout.c b/builtin-checkout.c > index 8a9a474..1f2f84d 100644 > --- a/builtin-checkout.c > +++ b/builtin-checkout.c > @@ -402,7 +402,9 @@ static int merge_working_tree(struct checkout_opts *opts, > topts.dir = xcalloc(1, sizeof(*topts.dir)); > topts.dir->flags |= DIR_SHOW_IGNORED; > topts.dir->exclude_per_dir = ".gitignore"; > - tree = parse_tree_indirect(old->commit->object.sha1); > + tree = parse_tree_indirect(old->commit ? > + old->commit->object.sha1 : > + (unsigned char *)EMPTY_TREE_SHA1_BIN); > init_tree_desc(&trees[0], tree->buffer, tree->size); > tree = parse_tree_indirect(new->commit->object.sha1); > init_tree_desc(&trees[1], tree->buffer, tree->size); This looks a lot saner; I like it. Care to wrap it up with the usual supporting material? I think the "You appear to be" can just go, but I do not feel very strongly either way.