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

Re: checkout-cache -f: a better way?

From
Linus Torvalds <torvalds@osdl.org>
Date
May 20, 2005, 23:33 UTC
Message-ID
<Pine.LNX.4.58.0505201626560.2206@ppc970.osdl.org>
In-Reply-To
<428E5102.60003@pobox.com>
On Fri, 20 May 2005, Jeff Garzik wrote:
> 
> Problem is, 'git-checkout-cache -q -f -a' really pounds the disk, and 
> takes quite a while.

No. "git" is perfect, and "git-checkout-cache -f" already does exactly what you want.

> Is there any way to avoid -f, while ensuring that the working directory 
> truly represents the new branch?

You don't need to avoid -f, it already has the logic to avoid writing files that are already up-to-date.

HOWEVER, your script is broken:
	git-read-tree $(cat .git/HEAD) && \
	        git-checkout-cache -q -f -a && \
	        git-update-cache --refresh

you need to use the "-m" switch to git-read-tree to tell it to merge the index information from your previous tree with the new one.

Also, don't do the "$(cat .git/HEAD)" thing any more, since modern git does this so much more nicely, and allows you to use your branch names directly.

Finally, use the new "-u" flag to git-checkout-cache, which will update the cache as it goes along.

In other words, those lines in your script should look like this:
	git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
and you'll be a lot happier.
			Linus
Previous: Jeff GarzikNext: Linus Torvalds
Message 8 of 11 in “checkout-cache -f: a better way?”
  1. Jeff GarzikMay 20, 2005
  2. Junio C HamanoMay 20, 2005
  3. Jeff GarzikMay 20, 2005
  4. Junio C HamanoMay 20, 2005
  5. Jeff GarzikMay 20, 2005
  6. Linus TorvaldsMay 21, 2005
  7. Jeff GarzikMay 21, 2005
  8. Linus TorvaldsMay 20, 2005
  9. Linus TorvaldsMay 20, 2005
  10. Jeff GarzikMay 20, 2005
  11. Junio C HamanoMay 20, 2005

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.