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

Re: [PATCH v2] index-format.txt: be more liberal on what can represent invalid cache tree

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 13, 2012, 01:55 UTC
Message-ID
<7v8v921zt6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1355361287-10875-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>  How would that work with existing versions? If you write -2 in
>  cache-tree, the next time 1.8.0 updates cache tree it writes -1 back.
>  That loses whatever information you attach to -2. A new cache-tree
>  extension is probably better.
You can easily imagine a definition like this:
 - If non-negative, the entry is valid and it is the number of index
   entries that are covered by this subtree;
 - If -1, the cached-tree does not know the object name of the tree
   object, and nothing else is known. The caller needs to walk the
   index to skip the entries that could have been covered by this
   subtree, if the cached tree information were valid;
 - If less than -1, the cached-tree does not know the object name of
   the tree object, but we know the number of index entries that are
   covered by this subtree.  The caller, instead of walking the index,
   can subtract the count from -1 and skip that many entries to find
   the index entry after the part that is inside this directory.

Newer Git may write -201 and newer Git may be able to take advantage of the new information encoded there, saving 200 calls to prefixcmp(), while given the same index, older Git will operate just as correctly as before. An older Git may write that part of the cache-tree back with -1, defeating the optimization when a newer Git reads it back, but by definition the older Git does not know what to write to help that optimization that did not exist when it was done, and writing -1 will not confuse the newer Git.

Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 4 of 5 in “index-format.txt: be more liberal on what can represent invalid cache tree”
  1. index-format.txt: be more liberal on what can represent invalid cache treeNguyễn Thái Ngọc Duy, Dec 12, 2012
  2. Junio C HamanoDec 12, 2012
  3. index-format.txt: be more liberal on what can represent invalid cache treeNguyễn Thái Ngọc Duy, Dec 13, 2012
  4. Junio C HamanoDec 13, 2012
  5. Junio C HamanoDec 13, 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.