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

[PATCH 0/1] Preserve the untracked cache across checkout, reset --hard, etc

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 8, 2017, 09:41 UTC
Message-ID
<cover.1494236457.git.johannes.schindelin@gmx.de>

I recently sent out a request for assistance, after noticing that the untracked cache is simply thrown away after operations such as `git checkout` or `git reset --hard`:

http://public-inbox.org/git/alpine.DEB.2.20.1705031202470.3480@virtualbox/

Duy responded with some high-level reasoning that it should be possible to simply reuse the untracked cache data structure in the new index, as he had a gut feeling that "we do invalidation right".

I did not have time to back that up by a thorough analysis of the code, but it turns out that it is unnecessary: Ben Peart pointed me to a patch of Dave Turner's that was submitted as part of the watchman series, addressing the very issue about which I was concerned.

And I trust Dave to have validated the idea that the untracked cache invalidation "is done right" even when we simply move the pointer to a different index_state struct than originally.

Seeing as the untracked cache being dropped unceremoniously when it should not be dropped, in a surprising number of operations, I think it is a sensible change, and important, too, and independent enough from the watchman patches to merit being separated out and applied pretty soon.

So what I did was simply to drop the two lines from this patch that referred to index_state fields added by Dave's watchman patch series.

Please do not mistake this for a sign that I am disinterested in watchman support, far from it... stay tuned ;-)

Oh, and I adjusted Dave's email address. Dave, is that okay?

As we are in a feature freeze phase, I was debating whether to send out this patch now or later.

Having thought about it for quite a bit, I am now convinced that this patch fixes a bug in the untracked cache feature that is so critical as to render it useless: if you

- have to switch between branches frequently, or
- rebase frequently (which calls `git reset --hard`), or
- stash frequently (which calls `git reset --hard`),

it is as if you had not enabled the untracked cache at all. Even worse, Git will do a ton of work to recreate the untracked cache and to store it as an index extension, *just* to throw the untracked away in the end.

David Turner (1):
  unpack-trees: preserve index extensions
 cache.h                           |  1 +
 read-cache.c                      |  6 ++++++
 t/t7063-status-untracked-cache.sh | 22 ++++++++++++++++++++++
 unpack-trees.c                    |  1 +
 4 files changed, 30 insertions(+)
base-commit: 4fa66c85f11bc5a541462ca5ae3246aa0ce02e74
Published-As: https://github.com/dscho/git/releases/tag/preserve-untracked-cache-v1
Fetch-It-Via: git fetch https://github.com/dscho/git preserve-untracked-cache-v1
-- 
2.12.2.windows.2.800.gede8f145e06
Next: Johannes Schindelin
Message 1 of 8 in “Preserve the untracked cache across checkout, reset --hard, etc”
  1. 0/1 Preserve the untracked cache across checkout, reset --hard, etcJohannes Schindelin, May 8, 2017
  2. 1/1 unpack-trees: preserve index extensionsJohannes Schindelin, May 8, 2017
  3. Christian CouderMay 8, 2017
  4. David TurnerMay 8, 2017
  5. Junio C HamanoMay 9, 2017
  6. Ben PeartMay 9, 2017
  7. Ben PeartMay 18, 2017
  8. David TurnerMay 18, 2017

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.