git/fsmonitor-settings.c

#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
#include "repository.h"
#include "fsmonitor-ipc.h"
#include "fsmonitor-settings.h"
#include "fsmonitor-path-utils.h"

/*
 * We keep this structure definition private and have getters
 * for all fields so that we can lazy load it as needed.
 */
struct fsmonitor_settings {};

/*
 * Remote working directories are problematic for FSMonitor.
 *
 * The underlying file system on the server machine and/or the remote
 * mount type dictates whether notification events are available at
 * all to remote client machines.
 *
 * Kernel differences between the server and client machines also
 * dictate the how (buffering, frequency, de-dup) the events are
 * delivered to client machine processes.
 *
 * A client machine (such as a laptop) may choose to suspend/resume
 * and it is unclear (without lots of testing) whether the watcher can
 * resync after a resume.  We might be able to treat this as a normal
 * "events were dropped by the kernel" event and do our normal "flush
 * and resync" --or-- we might need to close the existing (zombie?)
 * notification fd and create a new one.
 *
 * In theory, the above issues need to be addressed whether we are
 * using the Hook or IPC API.
 *
 * So (for now at least), mark remote working directories as
 * incompatible unless 'fsmonitor.allowRemote' is true.
 *
 */
#ifdef HAVE_FSMONITOR_OS_SETTINGS
static enum fsmonitor_reason check_remote(struct repository *r)
{
	int allow_remote = -1; /* -1 unset, 0 not allowed, 1 allowed */
	int is_remote = fsmonitor__is_fs_remote(r->worktree);

	switch (is_remote) {
		case 0:
			return FSMONITOR_REASON_OK;
		case 1:
			repo_config_get_bool(r, "fsmonitor.allowremote", &allow_remote);
			if (allow_remote < 1)
				return FSMONITOR_REASON_REMOTE;
			else
				return FSMONITOR_REASON_OK;
		default:
			return FSMONITOR_REASON_ERROR;
	}
}
#endif

static enum fsmonitor_reason check_for_incompatible(struct repository *r,
						    int ipc MAYBE_UNUSED)
{}

static struct fsmonitor_settings *alloc_settings(void)
{}

static void lookup_fsmonitor_settings(struct repository *r)
{}

enum fsmonitor_mode fsm_settings__get_mode(struct repository *r)
{}

const char *fsm_settings__get_hook_path(struct repository *r)
{}

void fsm_settings__set_ipc(struct repository *r)
{}

void fsm_settings__set_hook(struct repository *r, const char *path)
{}

void fsm_settings__set_disabled(struct repository *r)
{}

void fsm_settings__set_incompatible(struct repository *r,
				    enum fsmonitor_reason reason)
{}

enum fsmonitor_reason fsm_settings__get_reason(struct repository *r)
{}

char *fsm_settings__get_incompatible_msg(struct repository *r,
					 enum fsmonitor_reason reason)
{}