mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Johannes Schindelin via GitGitGadget" <>
Cc: Johannes Schindelin <>,
	Johannes Schindelin <>
Subject: [PATCH v2] fsmonitor: only enable it in non-bare repositories
Date: Mon, 03 May 2021 09:11:45 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

From: Johannes Schindelin <>

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 <>
    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
    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!)

Fetch-It-Via: git fetch pr-942/dscho/bare-repositories-need-no-fsmonitor-v2

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

  parent reply	other threads:[~2021-05-03  9:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  7:46 [PATCH] fsmonitor: only enable it in non-bare repositories Johannes Schindelin via GitGitGadget
2021-04-30 13:55 ` Junio C Hamano
2021-05-03  9:11 ` Johannes Schindelin via GitGitGadget [this message]
2021-05-03 13:58 ` Ævar Arnfjörð Bjarmason
2021-05-03 17:27   ` Jeff Hostetler
2021-05-03 17:56     ` Ævar Arnfjörð Bjarmason
2021-05-11 19:24       ` Jeff Hostetler

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:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).