fsmonitor: deal with synthetic firmlinks on macOS
Starting with macOS 10.15 (Catalina), Apple introduced a new feature called 'firmlinks' in order to separate the boot volume into two volumes, one read-only and one writable but still present them to the user as a single volume. Along with this change, Apple removed the ability to create symlinks in the root directory and replaced them with 'synthetic firmlinks'. See 'man synthetic.conf' When FSEevents reports the path of changed files, if the path involves a synthetic firmlink, the path is reported from the point of the synthetic firmlink and not the real path. For example: Real path: /System/Volumes/Data/network/working/directory/foo.txt Synthetic firmlink: /network -> /System/Volumes/Data/network FSEvents path: /network/working/directory/foo.txt This causes the FSEvents path to not match against the worktree directory. There are several ways in which synthetic firmlinks can be created: they can be defined in /etc/synthetic.conf, the automounter can create them, and there may be other means. Simply reading /etc/synthetic.conf is insufficient. No matter what process creates synthetic firmlinks, they all get created in the root directory. Therefore, in order to deal with synthetic firmlinks, the root directory is scanned and the first possible synthetic firmink that, when resolved, is a prefix of the worktree is used to map FSEvents paths to worktree paths. Signed-off-by: Eric DeCosta <edecosta@mathworks.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8f44976882
commit
12fd27df79
@ -3,6 +3,7 @@
|
||||
#include "parse-options.h"
|
||||
#include "fsmonitor.h"
|
||||
#include "fsmonitor-ipc.h"
|
||||
#include "fsmonitor-path-utils.h"
|
||||
#include "compat/fsmonitor/fsm-health.h"
|
||||
#include "compat/fsmonitor/fsm-listen.h"
|
||||
#include "fsmonitor--daemon.h"
|
||||
@ -1282,6 +1283,11 @@ static int fsmonitor_run_daemon(void)
|
||||
strbuf_addstr(&state.path_worktree_watch, absolute_path(get_git_work_tree()));
|
||||
state.nr_paths_watching = 1;
|
||||
|
||||
strbuf_init(&state.alias.alias, 0);
|
||||
strbuf_init(&state.alias.points_to, 0);
|
||||
if ((err = fsmonitor__get_alias(state.path_worktree_watch.buf, &state.alias)))
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* We create and delete cookie files somewhere inside the .git
|
||||
* directory to help us keep sync with the file system. If
|
||||
@ -1391,6 +1397,8 @@ done:
|
||||
strbuf_release(&state.path_gitdir_watch);
|
||||
strbuf_release(&state.path_cookie_prefix);
|
||||
strbuf_release(&state.path_ipc);
|
||||
strbuf_release(&state.alias.alias);
|
||||
strbuf_release(&state.alias.points_to);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user