fsmonitor--daemon: add a built-in fsmonitor daemon
Create a built-in file system monitoring daemon that can be used by the existing `fsmonitor` feature (protocol API and index extension) to improve the performance of various Git commands, such as `status`. The `fsmonitor--daemon` feature builds upon the `Simple IPC` API and provides an alternative to hook access to existing fsmonitors such as `watchman`. This commit merely adds the new command without any functionality. Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Mar 25, 2022 at 18:02 UTC
16d9d6175b53ca6197831da78ca8fb0dedb961b6
5 files changed
+50
.gitignore
+1
@@ -72,6 +72,7 @@
72
/git-format-patch
73
/git-fsck
74
/git-fsck-objects
75
+/git-fsmonitor--daemon
76
/git-gc
77
/git-get-tar-commit-id
78
/git-grep
Makefile
+1
@@ -1114,6 +1114,7 @@ BUILTIN_OBJS += builtin/fmt-merge-msg.o
1114
BUILTIN_OBJS += builtin/for-each-ref.o
1115
BUILTIN_OBJS += builtin/for-each-repo.o
1116
BUILTIN_OBJS += builtin/fsck.o
1117
+BUILTIN_OBJS += builtin/fsmonitor--daemon.o
1118
BUILTIN_OBJS += builtin/gc.o
1119
BUILTIN_OBJS += builtin/get-tar-commit-id.o
1120
BUILTIN_OBJS += builtin/grep.o
builtin.h
+1
@@ -159,6 +159,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix);
159
int cmd_for_each_repo(int argc, const char **argv, const char *prefix);
160
int cmd_format_patch(int argc, const char **argv, const char *prefix);
161
int cmd_fsck(int argc, const char **argv, const char *prefix);
162
+int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix);
163
int cmd_gc(int argc, const char **argv, const char *prefix);
164
int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix);
165
int cmd_grep(int argc, const char **argv, const char *prefix);
builtin/fsmonitor--daemon.c
new
+46
@@ -0,0 +1,46 @@
1
+#include "builtin.h"
2
+#include "config.h"
3
+#include "parse-options.h"
4
+#include "fsmonitor.h"
5
+#include "fsmonitor-ipc.h"
6
+#include "simple-ipc.h"
7
+#include "khash.h"
8
+
9
+static const char * const builtin_fsmonitor__daemon_usage[] = {
10
+ NULL
11
+};
12
+
13
+#ifdef HAVE_FSMONITOR_DAEMON_BACKEND
14
+
15
+int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
16
+{
17
+ const char *subcmd;
18
+
19
+ struct option options[] = {
20
+ OPT_END()
21
+ };
22
+
23
+ git_config(git_default_config, NULL);
24
+
25
+ argc = parse_options(argc, argv, prefix, options,
26
+ builtin_fsmonitor__daemon_usage, 0);
27
+ if (argc != 1)
28
+ usage_with_options(builtin_fsmonitor__daemon_usage, options);
29
+ subcmd = argv[0];
30
+
31
+ die(_("Unhandled subcommand '%s'"), subcmd);
32
+}
33
+
34
+#else
35
+int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
36
+{
37
+ struct option options[] = {
38
+ OPT_END()
39
+ };
40
+
41
+ if (argc == 2 && !strcmp(argv[1], "-h"))
42
+ usage_with_options(builtin_fsmonitor__daemon_usage, options);
43
+
44
+ die(_("fsmonitor--daemon not supported on this platform"));
45
+}
46
+#endif
git.c
+1
@@ -537,6 +537,7 @@ static struct cmd_struct commands[] = {
537
{ "format-patch", cmd_format_patch, RUN_SETUP },
538
{ "fsck", cmd_fsck, RUN_SETUP },
539
{ "fsck-objects", cmd_fsck, RUN_SETUP },
540
+ { "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
541
{ "gc", cmd_gc, RUN_SETUP },
542
{ "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
543
{ "grep", cmd_grep, RUN_SETUP_GENTLY },