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

[PATCH v2] fsmonitor: only enable it in non-bare repositories

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
May 3, 2021, 09:11 UTC
Message-ID
<pull.942.v2.git.1620033105872.gitgitgadget@gmail.com>
In-Reply-To
<pull.942.git.1619682362363.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

The entire point of the FSMonitor is to monitor the worktree changes in a more efficient manner than `lstat()`ing all worktree files every time we refresh the index.

But if there is no worktree, FSMonitor has nothing to monitor.

So let's ignore if an FSMonitor is configured (e.g. in `~/.gitconfig`) and we're running in a repository without worktree.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    fsmonitor: only enable it in non-bare repositories
    
    For quite a while now, I run with the built-in FSMonitor via my user
    config. Happily, the only issue I ran into was that FSMonitor tried to
    run in a bare repository the other day. But an FSMonitor makes only
    sense if we have a worktree. So let's disable it automatically in bare
    repositories.
    
    This patch applies near the top of jh/rfc-builtin-fsmonitor. I would
    like to keep it as a separate topic because the built-in FSMonitor did
    not introduce this bug. This bug has been in Git's FSMonitor feature for
    a long, long time.
    
    Changes since v1:
    
     * Using NULL instead of 0 (d'oh!)
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-942%2Fdscho%2Fbare-repositories-need-no-fsmonitor-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-942/dscho/bare-repositories-need-no-fsmonitor-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/942
Range-diff vs v1:
 1:  3a93be538d33 ! 1:  95333bbf45d5 fsmonitor: only enable it in non-bare repositories
     @@ config.c: int git_config_get_max_percent_split_change(void)
       {
      +	if (!r->worktree) {
      +		/* FSMonitor makes no sense in bare repositories */
     -+		core_fsmonitor = 0;
     ++		core_fsmonitor = NULL;
      +		return 1;
      +	}
      +
 config.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/config.c b/config.c
index 53e7dedc60de..90ce4c23d3dc 100644
--- a/config.c
+++ b/config.c
@@ -2515,6 +2515,12 @@ int git_config_get_max_percent_split_change(void)
 
 int repo_config_get_fsmonitor(struct repository *r)
 {
+	if (!r->worktree) {
+		/* FSMonitor makes no sense in bare repositories */
+		core_fsmonitor = NULL;
+		return 1;
+	}
+
 	if (r->settings.use_builtin_fsmonitor > 0) {
 		core_fsmonitor = "(built-in daemon)";
 		return 1;

base-commit: 14d50074ff19e68e7a8d718b22d138882087bbc9
-- 
gitgitgadget
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 3 of 7 in “fsmonitor: only enable it in non-bare repositories”
  1. fsmonitor: only enable it in non-bare repositoriesJohannes Schindelin via GitGitGadget, Apr 29, 2021
  2. Junio C HamanoApr 30, 2021
  3. fsmonitor: only enable it in non-bare repositoriesJohannes Schindelin via GitGitGadget, May 3, 2021
  4. Ævar Arnfjörð BjarmasonMay 3, 2021
  5. Jeff HostetlerMay 3, 2021
  6. Ævar Arnfjörð BjarmasonMay 3, 2021
  7. Jeff HostetlerMay 11, 2021

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.