Skip to content

Commit 16d9d61

Browse files
jeffhostetlerdscho
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3248486 commit 16d9d61

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
/git-format-patch
7373
/git-fsck
7474
/git-fsck-objects
75+
/git-fsmonitor--daemon
7576
/git-gc
7677
/git-get-tar-commit-id
7778
/git-grep

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ BUILTIN_OBJS += builtin/fmt-merge-msg.o
11141114
BUILTIN_OBJS += builtin/for-each-ref.o
11151115
BUILTIN_OBJS += builtin/for-each-repo.o
11161116
BUILTIN_OBJS += builtin/fsck.o
1117+
BUILTIN_OBJS += builtin/fsmonitor--daemon.o
11171118
BUILTIN_OBJS += builtin/gc.o
11181119
BUILTIN_OBJS += builtin/get-tar-commit-id.o
11191120
BUILTIN_OBJS += builtin/grep.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix);
159159
int cmd_for_each_repo(int argc, const char **argv, const char *prefix);
160160
int cmd_format_patch(int argc, const char **argv, const char *prefix);
161161
int cmd_fsck(int argc, const char **argv, const char *prefix);
162+
int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix);
162163
int cmd_gc(int argc, const char **argv, const char *prefix);
163164
int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix);
164165
int cmd_grep(int argc, const char **argv, const char *prefix);

builtin/fsmonitor--daemon.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ static struct cmd_struct commands[] = {
537537
{ "format-patch", cmd_format_patch, RUN_SETUP },
538538
{ "fsck", cmd_fsck, RUN_SETUP },
539539
{ "fsck-objects", cmd_fsck, RUN_SETUP },
540+
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
540541
{ "gc", cmd_gc, RUN_SETUP },
541542
{ "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
542543
{ "grep", cmd_grep, RUN_SETUP_GENTLY },

0 commit comments

Comments
 (0)