Skip to content

Commit 4725384

Browse files
jeffhostetlerdscho
authored andcommitted
fsmonitor--daemon: print start message only if fsmonitor.announceStartup
Teach fsmonitor--daemon to print a startup message only when `fsmonitor.announceStartup` is true. This setting is false by default so that the output of client commands, like `git status`, is not changed if the daemon is implicitly started. The message is conditionally printed by "run" and "start" subcommands and is sent to stderr. It contains the path to the work tree root. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent a8ea9c3 commit 4725384

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

builtin/fsmonitor--daemon.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ static int fsmonitor__ipc_threads = 8;
2727
#define FSMONITOR__START_TIMEOUT "fsmonitor.starttimeout"
2828
static int fsmonitor__start_timeout_sec = 60;
2929

30+
#define FSMONITOR__ANNOUNCE_STARTUP "fsmonitor.announcestartup"
31+
static int fsmonitor__announce_startup = 0;
32+
3033
static int fsmonitor_config(const char *var, const char *value, void *cb)
3134
{
3235
if (!strcmp(var, FSMONITOR__IPC_THREADS)) {
@@ -47,6 +50,16 @@ static int fsmonitor_config(const char *var, const char *value, void *cb)
4750
return 0;
4851
}
4952

53+
if (!strcmp(var, FSMONITOR__ANNOUNCE_STARTUP)) {
54+
int is_bool;
55+
int i = git_config_bool_or_int(var, value, &is_bool);
56+
if (i < 0)
57+
return error(_("value of '%s' not bool or int: %d"),
58+
var, i);
59+
fsmonitor__announce_startup = i;
60+
return 0;
61+
}
62+
5063
return git_default_config(var, value, cb);
5164
}
5265

@@ -1307,9 +1320,11 @@ static int try_to_run_foreground_daemon(int free_console)
13071320
die("fsmonitor--daemon is already running '%s'",
13081321
the_repository->worktree);
13091322

1310-
printf(_("running fsmonitor-daemon in '%s'\n"),
1311-
the_repository->worktree);
1312-
fflush(stdout);
1323+
if (fsmonitor__announce_startup) {
1324+
fprintf(stderr, _("running fsmonitor-daemon in '%s'\n"),
1325+
the_repository->worktree);
1326+
fflush(stderr);
1327+
}
13131328

13141329
#ifdef GIT_WINDOWS_NATIVE
13151330
if (free_console)
@@ -1360,9 +1375,11 @@ static int try_to_start_background_daemon(void)
13601375
die("fsmonitor--daemon is already running '%s'",
13611376
the_repository->worktree);
13621377

1363-
printf(_("starting fsmonitor-daemon in '%s'\n"),
1364-
the_repository->worktree);
1365-
fflush(stdout);
1378+
if (fsmonitor__announce_startup) {
1379+
fprintf(stderr, _("starting fsmonitor-daemon in '%s'\n"),
1380+
the_repository->worktree);
1381+
fflush(stderr);
1382+
}
13661383

13671384
cp.git_cmd = 1;
13681385

0 commit comments

Comments
 (0)