From: Junio C Hamano <gitster@pobox.com>
To: Derrick Stolee <stolee@gmail.com>
Cc: Ilia via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Ilia <ki.stfu@gmail.com>
Subject: Re: [PATCH] fsmonitor: check the untracked cache after a trivial response
Date: Thu, 05 Nov 2026 10:24:03 -0800 [thread overview]
Message-ID: <xmqqld77uofw.fsf@gitster.g> (raw)
In-Reply-To: <c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com> (Derrick Stolee's message of "Thu, 5 Nov 2026 10:01:52 -0500")
Derrick Stolee <stolee@gmail.com> writes:
>> + 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.
>> + /*
>> + * 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.
next prev parent reply other threads:[~2026-11-05 18:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 15:19 [PATCH] fsmonitor: check the untracked cache after a trivial response Ilia via GitGitGadget
2026-11-05 15:01 ` Derrick Stolee
2026-11-05 18:24 ` Junio C Hamano [this message]
2026-11-09 18:59 ` Ilia K
2026-11-09 19:14 ` [PATCH v2] " Ilia via GitGitGadget
2026-11-09 20:47 ` Derrick Stolee
2026-11-09 20:58 ` Junio C Hamano
2026-11-09 21:34 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqld77uofw.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=ki.stfu@gmail.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.