git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Possible regression: overwriting untracked files in a fresh repo

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2009, 02:11 UTC
Message-ID
<7vk50sve00.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090825013601.GA3515@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 15 quoted lines
> 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.

Previous: Jeff KingNext: Jeff King
Message 7 of 9 in “Possible regression: overwriting untracked files in a fresh repo”
  1. Johannes SchindelinAug 24, 2009
  2. Jeff KingAug 24, 2009
  3. Junio C HamanoAug 24, 2009
  4. Junio C HamanoAug 24, 2009
  5. Jeff KingAug 25, 2009
  6. Jeff KingAug 25, 2009
  7. Junio C HamanoAug 25, 2009
  8. Jeff KingAug 25, 2009
  9. Johannes SchindelinAug 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.