Skip to content

Commit c92b348

Browse files
jeffhostetlerdscho
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]>
1 parent d8f3684 commit c92b348

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-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
@@ -1098,6 +1098,7 @@ BUILTIN_OBJS += builtin/fmt-merge-msg.o
10981098
BUILTIN_OBJS += builtin/for-each-ref.o
10991099
BUILTIN_OBJS += builtin/for-each-repo.o
11001100
BUILTIN_OBJS += builtin/fsck.o
1101+
BUILTIN_OBJS += builtin/fsmonitor--daemon.o
11011102
BUILTIN_OBJS += builtin/gc.o
11021103
BUILTIN_OBJS += builtin/get-tar-commit-id.o
11031104
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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
if (argc < 2)
24+
usage_with_options(builtin_fsmonitor__daemon_usage, options);
25+
26+
if (argc == 2 && !strcmp(argv[1], "-h"))
27+
usage_with_options(builtin_fsmonitor__daemon_usage, options);
28+
29+
git_config(git_default_config, NULL);
30+
31+
subcmd = argv[1];
32+
argv--;
33+
argc++;
34+
35+
argc = parse_options(argc, argv, prefix, options,
36+
builtin_fsmonitor__daemon_usage, 0);
37+
38+
die(_("Unhandled subcommand '%s'"), subcmd);
39+
}
40+
41+
#else
42+
int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
43+
{
44+
struct option options[] = {
45+
OPT_END()
46+
};
47+
48+
if (argc == 2 && !strcmp(argv[1], "-h"))
49+
usage_with_options(builtin_fsmonitor__daemon_usage, options);
50+
51+
die(_("fsmonitor--daemon not supported on this platform"));
52+
}
53+
#endif

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ static struct cmd_struct commands[] = {
533533
{ "format-patch", cmd_format_patch, RUN_SETUP },
534534
{ "fsck", cmd_fsck, RUN_SETUP },
535535
{ "fsck-objects", cmd_fsck, RUN_SETUP },
536+
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
536537
{ "gc", cmd_gc, RUN_SETUP },
537538
{ "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
538539
{ "grep", cmd_grep, RUN_SETUP_GENTLY },

0 commit comments

Comments
 (0)