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

Re: [PATCH] Write index file on any checkout of files

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2008, 20:25 UTC
Message-ID
<7vfxvcj0b7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LNX.1.00.0802281058190.19665@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> We need to rewrite the index file when we check out files, even if we
> haven't modified the blob info by reading from another tree, so that
> we get the stat cache to include the fact that we just modified the
> file so it doesn't need to be refreshed.
Thanks, Alexandre, for spotting.
Show 19 quoted lines
> -static int checkout_paths(const char **pathspec)
> +static int checkout_paths(const char **pathspec, int newfd, struct lock_file *lock_file)
>  {
> ...
> @@ -554,11 +549,14 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>  			}
>  		}
>  
> +		int newfd;
> +		struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
> +		newfd = hold_locked_index(lock_file, 1);
> +		read_cache();
> +
>  		if (source_tree)
>  			read_tree_some(source_tree, pathspec);
> -		else
> -			read_cache();
> -		return checkout_paths(pathspec);
> +		return checkout_paths(pathspec, newfd, lock_file);

Aside from decl-after-statement, I suspect that at this point these all should go to checkout_paths() function itself, that takes pathspec and source_tree (which could be NULL), but that is only "logical code organization" issue. Thanks for fixing.

I however would have liked if this were caught while the topic was still cooking in 'next'.

There was a process failure somewhere, which makes me worry more than just this single bug that escaped to 'master'. Alex Riesen's segv fix in another thread makes it double X-<.

Previous: Daniel BarkalowNext: Daniel Barkalow
Message 6 of 8 in “git-checkout regression?”
  1. Alexandre JulliardFeb 28, 2008
  2. Daniel BarkalowFeb 28, 2008
  3. Write index file on any checkout of filesDaniel Barkalow, Feb 28, 2008
  4. Alexandre JulliardFeb 28, 2008
  5. Daniel BarkalowFeb 28, 2008
  6. Junio C HamanoFeb 28, 2008
  7. Daniel BarkalowFeb 28, 2008
  8. Junio C HamanoFeb 28, 2008

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.