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

Re: [PATCH v4 3/4] cache-tree: fix writing cache-tree when CE_REMOVE is present

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 16, 2012, 10:15 UTC
Message-ID
<CACsJy8DgwQ2jn=tPpE8f22JNE1Vih86d=Xf1iGBznLcwMukd+w@mail.gmail.com>
In-Reply-To
<7vk3siqx8b.fsf@alter.siamese.dyndns.org>
On Sun, Dec 16, 2012 at 2:20 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> entry_count is used in update_one() for two purposes:
>>
>> 1. to skip through the number of processed entries in in-memory index
>> 2. to record the number of entries this cache-tree covers on disk
>>
>> Unfortunately when CE_REMOVE is present these numbers are not the same
>> because CE_REMOVE entries are automatically removed before writing to
>> disk but entry_count is not adjusted and still counts CE_REMOVE
>> entries.
>
> Nicely explained.  I wonder if we can also add a piece of test to
> the patch 4/4 to demonstrate the issue with CE_REMOVE entries,
> though.

A hand crafted one, maybe. I did not attempt to recreate it with git commands (and I don't think we update cache-tree after unpack_trees). So I wrote something like this instead:

int main(int ac, char **av)
{
	unsigned char sha1[20];
	setup_git_directory();
	read_cache();
	active_cache[1]->ce_flags |= CE_REMOVE;
	write_cache_as_tree(sha1, 0, NULL);
	return 0;
}

I can polish it a bit and write new tests based on it and test-dump-cache-tree if you want.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “nd/invalidate-i-t-a-cache-tree”
  1. 0/4 nd/invalidate-i-t-a-cache-treeNguyễn Thái Ngọc Duy, Dec 16, 2012
  2. 1/4 cache-tree: remove dead i-t-a code in verify_cache()Nguyễn Thái Ngọc Duy, Dec 16, 2012
  3. 2/4 cache-tree: replace "for" loops in update_one with "while" loopsNguyễn Thái Ngọc Duy, Dec 16, 2012
  4. 3/4 cache-tree: fix writing cache-tree when CE_REMOVE is presentNguyễn Thái Ngọc Duy, Dec 16, 2012
  5. Junio C HamanoDec 16, 2012
  6. Nguyen Thai Ngoc DuyDec 16, 2012
  7. Junio C HamanoDec 16, 2012
  8. 4/4 cache-tree: invalidate i-t-a paths after generating treesNguyễn Thái Ngọc Duy, Dec 16, 2012

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.