Skip to content

Commit 142c518

Browse files
committed
fsmonitor/darwin: fix hangs for submodules
fsmonitor_classify_path_absolute() expects state->path_gitdir_watch.buf has no trailing '/' or '.' For a submodule, fsmonitor_run_daemon() sets the value with trailing "/." (as repo_get_git_dir(the_repository) on darwin returns ".") so that fsmonitor_classify_path_absolute() returns IS_OUTSIDE_CONE. In this case, fsevent_callback() doesn't update cookie_list so that fsmonitor_publish() does nothing and with_lock__mark_cookies_seen() is not invoked. As with_lock__wait_for_cookie() infinitely waits for state->cookies_cond that with_lock__mark_cookies_seen() should unlock, the whole daemon hangs. Remove trailing "/." from state->path_gitdir_watch.buf for submodules. Signed-off-by: Koji Nakamaru <[email protected]>
1 parent 3857aae commit 142c518

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin/fsmonitor--daemon.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,9 +1311,15 @@ static int fsmonitor_run_daemon(void)
13111311
strbuf_addbuf(&state.path_gitdir_watch, &state.path_worktree_watch);
13121312
strbuf_addstr(&state.path_gitdir_watch, "/.git");
13131313
if (!is_directory(state.path_gitdir_watch.buf)) {
1314+
char *buf;
1315+
int len;
13141316
strbuf_reset(&state.path_gitdir_watch);
13151317
strbuf_addstr(&state.path_gitdir_watch,
13161318
absolute_path(repo_get_git_dir(the_repository)));
1319+
buf = state.path_gitdir_watch.buf;
1320+
len = state.path_gitdir_watch.len;
1321+
if (len >= 2 && buf[len - 2] == '/' && buf[len - 1] == '.')
1322+
strbuf_setlen(&state.path_gitdir_watch, len - 2);
13171323
state.nr_paths_watching = 2;
13181324
}
13191325

0 commit comments

Comments
 (0)