Skip to content

Commit eee16aa

Browse files
jeffhostetlerdscho
authored andcommitted
fixup! fsmonitor--daemon: do not try to operate on bare repos
This reverts commit eab07e1. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent d27ea8b commit eee16aa

File tree

5 files changed

+9
-130
lines changed

5 files changed

+9
-130
lines changed

builtin/fsmonitor--daemon.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,17 +490,6 @@ int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
490490
die(_("invalid 'ipc-threads' value (%d)"),
491491
fsmonitor__ipc_threads);
492492

493-
prepare_repo_settings(the_repository);
494-
495-
fsm_settings__set_ipc(the_repository);
496-
if (fsm_settings__get_mode(the_repository) == FSMONITOR_MODE_INCOMPATIBLE) {
497-
struct strbuf buf_reason = STRBUF_INIT;
498-
fsm_settings__get_reason(the_repository, &buf_reason);
499-
error("%s '%s'", buf_reason.buf, xgetcwd());
500-
strbuf_release(&buf_reason);
501-
return -1;
502-
}
503-
504493
if (!strcmp(subcmd, "start"))
505494
return !!try_to_start_background_daemon();
506495

builtin/update-index.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,14 +1218,6 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
12181218
if (fsmonitor > 0) {
12191219
enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(r);
12201220

1221-
if (fsm_mode == FSMONITOR_MODE_INCOMPATIBLE) {
1222-
struct strbuf buf_reason = STRBUF_INIT;
1223-
fsm_settings__get_reason(r, &buf_reason);
1224-
error("%s", buf_reason.buf);
1225-
strbuf_release(&buf_reason);
1226-
return -1;
1227-
}
1228-
12291221
if (fsm_mode == FSMONITOR_MODE_DISABLED) {
12301222
warning(_("core.useBuiltinFSMonitor is unset; "
12311223
"set it if you really want to enable the "

fsmonitor-settings.c

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,29 @@
99
*/
1010
struct fsmonitor_settings {
1111
enum fsmonitor_mode mode;
12-
enum fsmonitor_reason reason;
1312
char *hook_path;
1413
};
1514

16-
static void set_incompatible(struct repository *r,
17-
enum fsmonitor_reason reason)
18-
{
19-
struct fsmonitor_settings *s = r->settings.fsmonitor;
20-
21-
s->mode = FSMONITOR_MODE_INCOMPATIBLE;
22-
s->reason = reason;
23-
}
24-
25-
static int check_for_incompatible(struct repository *r)
26-
{
27-
if (!r->worktree) {
28-
/*
29-
* Bare repositories don't have a working directory and
30-
* therefore have nothing to watch.
31-
*/
32-
set_incompatible(r, FSMONITOR_REASON_BARE);
33-
return 1;
34-
}
35-
36-
return 0;
37-
}
38-
39-
static struct fsmonitor_settings *s_init(struct repository *r)
40-
{
41-
if (!r->settings.fsmonitor)
42-
CALLOC_ARRAY(r->settings.fsmonitor, 1);
43-
44-
return r->settings.fsmonitor;
45-
}
46-
4715
void fsm_settings__set_ipc(struct repository *r)
4816
{
49-
struct fsmonitor_settings *s = s_init(r);
50-
51-
if (check_for_incompatible(r))
52-
return;
17+
struct fsmonitor_settings *s = r->settings.fsmonitor;
5318

5419
s->mode = FSMONITOR_MODE_IPC;
5520
}
5621

5722
void fsm_settings__set_hook(struct repository *r, const char *path)
5823
{
59-
struct fsmonitor_settings *s = s_init(r);
60-
61-
if (check_for_incompatible(r))
62-
return;
24+
struct fsmonitor_settings *s = r->settings.fsmonitor;
6325

6426
s->mode = FSMONITOR_MODE_HOOK;
6527
s->hook_path = strdup(path);
6628
}
6729

6830
void fsm_settings__set_disabled(struct repository *r)
6931
{
70-
struct fsmonitor_settings *s = s_init(r);
32+
struct fsmonitor_settings *s = r->settings.fsmonitor;
7133

7234
s->mode = FSMONITOR_MODE_DISABLED;
73-
s->reason = FSMONITOR_REASON_ZERO;
7435
FREE_AND_NULL(s->hook_path);
7536
}
7637

@@ -104,6 +65,12 @@ static int check_for_hook(struct repository *r)
10465

10566
static void lookup_fsmonitor_settings(struct repository *r)
10667
{
68+
struct fsmonitor_settings *s;
69+
70+
CALLOC_ARRAY(s, 1);
71+
72+
r->settings.fsmonitor = s;
73+
10774
if (check_for_ipc(r))
10875
return;
10976

@@ -128,35 +95,3 @@ const char *fsm_settings__get_hook_path(struct repository *r)
12895

12996
return r->settings.fsmonitor->hook_path;
13097
}
131-
132-
static void create_reason_message(struct repository *r,
133-
struct strbuf *buf_reason)
134-
{
135-
struct fsmonitor_settings *s = r->settings.fsmonitor;
136-
137-
switch (s->reason) {
138-
case FSMONITOR_REASON_ZERO:
139-
return;
140-
141-
case FSMONITOR_REASON_BARE:
142-
strbuf_addstr(buf_reason,
143-
_("bare repos are incompatible with fsmonitor"));
144-
return;
145-
146-
default:
147-
BUG("Unhandled case in create_reason_message '%d'", s->reason);
148-
}
149-
}
150-
enum fsmonitor_reason fsm_settings__get_reason(struct repository *r,
151-
struct strbuf *buf_reason)
152-
{
153-
strbuf_reset(buf_reason);
154-
155-
if (!r->settings.fsmonitor)
156-
lookup_fsmonitor_settings(r);
157-
158-
if (r->settings.fsmonitor->mode == FSMONITOR_MODE_INCOMPATIBLE)
159-
create_reason_message(r, buf_reason);
160-
161-
return r->settings.fsmonitor->reason;
162-
}

fsmonitor-settings.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,17 @@
44
struct repository;
55

66
enum fsmonitor_mode {
7-
FSMONITOR_MODE_INCOMPATIBLE = -1, /* see _reason */
87
FSMONITOR_MODE_DISABLED = 0,
98
FSMONITOR_MODE_HOOK = 1, /* core.fsmonitor */
109
FSMONITOR_MODE_IPC = 2, /* core.useBuiltinFSMonitor */
1110
};
1211

13-
/*
14-
* Incompatibility reasons.
15-
*/
16-
enum fsmonitor_reason {
17-
FSMONITOR_REASON_ZERO = 0,
18-
FSMONITOR_REASON_BARE = 1,
19-
};
20-
2112
void fsm_settings__set_ipc(struct repository *r);
2213
void fsm_settings__set_hook(struct repository *r, const char *path);
2314
void fsm_settings__set_disabled(struct repository *r);
2415

2516
enum fsmonitor_mode fsm_settings__get_mode(struct repository *r);
2617
const char *fsm_settings__get_hook_path(struct repository *r);
27-
enum fsmonitor_reason fsm_settings__get_reason(struct repository *r,
28-
struct strbuf *buf_reason);
2918

3019
struct fsmonitor_settings;
3120

t/t7519-status-fsmonitor.sh

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,6 @@ test_lazy_prereq UNTRACKED_CACHE '
5555
test $ret -ne 1
5656
'
5757

58-
# Test that we detect and disallow repos that are incompatible with FSMonitor.
59-
test_expect_success 'incompatible bare repo' '
60-
test_when_finished "rm -rf ./bare-clone actual expect" &&
61-
git init --bare bare-clone &&
62-
cat >expect <<-\EOF &&
63-
error: bare repos are incompatible with fsmonitor
64-
EOF
65-
66-
test_must_fail \
67-
git -C ./bare-clone -c core.fsmonitor=foo \
68-
update-index --fsmonitor 2>actual &&
69-
test_cmp expect actual &&
70-
71-
test_must_fail \
72-
git -C ./bare-clone -c core.usebuiltinfsmonitor=true \
73-
update-index --fsmonitor 2>actual &&
74-
test_cmp expect actual
75-
'
76-
77-
test_expect_success FSMONITOR_DAEMON 'run fsmonitor-daemon in bare repo' '
78-
test_when_finished "rm -rf ./bare-clone actual" &&
79-
git init --bare bare-clone &&
80-
test_must_fail git -C ./bare-clone fsmonitor--daemon run 2>actual &&
81-
grep "bare repos are incompatible with fsmonitor" actual
82-
'
83-
8458
test_expect_success 'setup' '
8559
mkdir -p .git/hooks &&
8660
: >tracked &&

0 commit comments

Comments
 (0)