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

Re: [PATCH 1/3] Add read_cache_from() and discard_cache()

From
Junio C Hamano <junkio@cox.net>
Date
Jun 30, 2006, 16:44 UTC
Message-ID
<7v3bdmk2zj.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0606301643150.29667@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 14 quoted lines
> +int discard_cache()
> +{
> +	int ret;
> +	
> +	if (cache_mmap == NULL)
> +		return 0;
> +	ret = munmap(cache_mmap, cache_mmap_size);
> +	cache_mmap = NULL;
> +	cache_mmap_size = 0;
> +	active_nr = active_cache_changed = 0;
> +	/* no need to throw away allocated active_cache */
> +	return ret;
> +}
> +

I haven't been following the details of the patches in this thread while they are being cooked actively, but two things to look out for are:

 - I am guessing you run discard_cache() because you want to
   read in a new cache (or start from a clean slate).  I am not
   sure what you are doing with the old cache tree data
   structure.  If you are starting from a clean slate
   (i.e. there is no read_cache_from() after you call
   discard_cache), you would probably need to discard the old
   cache tree; otherwise your next write-tree may produce an
   incorrect index file.  If you keep the old one and later
   swap it in, the problem might be even more severe.
 - index_timestamp is left as the old value in this patch when
   you switch cache using read_cache_from() directly.  I have a
   suspicion you may be bitten by "Racy Git" problem, especially
   because the operations are supposed to happen quickly thanks
   to the effort of you two ;-) increasing the risks that the
   file timestamp of the working tree file and the cached entry
   match.
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 8 of 16 in “save another call to git-update-index”
  1. 4/4 save another call to git-update-indexAlex Riesen, Jun 30, 2006
  2. Johannes SchindelinJun 30, 2006
  3. Alex RiesenJun 30, 2006
  4. Johannes SchindelinJun 30, 2006
  5. Alex RiesenJun 30, 2006
  6. Johannes SchindelinJun 30, 2006
  7. 1/3 Add read_cache_from() and discard_cache()Johannes Schindelin, Jun 30, 2006
  8. Junio C HamanoJun 30, 2006
  9. Johannes SchindelinJul 1, 2006
  10. Junio C HamanoJul 1, 2006
  11. Johannes SchindelinJul 2, 2006
  12. Junio C HamanoJul 3, 2006
  13. Johannes SchindelinJul 4, 2006
  14. Junio C HamanoJul 4, 2006
  15. 2/3 Make refresh_cache_entry() publicJohannes Schindelin, Jun 30, 2006
  16. 3/3 merge-recursive: avoid the pipe to update-indexJohannes Schindelin, Jun 30, 2006

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.