{"thread":{"id":"66460","subject":"[PATCH] fsmonitor: check the untracked cache after a trivial response","startedAt":"2026-10-04T15:19:18Z","lastAt":"2026-11-09T21:34:53Z","messageCount":8,"participants":["Ilia via GitGitGadget","Derrick Stolee","Junio C Hamano","Ilia K"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"554114","messageId":"pull.2247.git.1791127155614.gitgitgadget@gmail.com","threadId":"66460","inReplyTo":null,"subject":"[PATCH] fsmonitor: check the untracked cache after a trivial response","fromName":"Ilia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-04T15:19:15Z","receivedAt":"2026-10-04T15:19:18Z","isPatch":true,"sender":{"key":"name:Ilia","avatar":null},"body":"From: Ilia K <ki.stfu@gmail.com>\n\nWhen the monitor sends a trivial response (\"/\"), for example after\nthe daemon restarted or lost events, refresh_fsmonitor() marks every\nindex entry dirty, which is saved in the index. For the untracked\ncache it only clears the in-memory flag use_fsmonitor. The valid bits\nof the cached directories are saved unchanged, although nothing\nchecks them anymore: valid_cached_dir() does not lstat() a valid\ndirectory while the monitor is trusted.\n\nA command that does not scan for untracked files, like \"git add\" or\n\"git checkout\", therefore saves the new token next to stale valid\nbits, and every later \"git status\" trusts them. A directory removed\nin the meantime keeps its untracked files listed, or, when its own\nentry is invalid, makes every run print\n```\nwarning: could not open directory 'sub/': No such file or directory\n```\nCheck every cached directory against its stat data before the cache\nis saved next to such a token, as valid_cached_dir() does without a\nmonitor, and invalidate the ones that changed or disappeared. Doing\nthis at write time skips commands that do not write the index, and\nsparse index writes, which drop the fsmonitor extension anyway.\nThe cost is one lstat() per cached directory, once per trivial\nresponse.\n\nSigned-off-by: Ilia K <ki.stfu@gmail.com>\n---\n    fsmonitor: check the untracked cache after a trivial response\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2247%2Fk15tfu%2Funtracked-cache-trivial-response-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2247/k15tfu/untracked-cache-trivial-response-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2247\n\n dir.c                        | 56 ++++++++++++++++++++++++++++++++++++\n dir.h                        |  7 +++++\n read-cache.c                 | 16 +++++++++++\n t/t7519-status-fsmonitor.sh  | 55 +++++++++++++++++++++++++++++++++++\n t/t7527-builtin-fsmonitor.sh | 44 ++++++++++++++++++++++++++++\n 5 files changed, 178 insertions(+)\n\ndiff --git a/dir.c b/dir.c\nindex d896e7be4b..fc41ca9694 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -4053,6 +4053,62 @@ void untracked_cache_invalidate_trimmed_path(struct index_state *istate,\n \t}\n }\n \n+static int invalidate_stale_dirs(struct untracked_cache *uc,\n+\t\t\t\t struct untracked_cache_dir *ucd,\n+\t\t\t\t struct index_state *istate,\n+\t\t\t\t struct strbuf *path)\n+{\n+\tstruct stat st;\n+\tsize_t len = path->len;\n+\tint nr_invalidated = 0;\n+\tunsigned int i;\n+\n+\tif (ucd->valid &&\n+\t    (lstat(path->buf, &st) ||\n+\t     match_stat_data_racy(istate, &ucd->stat_data, &st))) {\n+\t\tinvalidate_one_directory(uc, ucd);\n+\t\tnr_invalidated++;\n+\t}\n+\n+\tfor (i = 0; i < ucd->dirs_nr; i++) {\n+\t\t/* not written to the index, see write_one_dir() */\n+\t\tif (!ucd->dirs[i]->recurse)\n+\t\t\tcontinue;\n+\t\tstrbuf_addch(path, '/');\n+\t\tstrbuf_addstr(path, ucd->dirs[i]->name);\n+\t\tnr_invalidated += invalidate_stale_dirs(uc, ucd->dirs[i],\n+\t\t\t\t\t\t\tistate, path);\n+\t\tstrbuf_setlen(path, len);\n+\t}\n+\n+\treturn nr_invalidated;\n+}\n+\n+int untracked_cache_invalidate_stale_dirs(struct index_state *istate)\n+{\n+\tstruct strbuf path = STRBUF_INIT;\n+\tconst char *worktree;\n+\tint nr_invalidated;\n+\n+\tif (!istate->untracked || !istate->untracked->root)\n+\t\treturn 0;\n+\n+\t/*\n+\t * The index is also read and written by commands that do not\n+\t * run in the top-level directory of the worktree.\n+\t */\n+\tworktree = repo_get_work_tree(istate->repo);\n+\tif (!worktree)\n+\t\treturn 0;\n+\n+\tstrbuf_addstr(&path, worktree);\n+\tnr_invalidated = invalidate_stale_dirs(istate->untracked,\n+\t\t\t\t\t       istate->untracked->root,\n+\t\t\t\t\t       istate, &path);\n+\tstrbuf_release(&path);\n+\treturn nr_invalidated;\n+}\n+\n void untracked_cache_remove_from_index(struct index_state *istate,\n \t\t\t\t       const char *path)\n {\ndiff --git a/dir.h b/dir.h\nindex 83e0f648a8..7af1562b44 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -604,6 +604,13 @@ void untracked_cache_invalidate_path(struct index_state *, const char *, int saf\n void untracked_cache_invalidate_trimmed_path(struct index_state *,\n \t\t\t\t\t     const char *path,\n \t\t\t\t\t     int safe_path);\n+/*\n+ * Invalidate every cached directory that no longer exists or whose\n+ * stat data no longer matches the working tree. valid_cached_dir()\n+ * skips this check while the file system monitor is trusted.\n+ * Returns the number of invalidated directories.\n+ */\n+int untracked_cache_invalidate_stale_dirs(struct index_state *);\n void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \ndiff --git a/read-cache.c b/read-cache.c\nindex c4cf08a3a3..00c9960c8e 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3034,6 +3034,22 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \t    istate->untracked) {\n \t\tstrbuf_reset(&sb);\n \n+\t\t/*\n+\t\t * The monitor could not say what changed (see the trivial\n+\t\t * response in refresh_fsmonitor()), so nothing kept the\n+\t\t * valid bits up to date. Check them before they are saved\n+\t\t * next to the new token, which later commands trust even\n+\t\t * when this command did not look for untracked files.\n+\t\t */\n+\t\tif (write_extensions & WRITE_FSMONITOR_EXTENSION &&\n+\t\t    istate->fsmonitor_last_update &&\n+\t\t    !istate->untracked->use_fsmonitor) {\n+\t\t\tint nr = untracked_cache_invalidate_stale_dirs(istate);\n+\n+\t\t\ttrace2_data_intmax(\"index\", istate->repo,\n+\t\t\t\t\t   \"extension/untr/invalidated\", nr);\n+\t\t}\n+\n \t\twrite_untracked_extension(&sb, istate->untracked);\n \t\terr = write_index_ext_header(f, eoie_c, CACHE_EXT_UNTRACKED,\n \t\t\t\t\t     sb.len) < 0;\ndiff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh\nindex 93973ed25a..2e1d795a4b 100755\n--- a/t/t7519-status-fsmonitor.sh\n+++ b/t/t7519-status-fsmonitor.sh\n@@ -336,6 +336,61 @@ do\n \tdone\n done\n \n+# After a trivial response (\"/\") the monitor cannot vouch for the\n+# untracked cache. Even a command that does not look for untracked\n+# files must drop the stale entries, or the next \"git status\" trusts them.\n+test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n+\ttest_when_finished \"rm -rf trivial err\" &&\n+\tgit init trivial &&\n+\t(\n+\t\tcd trivial &&\n+\t\tmkdir -p dir/sub &&\n+\t\techo tracked >dir/sub/tracked &&\n+\t\tgit add dir &&\n+\t\tgit commit -m initial &&\n+\t\tgit config core.fsmonitor \"$TEST_DIRECTORY/t7519/fsmonitor-none\" &&\n+\t\t# Version 1 only, or the hook prints a version complaint\n+\t\t# on stderr at every query.\n+\t\tgit config core.fsmonitorHookVersion 1 &&\n+\t\tgit config core.untrackedCache true &&\n+\t\t# With \"normal\", invalidating one path also invalidates\n+\t\t# its parents, and the stale parent below is never seen.\n+\t\tgit config status.showUntrackedFiles all &&\n+\t\techo untracked >dir/sub/untracked &&\n+\t\techo \"?? dir/sub/untracked\" >../expect &&\n+\t\tgit status --porcelain >../actual &&\n+\t\ttest_cmp ../expect ../actual &&\n+\t\tgit status --porcelain >../actual &&\n+\t\ttest_cmp ../expect ../actual &&\n+\n+\t\t# The monitor misses the removal of dir/sub. \"git add other\"\n+\t\t# gets the trivial response and does not touch the entries\n+\t\t# of dir and dir/sub by itself.\n+\t\trm -r dir/sub &&\n+\t\techo other >other &&\n+\t\tgit -c core.fsmonitor=\"$TEST_DIRECTORY/t7519/fsmonitor-all\" \\\n+\t\t\tadd other &&\n+\t\tcat >../expect <<-\\EOF &&\n+\t\t D dir/sub/tracked\n+\t\tA  other\n+\t\tEOF\n+\t\tgit status --porcelain >../actual 2>../err &&\n+\t\ttest_must_be_empty ../err &&\n+\t\ttest_cmp ../expect ../actual &&\n+\n+\t\t# Invalidate the entry of dir/sub. The stale entry of dir then\n+\t\t# makes \"git status\" open the removed directory and warn.\n+\t\tgit update-index --remove dir/sub/tracked &&\n+\t\tcat >../expect <<-\\EOF &&\n+\t\tD  dir/sub/tracked\n+\t\tA  other\n+\t\tEOF\n+\t\tgit status --porcelain >../actual 2>../err &&\n+\t\ttest_must_be_empty ../err &&\n+\t\ttest_cmp ../expect ../actual\n+\t)\n+'\n+\n # test that splitting the index doesn't interfere\n test_expect_success 'splitting the index results in the same state' '\n \twrite_integration_script &&\ndiff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh\nindex 86195770e9..46b97ef784 100755\n--- a/t/t7527-builtin-fsmonitor.sh\n+++ b/t/t7527-builtin-fsmonitor.sh\n@@ -1389,4 +1389,48 @@ test_expect_success CASE_INSENSITIVE_FS 'fsmonitor file case wrong on disk' '\n \ttest_grep -q \" M dir1/dir2/dir4/FILE-4-A\" \"$PWD/file_case_wrong-try3.out\"\n '\n \n+# After a restart the daemon sends a trivial response (\"/\"), because it\n+# cannot know what changed while it was down. Even a command that does\n+# not look for untracked files must then drop the stale untracked cache\n+# entries, or the next \"git status\" trusts them.\n+test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n+\ttest_when_finished \"stop_daemon_delete_repo test_trivial\" &&\n+\n+\tgit init test_trivial &&\n+\tmkdir -p test_trivial/dir/sub &&\n+\techo tracked >test_trivial/dir/sub/tracked &&\n+\tgit -C test_trivial add dir &&\n+\tgit -C test_trivial commit -m initial &&\n+\tgit -C test_trivial config core.fsmonitor true &&\n+\tgit -C test_trivial config core.untrackedCache true &&\n+\techo untracked >test_trivial/dir/sub/untracked &&\n+\n+\t# The first status starts the daemon and builds the untracked\n+\t# cache, the second one trusts it.\n+\techo \"?? dir/sub/untracked\" >expect &&\n+\tgit -C test_trivial status --porcelain >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C test_trivial status --porcelain >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# Remove dir/sub while no daemon is running. \"git add\" then\n+\t# starts a new daemon, receives its trivial response, and does\n+\t# not look for untracked files.\n+\tgit -C test_trivial fsmonitor--daemon stop &&\n+\trm -r test_trivial/dir/sub &&\n+\techo other >test_trivial/other &&\n+\tGIT_TRACE2_EVENT=\"$PWD/trace_trivial\" \\\n+\t\tgit -C test_trivial add other &&\n+\thave_t2_data_event fsm_client query/trivial-response <trace_trivial &&\n+\tgit -C test_trivial fsmonitor--daemon status &&\n+\n+\tcat >expect <<-\\EOF &&\n+\t D dir/sub/tracked\n+\tA  other\n+\tEOF\n+\tgit -C test_trivial status --porcelain >actual 2>err &&\n+\ttest_must_be_empty err &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nbase-commit: c46c1e37724f0478939de636ab8ea5a89086d532\n-- \ngitgitgadget\n"},{"id":"557556","messageId":"c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com","threadId":"66460","inReplyTo":"pull.2247.git.1791127155614.gitgitgadget@gmail.com","subject":"Re: [PATCH] fsmonitor: check the untracked cache after a trivial response","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-05T15:01:52Z","receivedAt":"2026-11-05T15:01:52Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 10/4/2026 11:19 AM, Ilia via GitGitGadget wrote:\n> From: Ilia K <ki.stfu@gmail.com>\n> \n> When the monitor sends a trivial response (\"/\"), for example after\n> the daemon restarted or lost events, refresh_fsmonitor() marks every\n> index entry dirty, which is saved in the index. For the untracked\n> cache it only clears the in-memory flag use_fsmonitor. The valid bits\n> of the cached directories are saved unchanged, although nothing\n> checks them anymore: valid_cached_dir() does not lstat() a valid\n> directory while the monitor is trusted.\n\nSorry that I declared \"mailing list bankruptcy\" and didn't see your patch\nwhen I was preparing mine [1] for the same issue.\n\n[1] https://lore.kernel.org/git/pull.2295.git.1793806679163.gitgitgadget@gmail.com/\n\n...\n> Check every cached directory against its stat data before the cache\n> is saved next to such a token, as valid_cached_dir() does without a\n> monitor, and invalidate the ones that changed or disappeared. Doing\n> this at write time skips commands that do not write the index, and\n> sparse index writes, which drop the fsmonitor extension anyway.\n> The cost is one lstat() per cached directory, once per trivial\n> response.\n\nThis is the main difference between your patch and mine. My patch does a\nfull clear of the untracked cache, but you do the more efficient thing to\nonly clear the entries that don't match the filesystem info.\n\nThis is visible when running p7527-bulitin-fsmonitor.sh on Linux with a\nsmall setting in fs.inotify.max_user_watches, causing the builtin fsmonitor\nto always fail. My \"clear everything\" patch gets a 50-75% penalty on the\nuntracked cache tests while yours has no measurable impact.\n\nFor this reason, I think your approach is better and worth the slight\nincrease in code complexity.\n\n> +static int invalidate_stale_dirs(struct untracked_cache *uc,\n> +\t\t\t\t struct untracked_cache_dir *ucd,\n> +\t\t\t\t struct index_state *istate,\n> +\t\t\t\t struct strbuf *path)\n> +{\n> +\tstruct stat st;\n> +\tsize_t len = path->len;\n> +\tint nr_invalidated = 0;\n> +\tunsigned int i;\n> +\n> +\tif (ucd->valid &&\n> +\t    (lstat(path->buf, &st) ||\n> +\t     match_stat_data_racy(istate, &ucd->stat_data, &st))) {\n> +\t\tinvalidate_one_directory(uc, ucd);\n> +\t\tnr_invalidated++;\n> +\t}\n> +\n> +\tfor (i = 0; i < ucd->dirs_nr; i++) {\n> +\t\t/* not written to the index, see write_one_dir() */\n> +\t\tif (!ucd->dirs[i]->recurse)\n> +\t\t\tcontinue;\n> +\t\tstrbuf_addch(path, '/');\n> +\t\tstrbuf_addstr(path, ucd->dirs[i]->name);\n> +\t\tnr_invalidated += invalidate_stale_dirs(uc, ucd->dirs[i],\n> +\t\t\t\t\t\t\tistate, path);\n\nI'm conditioned to worry about recursive calls without depth limits, but\nI suppose that we are limited by the untracked cache data structure itself,\nwhich was presumably created recursively without hitting stack limits.\n\nWe could make this iterative using a stack-based data structure, but that\nwould be more complicated than this is worth, probably. These are not used\nin server environments and the .git/index file shouldn't be considered\n\"unsafe\" or else we have bigger safety problems.\n\n> +\t\tstrbuf_setlen(path, len);\n> +\t}\n> +\n> +\treturn nr_invalidated;\n> +}\n> +\n> +int untracked_cache_invalidate_stale_dirs(struct index_state *istate)\n> +{\n> +\tstruct strbuf path = STRBUF_INIT;\n> +\tconst char *worktree;\n> +\tint nr_invalidated;\n> +\n> +\tif (!istate->untracked || !istate->untracked->root)\n> +\t\treturn 0;\n> +\n> +\t/*\n> +\t * The index is also read and written by commands that do not\n> +\t * run in the top-level directory of the worktree.\n> +\t */\n> +\tworktree = repo_get_work_tree(istate->repo);\n> +\tif (!worktree)\n> +\t\treturn 0;\n\nI wonder if this is the right response if we fail to get a worktree. Maybe\nwe should invalidate the entire untracked cache in this case, along with a\nwarning that we couldn't evaluate the worktree? Or should we return -1 to\nsignal an error?\n\n> +\n> +\tstrbuf_addstr(&path, worktree);\n> +\tnr_invalidated = invalidate_stale_dirs(istate->untracked,\n> +\t\t\t\t\t       istate->untracked->root,\n> +\t\t\t\t\t       istate, &path);\n> +\tstrbuf_release(&path);\n> +\treturn nr_invalidated;\n> +}\n...\n> +/*\n> + * Invalidate every cached directory that no longer exists or whose\n> + * stat data no longer matches the working tree. valid_cached_dir()\n> + * skips this check while the file system monitor is trusted.\n> + * Returns the number of invalidated directories.\n> + */\n> +int untracked_cache_invalidate_stale_dirs(struct index_state *);\n\nWe could update this doc comment if we return negative on error.\n\n> diff --git a/read-cache.c b/read-cache.c\n> index c4cf08a3a3..00c9960c8e 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -3034,6 +3034,22 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n>  \t    istate->untracked) {\n>  \t\tstrbuf_reset(&sb);\n>  \n> +\t\t/*\n> +\t\t * The monitor could not say what changed (see the trivial\n> +\t\t * response in refresh_fsmonitor()), so nothing kept the\n> +\t\t * valid bits up to date. Check them before they are saved\n> +\t\t * next to the new token, which later commands trust even\n> +\t\t * when this command did not look for untracked files.\n> +\t\t */\n> +\t\tif (write_extensions & WRITE_FSMONITOR_EXTENSION &&\n> +\t\t    istate->fsmonitor_last_update &&\n> +\t\t    !istate->untracked->use_fsmonitor) {\n> +\t\t\tint nr = untracked_cache_invalidate_stale_dirs(istate);\n> +\n> +\t\t\ttrace2_data_intmax(\"index\", istate->repo,\n> +\t\t\t\t\t   \"extension/untr/invalidated\", nr);\n> +\t\t}\n\nThis surprised me, that you're computing this in do_write_index(). I suppose\nthat this avoids doing this computation unless the index is written, but is\nit possible that between refresh_fsmonitor() and do_write_index() that the\nuntracked cache is read and used to determine what this index update should\nbe?\n\nI used a coding agent to explore my concerns in this space, and it couldn't\nfind an example where doing this in refresh_fsmonitor() would be better than\nits current placement.\n\n> +# After a trivial response (\"/\") the monitor cannot vouch for the\n> +# untracked cache. Even a command that does not look for untracked\n> +# files must drop the stale entries, or the next \"git status\" trusts them.\n\nnit: Generally, we don't need these comments because the tests should be\nself-documenting.\n\n> +test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n> +\ttest_when_finished \"rm -rf trivial err\" &&\n> +\tgit init trivial &&\n> +\t(\n> +\t\tcd trivial &&\n> +\t\tmkdir -p dir/sub &&\n> +\t\techo tracked >dir/sub/tracked &&\n> +\t\tgit add dir &&\n> +\t\tgit commit -m initial &&\n> +\t\tgit config core.fsmonitor \"$TEST_DIRECTORY/t7519/fsmonitor-none\" &&\n> +\t\t# Version 1 only, or the hook prints a version complaint\n> +\t\t# on stderr at every query.\n> +\t\tgit config core.fsmonitorHookVersion 1 &&\n> +\t\tgit config core.untrackedCache true &&\n> +\t\t# With \"normal\", invalidating one path also invalidates\n> +\t\t# its parents, and the stale parent below is never seen.\n> +\t\tgit config status.showUntrackedFiles all &&\n> +\t\techo untracked >dir/sub/untracked &&\n> +\t\techo \"?? dir/sub/untracked\" >../expect &&\n> +\t\tgit status --porcelain >../actual &&\n> +\t\ttest_cmp ../expect ../actual &&\n> +\t\tgit status --porcelain >../actual &&\n> +\t\ttest_cmp ../expect ../actual &&\n> +\n> +\t\t# The monitor misses the removal of dir/sub. \"git add other\"\n> +\t\t# gets the trivial response and does not touch the entries\n> +\t\t# of dir and dir/sub by itself.\n> +\t\trm -r dir/sub &&\n> +\t\techo other >other &&\n> +\t\tgit -c core.fsmonitor=\"$TEST_DIRECTORY/t7519/fsmonitor-all\" \\\n> +\t\t\tadd other &&\n> +\t\tcat >../expect <<-\\EOF &&\n> +\t\t D dir/sub/tracked\n> +\t\tA  other\n\nI initially thought that this difference in left-padding was a typo, but\nit is functional. We need a space before D and a space after A to signal\nthe different states.\n\n> +\t\tEOF\n> +\t\tgit status --porcelain >../actual 2>../err &&\n> +\t\ttest_must_be_empty ../err &&\n> +\t\ttest_cmp ../expect ../actual &&\n> +\n> +\t\t# Invalidate the entry of dir/sub. The stale entry of dir then\n> +\t\t# makes \"git status\" open the removed directory and warn.\n> +\t\tgit update-index --remove dir/sub/tracked &&\n> +\t\tcat >../expect <<-\\EOF &&\n> +\t\tD  dir/sub/tracked\n> +\t\tA  other\n\nAnd of course now the deletion is staged. Good.\n\n> +\t\tEOF\n> +\t\tgit status --porcelain >../actual 2>../err &&\n> +\t\ttest_must_be_empty ../err &&\n> +\t\ttest_cmp ../expect ../actual\n> +\t)\n> +'\n\n> +# After a restart the daemon sends a trivial response (\"/\"), because it\n> +# cannot know what changed while it was down. Even a command that does\n> +# not look for untracked files must then drop the stale untracked cache\n> +# entries, or the next \"git status\" trusts them.\n\nsame nit: comments shouldn't be necessary here.\n\n> +test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n> +\ttest_when_finished \"stop_daemon_delete_repo test_trivial\" &&\n> +\n> +\tgit init test_trivial &&\n> +\tmkdir -p test_trivial/dir/sub &&\n> +\techo tracked >test_trivial/dir/sub/tracked &&\n> +\tgit -C test_trivial add dir &&\n> +\tgit -C test_trivial commit -m initial &&\n> +\tgit -C test_trivial config core.fsmonitor true &&\n> +\tgit -C test_trivial config core.untrackedCache true &&\n> +\techo untracked >test_trivial/dir/sub/untracked &&\n> +\n> +\t# The first status starts the daemon and builds the untracked\n> +\t# cache, the second one trusts it.\n> +\techo \"?? dir/sub/untracked\" >expect &&\n> +\tgit -C test_trivial status --porcelain >actual &&\n> +\ttest_cmp expect actual &&\n> +\tgit -C test_trivial status --porcelain >actual &&\n> +\ttest_cmp expect actual &&\n> +\n> +\t# Remove dir/sub while no daemon is running. \"git add\" then\n> +\t# starts a new daemon, receives its trivial response, and does\n> +\t# not look for untracked files.\n> +\tgit -C test_trivial fsmonitor--daemon stop &&\n> +\trm -r test_trivial/dir/sub &&\n> +\techo other >test_trivial/other &&\n> +\tGIT_TRACE2_EVENT=\"$PWD/trace_trivial\" \\\n> +\t\tgit -C test_trivial add other &&\n> +\thave_t2_data_event fsm_client query/trivial-response <trace_trivial &&\n> +\tgit -C test_trivial fsmonitor--daemon status &&\n> +\n> +\tcat >expect <<-\\EOF &&\n> +\t D dir/sub/tracked\n> +\tA  other\n> +\tEOF\n> +\tgit -C test_trivial status --porcelain >actual 2>err &&\n> +\ttest_must_be_empty err &&\n> +\ttest_cmp expect actual\n> +'\n\nOverall, this patch appears to solve the same problem that pointed me in\nthis direction. I don't see any issues worth re-rolling this patch, so it\nLGTM.\n\nThanks,\n-Stolee\n\n"},{"id":"557596","messageId":"xmqqld77uofw.fsf@gitster.g","threadId":"66460","inReplyTo":"c724ab00-dfb8-4e81-8bd7-89702bea51b4@gmail.com","subject":"Re: [PATCH] fsmonitor: check the untracked cache after a trivial response","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-05T18:24:03Z","receivedAt":"2026-11-05T18:24:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n>> +\tfor (i = 0; i < ucd->dirs_nr; i++) {\n>> +\t\t/* not written to the index, see write_one_dir() */\n>> +\t\tif (!ucd->dirs[i]->recurse)\n>> +\t\t\tcontinue;\n>> +\t\tstrbuf_addch(path, '/');\n>> +\t\tstrbuf_addstr(path, ucd->dirs[i]->name);\n>> +\t\tnr_invalidated += invalidate_stale_dirs(uc, ucd->dirs[i],\n>> +\t\t\t\t\t\t\tistate, path);\n>\n> I'm conditioned to worry about recursive calls without depth limits, but\n> I suppose that we are limited by the untracked cache data structure itself,\n> which was presumably created recursively without hitting stack limits.\n>\n> We could make this iterative using a stack-based data structure, but that\n> would be more complicated than this is worth, probably. These are not used\n> in server environments and the .git/index file shouldn't be considered\n> \"unsafe\" or else we have bigger safety problems.\n\nGood reasoning.  Thanks for spelling it out.\n\n>> +\t/*\n>> +\t * The index is also read and written by commands that do not\n>> +\t * run in the top-level directory of the worktree.\n>> +\t */\n>> +\tworktree = repo_get_work_tree(istate->repo);\n>> +\tif (!worktree)\n>> +\t\treturn 0;\n>\n> I wonder if this is the right response if we fail to get a worktree. Maybe\n> we should invalidate the entire untracked cache in this case, along with a\n> warning that we couldn't evaluate the worktree? Or should we return -1 to\n> signal an error?\n\nIt probably is safer to invalidate and continue.  If there is truly\nnot a worktree, untracked cache entries do not matter ;-)\n\nThanks for a review.\n\n"},{"id":"557972","messageId":"CAMmqxguRpCFL2cRJ_LCXaPd9d91zFb-Yo6MVbhSsi57S14xseA@mail.gmail.com","threadId":"66460","inReplyTo":"xmqqld77uofw.fsf@gitster.g","subject":"Re: [PATCH] fsmonitor: check the untracked cache after a trivial response","fromName":"Ilia K","fromEmail":"ki.stfu@gmail.com","sentAt":"2026-11-09T18:59:10Z","receivedAt":"2026-11-09T18:59:10Z","isPatch":true,"sender":{"key":"ki.stfu@gmail.com","avatar":null},"body":"On Thu, Nov 5, 2026 at 4:01 PM Derrick Stolee <stolee@gmail.com> wrote:\n>\n> > +             strbuf_setlen(path, len);\n> > +     }\n> > +\n> > +     return nr_invalidated;\n> > +}\n> > +\n> > +int untracked_cache_invalidate_stale_dirs(struct index_state *istate)\n> > +{\n> > +     struct strbuf path = STRBUF_INIT;\n> > +     const char *worktree;\n> > +     int nr_invalidated;\n> > +\n> > +     if (!istate->untracked || !istate->untracked->root)\n> > +             return 0;\n> > +\n> > +     /*\n> > +      * The index is also read and written by commands that do not\n> > +      * run in the top-level directory of the worktree.\n> > +      */\n> > +     worktree = repo_get_work_tree(istate->repo);\n> > +     if (!worktree)\n> > +             return 0;\n>\n> I wonder if this is the right response if we fail to get a worktree. Maybe\n> we should invalidate the entire untracked cache in this case, along with a\n> warning that we couldn't evaluate the worktree? Or should we return -1 to\n> signal an error?\n\nFixed, thank you!\n\n> > diff --git a/read-cache.c b/read-cache.c\n> > index c4cf08a3a3..00c9960c8e 100644\n> > --- a/read-cache.c\n> > +++ b/read-cache.c\n> > @@ -3034,6 +3034,22 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n> >           istate->untracked) {\n> >               strbuf_reset(&sb);\n> >\n> > +             /*\n> > +              * The monitor could not say what changed (see the trivial\n> > +              * response in refresh_fsmonitor()), so nothing kept the\n> > +              * valid bits up to date. Check them before they are saved\n> > +              * next to the new token, which later commands trust even\n> > +              * when this command did not look for untracked files.\n> > +              */\n> > +             if (write_extensions & WRITE_FSMONITOR_EXTENSION &&\n> > +                 istate->fsmonitor_last_update &&\n> > +                 !istate->untracked->use_fsmonitor) {\n> > +                     int nr = untracked_cache_invalidate_stale_dirs(istate);\n> > +\n> > +                     trace2_data_intmax(\"index\", istate->repo,\n> > +                                        \"extension/untr/invalidated\", nr);\n> > +             }\n>\n> This surprised me, that you're computing this in do_write_index(). I suppose\n> that this avoids doing this computation unless the index is written, but is\n> it possible that between refresh_fsmonitor() and do_write_index() that the\n> untracked cache is read and used to determine what this index update should\n> be?\n\nNo, nothing between `refresh_fsmonitor()` and `do_write_index()`\ntrusts the cache because use_fsmonitor stays 0 until the index is\nwritten.\n\n> > +# After a trivial response (\"/\") the monitor cannot vouch for the\n> > +# untracked cache. Even a command that does not look for untracked\n> > +# files must drop the stale entries, or the next \"git status\" trusts them.\n>\n> nit: Generally, we don't need these comments because the tests should be\n> self-documenting.\n\nFixed, thank you!\n\n> > +             EOF\n> > +             git status --porcelain >../actual 2>../err &&\n> > +             test_must_be_empty ../err &&\n> > +             test_cmp ../expect ../actual\n> > +     )\n> > +'\n>\n> > +# After a restart the daemon sends a trivial response (\"/\"), because it\n> > +# cannot know what changed while it was down. Even a command that does\n> > +# not look for untracked files must then drop the stale untracked cache\n> > +# entries, or the next \"git status\" trusts them.\n>\n> same nit: comments shouldn't be necessary here.\n\nFixed, thank you!\n\n--\n- Ilia\n\n"},{"id":"557979","messageId":"pull.2247.v2.git.1794251653636.gitgitgadget@gmail.com","threadId":"66460","inReplyTo":"pull.2247.git.1791127155614.gitgitgadget@gmail.com","subject":"[PATCH v2] fsmonitor: check the untracked cache after a trivial response","fromName":"Ilia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-09T19:14:13Z","receivedAt":"2026-11-09T19:14:13Z","isPatch":true,"sender":{"key":"name:Ilia","avatar":null},"body":"From: Ilia K <ki.stfu@gmail.com>\n\nWhen the monitor sends a trivial response (\"/\"), for example after\nthe daemon restarted or lost events, refresh_fsmonitor() marks every\nindex entry dirty, which is saved in the index. For the untracked\ncache it only clears the in-memory flag use_fsmonitor. The valid bits\nof the cached directories are saved unchanged, although nothing\nchecks them anymore: valid_cached_dir() does not lstat() a valid\ndirectory while the monitor is trusted.\n\nA command that does not scan for untracked files, like \"git add\" or\n\"git checkout\", therefore saves the new token next to stale valid\nbits, and every later \"git status\" trusts them. A directory removed\nin the meantime keeps its untracked files listed, or, when its own\nentry is invalid, makes every run print\n```\nwarning: could not open directory 'sub/': No such file or directory\n```\nCheck every cached directory against its stat data before the cache\nis saved next to such a token, as valid_cached_dir() does without a\nmonitor, and invalidate the ones that changed or disappeared. Within\nthe command itself, valid_cached_dir() already checks every directory,\nbecause use_fsmonitor is cleared. Only what is saved needs the check.\nDoing this at write time skips commands that do not write the index,\nand sparse index writes, which drop the fsmonitor extension anyway.\nThe cost is one lstat() per cached directory, once per trivial\nresponse.\n\nSigned-off-by: Ilia K <ki.stfu@gmail.com>\n---\n    fsmonitor: check the untracked cache after a trivial response\n    \n    Changes since v1:\n    \n     * the whole untracked cache is dropped if !worktree\n     * removed the comments as per nits\n     * rebased against ToT\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2247%2Fk15tfu%2Funtracked-cache-trivial-response-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2247/k15tfu/untracked-cache-trivial-response-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2247\n\nRange-diff vs v1:\n\n 1:  84618b83fe ! 1:  d2cad8abe6 fsmonitor: check the untracked cache after a trivial response\n     @@ Commit message\n          ```\n          Check every cached directory against its stat data before the cache\n          is saved next to such a token, as valid_cached_dir() does without a\n     -    monitor, and invalidate the ones that changed or disappeared. Doing\n     -    this at write time skips commands that do not write the index, and\n     -    sparse index writes, which drop the fsmonitor extension anyway.\n     +    monitor, and invalidate the ones that changed or disappeared. Within\n     +    the command itself, valid_cached_dir() already checks every directory,\n     +    because use_fsmonitor is cleared. Only what is saved needs the check.\n     +    Doing this at write time skips commands that do not write the index,\n     +    and sparse index writes, which drop the fsmonitor extension anyway.\n          The cost is one lstat() per cached directory, once per trivial\n          response.\n      \n     @@ dir.c: void untracked_cache_invalidate_trimmed_path(struct index_state *istate,\n      +\t * run in the top-level directory of the worktree.\n      +\t */\n      +\tworktree = repo_get_work_tree(istate->repo);\n     -+\tif (!worktree)\n     -+\t\treturn 0;\n     ++\tif (!worktree) {\n     ++\t\tinvalidate_directory(istate->untracked,\n     ++\t\t\t\t     istate->untracked->root);\n     ++\t\treturn 1;\n     ++\t}\n      +\n      +\tstrbuf_addstr(&path, worktree);\n      +\tnr_invalidated = invalidate_stale_dirs(istate->untracked,\n     @@ t/t7519-status-fsmonitor.sh: do\n       \tdone\n       done\n       \n     -+# After a trivial response (\"/\") the monitor cannot vouch for the\n     -+# untracked cache. Even a command that does not look for untracked\n     -+# files must drop the stale entries, or the next \"git status\" trusts them.\n      +test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n      +\ttest_when_finished \"rm -rf trivial err\" &&\n      +\tgit init trivial &&\n     @@ t/t7527-builtin-fsmonitor.sh: test_expect_success CASE_INSENSITIVE_FS 'fsmonitor\n       \ttest_grep -q \" M dir1/dir2/dir4/FILE-4-A\" \"$PWD/file_case_wrong-try3.out\"\n       '\n       \n     -+# After a restart the daemon sends a trivial response (\"/\"), because it\n     -+# cannot know what changed while it was down. Even a command that does\n     -+# not look for untracked files must then drop the stale untracked cache\n     -+# entries, or the next \"git status\" trusts them.\n      +test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n      +\ttest_when_finished \"stop_daemon_delete_repo test_trivial\" &&\n      +\n\n\n dir.c                        | 59 ++++++++++++++++++++++++++++++++++++\n dir.h                        |  7 +++++\n read-cache.c                 | 16 ++++++++++\n t/t7519-status-fsmonitor.sh  | 52 +++++++++++++++++++++++++++++++\n t/t7527-builtin-fsmonitor.sh | 40 ++++++++++++++++++++++++\n 5 files changed, 174 insertions(+)\n\ndiff --git a/dir.c b/dir.c\nindex ac246ced1d..4f748800b1 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -4066,6 +4066,65 @@ void untracked_cache_invalidate_trimmed_path(struct index_state *istate,\n \t}\n }\n \n+static int invalidate_stale_dirs(struct untracked_cache *uc,\n+\t\t\t\t struct untracked_cache_dir *ucd,\n+\t\t\t\t struct index_state *istate,\n+\t\t\t\t struct strbuf *path)\n+{\n+\tstruct stat st;\n+\tsize_t len = path->len;\n+\tint nr_invalidated = 0;\n+\tunsigned int i;\n+\n+\tif (ucd->valid &&\n+\t    (lstat(path->buf, &st) ||\n+\t     match_stat_data_racy(istate, &ucd->stat_data, &st))) {\n+\t\tinvalidate_one_directory(uc, ucd);\n+\t\tnr_invalidated++;\n+\t}\n+\n+\tfor (i = 0; i < ucd->dirs_nr; i++) {\n+\t\t/* not written to the index, see write_one_dir() */\n+\t\tif (!ucd->dirs[i]->recurse)\n+\t\t\tcontinue;\n+\t\tstrbuf_addch(path, '/');\n+\t\tstrbuf_addstr(path, ucd->dirs[i]->name);\n+\t\tnr_invalidated += invalidate_stale_dirs(uc, ucd->dirs[i],\n+\t\t\t\t\t\t\tistate, path);\n+\t\tstrbuf_setlen(path, len);\n+\t}\n+\n+\treturn nr_invalidated;\n+}\n+\n+int untracked_cache_invalidate_stale_dirs(struct index_state *istate)\n+{\n+\tstruct strbuf path = STRBUF_INIT;\n+\tconst char *worktree;\n+\tint nr_invalidated;\n+\n+\tif (!istate->untracked || !istate->untracked->root)\n+\t\treturn 0;\n+\n+\t/*\n+\t * The index is also read and written by commands that do not\n+\t * run in the top-level directory of the worktree.\n+\t */\n+\tworktree = repo_get_work_tree(istate->repo);\n+\tif (!worktree) {\n+\t\tinvalidate_directory(istate->untracked,\n+\t\t\t\t     istate->untracked->root);\n+\t\treturn 1;\n+\t}\n+\n+\tstrbuf_addstr(&path, worktree);\n+\tnr_invalidated = invalidate_stale_dirs(istate->untracked,\n+\t\t\t\t\t       istate->untracked->root,\n+\t\t\t\t\t       istate, &path);\n+\tstrbuf_release(&path);\n+\treturn nr_invalidated;\n+}\n+\n void untracked_cache_remove_from_index(struct index_state *istate,\n \t\t\t\t       const char *path)\n {\ndiff --git a/dir.h b/dir.h\nindex 83e0f648a8..7af1562b44 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -604,6 +604,13 @@ void untracked_cache_invalidate_path(struct index_state *, const char *, int saf\n void untracked_cache_invalidate_trimmed_path(struct index_state *,\n \t\t\t\t\t     const char *path,\n \t\t\t\t\t     int safe_path);\n+/*\n+ * Invalidate every cached directory that no longer exists or whose\n+ * stat data no longer matches the working tree. valid_cached_dir()\n+ * skips this check while the file system monitor is trusted.\n+ * Returns the number of invalidated directories.\n+ */\n+int untracked_cache_invalidate_stale_dirs(struct index_state *);\n void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \ndiff --git a/read-cache.c b/read-cache.c\nindex 1d2b97c429..5d95ba7680 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3084,6 +3084,22 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \t    istate->untracked) {\n \t\tstrbuf_reset(&sb);\n \n+\t\t/*\n+\t\t * The monitor could not say what changed (see the trivial\n+\t\t * response in refresh_fsmonitor()), so nothing kept the\n+\t\t * valid bits up to date. Check them before they are saved\n+\t\t * next to the new token, which later commands trust even\n+\t\t * when this command did not look for untracked files.\n+\t\t */\n+\t\tif (write_extensions & WRITE_FSMONITOR_EXTENSION &&\n+\t\t    istate->fsmonitor_last_update &&\n+\t\t    !istate->untracked->use_fsmonitor) {\n+\t\t\tint nr = untracked_cache_invalidate_stale_dirs(istate);\n+\n+\t\t\ttrace2_data_intmax(\"index\", istate->repo,\n+\t\t\t\t\t   \"extension/untr/invalidated\", nr);\n+\t\t}\n+\n \t\twrite_untracked_extension(&sb, istate->untracked);\n \t\terr = write_index_ext_header(f, eoie_c, CACHE_EXT_UNTRACKED,\n \t\t\t\t\t     sb.len) < 0;\ndiff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh\nindex 93973ed25a..27c3194ae0 100755\n--- a/t/t7519-status-fsmonitor.sh\n+++ b/t/t7519-status-fsmonitor.sh\n@@ -336,6 +336,58 @@ do\n \tdone\n done\n \n+test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n+\ttest_when_finished \"rm -rf trivial err\" &&\n+\tgit init trivial &&\n+\t(\n+\t\tcd trivial &&\n+\t\tmkdir -p dir/sub &&\n+\t\techo tracked >dir/sub/tracked &&\n+\t\tgit add dir &&\n+\t\tgit commit -m initial &&\n+\t\tgit config core.fsmonitor \"$TEST_DIRECTORY/t7519/fsmonitor-none\" &&\n+\t\t# Version 1 only, or the hook prints a version complaint\n+\t\t# on stderr at every query.\n+\t\tgit config core.fsmonitorHookVersion 1 &&\n+\t\tgit config core.untrackedCache true &&\n+\t\t# With \"normal\", invalidating one path also invalidates\n+\t\t# its parents, and the stale parent below is never seen.\n+\t\tgit config status.showUntrackedFiles all &&\n+\t\techo untracked >dir/sub/untracked &&\n+\t\techo \"?? dir/sub/untracked\" >../expect &&\n+\t\tgit status --porcelain >../actual &&\n+\t\ttest_cmp ../expect ../actual &&\n+\t\tgit status --porcelain >../actual &&\n+\t\ttest_cmp ../expect ../actual &&\n+\n+\t\t# The monitor misses the removal of dir/sub. \"git add other\"\n+\t\t# gets the trivial response and does not touch the entries\n+\t\t# of dir and dir/sub by itself.\n+\t\trm -r dir/sub &&\n+\t\techo other >other &&\n+\t\tgit -c core.fsmonitor=\"$TEST_DIRECTORY/t7519/fsmonitor-all\" \\\n+\t\t\tadd other &&\n+\t\tcat >../expect <<-\\EOF &&\n+\t\t D dir/sub/tracked\n+\t\tA  other\n+\t\tEOF\n+\t\tgit status --porcelain >../actual 2>../err &&\n+\t\ttest_must_be_empty ../err &&\n+\t\ttest_cmp ../expect ../actual &&\n+\n+\t\t# Invalidate the entry of dir/sub. The stale entry of dir then\n+\t\t# makes \"git status\" open the removed directory and warn.\n+\t\tgit update-index --remove dir/sub/tracked &&\n+\t\tcat >../expect <<-\\EOF &&\n+\t\tD  dir/sub/tracked\n+\t\tA  other\n+\t\tEOF\n+\t\tgit status --porcelain >../actual 2>../err &&\n+\t\ttest_must_be_empty ../err &&\n+\t\ttest_cmp ../expect ../actual\n+\t)\n+'\n+\n # test that splitting the index doesn't interfere\n test_expect_success 'splitting the index results in the same state' '\n \twrite_integration_script &&\ndiff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh\nindex 86195770e9..f2770e9056 100755\n--- a/t/t7527-builtin-fsmonitor.sh\n+++ b/t/t7527-builtin-fsmonitor.sh\n@@ -1389,4 +1389,44 @@ test_expect_success CASE_INSENSITIVE_FS 'fsmonitor file case wrong on disk' '\n \ttest_grep -q \" M dir1/dir2/dir4/FILE-4-A\" \"$PWD/file_case_wrong-try3.out\"\n '\n \n+test_expect_success UNTRACKED_CACHE 'untracked cache is checked after a trivial response' '\n+\ttest_when_finished \"stop_daemon_delete_repo test_trivial\" &&\n+\n+\tgit init test_trivial &&\n+\tmkdir -p test_trivial/dir/sub &&\n+\techo tracked >test_trivial/dir/sub/tracked &&\n+\tgit -C test_trivial add dir &&\n+\tgit -C test_trivial commit -m initial &&\n+\tgit -C test_trivial config core.fsmonitor true &&\n+\tgit -C test_trivial config core.untrackedCache true &&\n+\techo untracked >test_trivial/dir/sub/untracked &&\n+\n+\t# The first status starts the daemon and builds the untracked\n+\t# cache, the second one trusts it.\n+\techo \"?? dir/sub/untracked\" >expect &&\n+\tgit -C test_trivial status --porcelain >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -C test_trivial status --porcelain >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# Remove dir/sub while no daemon is running. \"git add\" then\n+\t# starts a new daemon, receives its trivial response, and does\n+\t# not look for untracked files.\n+\tgit -C test_trivial fsmonitor--daemon stop &&\n+\trm -r test_trivial/dir/sub &&\n+\techo other >test_trivial/other &&\n+\tGIT_TRACE2_EVENT=\"$PWD/trace_trivial\" \\\n+\t\tgit -C test_trivial add other &&\n+\thave_t2_data_event fsm_client query/trivial-response <trace_trivial &&\n+\tgit -C test_trivial fsmonitor--daemon status &&\n+\n+\tcat >expect <<-\\EOF &&\n+\t D dir/sub/tracked\n+\tA  other\n+\tEOF\n+\tgit -C test_trivial status --porcelain >actual 2>err &&\n+\ttest_must_be_empty err &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nbase-commit: fb255012acbcbe81189cb8014da0280b09c66ecc\n-- \ngitgitgadget\n\n"},{"id":"557990","messageId":"fefa2680-695c-41db-9975-7e972590b969@gmail.com","threadId":"66460","inReplyTo":"pull.2247.v2.git.1794251653636.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] fsmonitor: check the untracked cache after a trivial response","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-09T20:47:33Z","receivedAt":"2026-11-09T20:47:33Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/9/2026 2:14 PM, Ilia via GitGitGadget wrote:\n>     Changes since v1:\n>     \n>      * the whole untracked cache is dropped if !worktree\n>      * removed the comments as per nits\n\nThanks for these improvements. The v2 patch LGTM.\n\n>      * rebased against ToT\n\nGenerally, you shouldn't do this as the maintainer will apply\nyour patch in the same spot and handle most merge conflicts\nvia rerere, but rebasing interrupts that. The main exception\nis when you rebase onto a specific topic or with regards to a\nlarge refactor that merged recently.\n\nThanks,\n-Stolee\n\n\n"},{"id":"557995","messageId":"xmqq8q31yb5s.fsf@gitster.g","threadId":"66460","inReplyTo":"fefa2680-695c-41db-9975-7e972590b969@gmail.com","subject":"Re: [PATCH v2] fsmonitor: check the untracked cache after a trivial response","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-09T20:58:39Z","receivedAt":"2026-11-09T20:58:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 11/9/2026 2:14 PM, Ilia via GitGitGadget wrote:\n>>     Changes since v1:\n>>     \n>>      * the whole untracked cache is dropped if !worktree\n>>      * removed the comments as per nits\n>\n> Thanks for these improvements. The v2 patch LGTM.\n>\n>>      * rebased against ToT\n>\n> Generally, you shouldn't do this as the maintainer will apply\n> your patch in the same spot and handle most merge conflicts\n> via rerere, but rebasing interrupts that. The main exception\n> is when you rebase onto a specific topic or with regards to a\n> large refactor that merged recently.\n\nGood suggestion.  Worse yet, the topic is already in 'next' so a\nwholesale replacement is not very welcome.\n\n"},{"id":"557999","messageId":"xmqqse19wuwy.fsf@gitster.g","threadId":"66460","inReplyTo":"xmqq8q31yb5s.fsf@gitster.g","subject":"Re: [PATCH v2] fsmonitor: check the untracked cache after a trivial response","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-09T21:34:53Z","receivedAt":"2026-11-09T21:34:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> Thanks for these improvements. The v2 patch LGTM.\n>>\n>>>      * rebased against ToT\n>>\n>> Generally, you shouldn't do this as the maintainer will apply\n>> your patch in the same spot and handle most merge conflicts\n>> via rerere, but rebasing interrupts that. The main exception\n>> is when you rebase onto a specific topic or with regards to a\n>> large refactor that merged recently.\n>\n> Good suggestion.  Worse yet, the topic is already in 'next' so a\n> wholesale replacement is not very welcome.\n\nWell, I ended up reverting the merge to 'next', and queued this\niteration (applied on exactly the same base as v1 was applied in my\ntree---the patch cleanly applied as if there were no rebase).  I'll\nmark the topic again ready for 'next' after waiting for a few days\nto see if there are any more feedback.\n\nThanks, all.\n\n"}]}