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

Re: [PATCH] fsmonitor: check the untracked cache after a trivial response

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 5, 2026, 18:24 UTC
Message-ID
<xmqqld77uofw.fsf@gitster.g>
In-Reply-To
<c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com>
Derrick Stolee <stolee@gmail.com> writes:
Show 17 quoted lines
>> +	for (i = 0; i < ucd->dirs_nr; i++) {
>> +		/* not written to the index, see write_one_dir() */
>> +		if (!ucd->dirs[i]->recurse)
>> +			continue;
>> +		strbuf_addch(path, '/');
>> +		strbuf_addstr(path, ucd->dirs[i]->name);
>> +		nr_invalidated += invalidate_stale_dirs(uc, ucd->dirs[i],
>> +							istate, path);
>
> I'm conditioned to worry about recursive calls without depth limits, but
> I suppose that we are limited by the untracked cache data structure itself,
> which was presumably created recursively without hitting stack limits.
>
> We could make this iterative using a stack-based data structure, but that
> would be more complicated than this is worth, probably. These are not used
> in server environments and the .git/index file shouldn't be considered
> "unsafe" or else we have bigger safety problems.
Good reasoning.  Thanks for spelling it out.
Show 12 quoted lines
>> +	/*
>> +	 * The index is also read and written by commands that do not
>> +	 * run in the top-level directory of the worktree.
>> +	 */
>> +	worktree = repo_get_work_tree(istate->repo);
>> +	if (!worktree)
>> +		return 0;
>
> I wonder if this is the right response if we fail to get a worktree. Maybe
> we should invalidate the entire untracked cache in this case, along with a
> warning that we couldn't evaluate the worktree? Or should we return -1 to
> signal an error?

It probably is safer to invalidate and continue. If there is truly not a worktree, untracked cache entries do not matter ;-)

Thanks for a review.
Previous: Derrick StoleeNext: Ilia K
Message 3 of 8 in “fsmonitor: check the untracked cache after a trivial response”
  1. fsmonitor: check the untracked cache after a trivial responseIlia via GitGitGadget, Oct 4, 2026
  2. Derrick StoleeNov 5, 2026
  3. Junio C HamanoNov 5, 2026
  4. Ilia KNov 9, 2026
  5. fsmonitor: check the untracked cache after a trivial responseIlia via GitGitGadget, Nov 9, 2026
  6. Derrick StoleeNov 9, 2026
  7. Junio C HamanoNov 9, 2026
  8. Junio C HamanoNov 9, 2026

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.