Skip to content

jj git clone --colocate hangs forever on macOS if the built-in git macOS fsmonitor is enabled in the global or user .gitconfig #6440

@dljsjr

Description

@dljsjr

Description

This isn't necessarily an issue with JJ itself, but rather, an edge case in git that JJ is hitting because of the operations that it uses to create a colocated repo. I don't actually understand why, though.

You can see this by performing the git clone operations by hand:

$ git config set --global core.fsmonitor true

$ git clone --no-checkout git@github.com:tim-janik/jj-fzf.git
Cloning into 'jj-fzf'...
remote: Enumerating objects: 1525, done.
remote: Counting objects: 100% (276/276), done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 1525 (delta 264), reused 207 (delta 202), pack-reused 1249 (from 2)
Receiving objects: 100% (1525/1525), 307.26 KiB | 2.77 MiB/s, done.
Resolving deltas: 100% (922/922), done.

# here is where we replicate the JJ fetch being done as part of the colocated clone.
# i've set GIT_TRACE to show where the hang happens relevant to the fsmonitor

$ LC_ALL=C GIT_TRACE=1 /usr/local/bin/git --git-dir /Users/dougstephen/git/jj-fzf/.git fetch --verbose --prune --no-write-fetch-head --progress -- origin '+refs/heads/*:refs/remotes/origin/*'
11:08:59.850406 git.c:476               trace: built-in: git fetch --verbose --prune --no-write-fetch-head --progress -- origin '+refs/heads/*:refs/remotes/origin/*'
11:08:59.851538 run-command.c:667       trace: run_command: git fsmonitor--daemon start
11:08:59.851564 run-command.c:759       trace: start_command: /usr/local/opt/git/libexec/git-core/git fsmonitor--daemon start
11:08:59.861526 git.c:476               trace: built-in: git fsmonitor--daemon start
11:08:59.862760 run-command.c:667       trace: run_command: git fsmonitor--daemon run --detach --ipc-threads=8
11:08:59.862785 run-command.c:759       trace: start_command: /usr/local/opt/git/libexec/git-core/git fsmonitor--daemon run --detach --ipc-threads=8

# Ctrl-C

$ rm -rf jj-fzf

# disabling fsmonitor fixes this, though

$ git config set --global core.fsmonitor false

$ git clone --no-checkout git@github.com:tim-janik/jj-fzf.git
Cloning into 'jj-fzf'...
remote: Enumerating objects: 1525, done.
remote: Counting objects: 100% (276/276), done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 1525 (delta 264), reused 207 (delta 202), pack-reused 1249 (from 2)
Receiving objects: 100% (1525/1525), 307.26 KiB | 3.30 MiB/s, done.
Resolving deltas: 100% (922/922), done.

$ LC_ALL=C GIT_TRACE=1 /usr/local/bin/git --git-dir /Users/dougstephen/git/jj-fzf/.git fetch --verbose --prune --no-write-fetch-head --progress -- origin '+refs/heads/*:refs/remotes/origin/*'
11:10:40.163795 git.c:476               trace: built-in: git fetch --verbose --prune --no-write-fetch-head --progress -- origin '+refs/heads/*:refs/remotes/origin/*'
11:10:40.168012 run-command.c:667       trace: run_command: unset GIT_DIR GIT_PREFIX; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL git@github.com 'git-upload-pack '\''tim-janik/jj-fzf.git'\'''
11:10:40.168105 run-command.c:759       trace: start_command: /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com 'git-upload-pack '\''tim-janik/jj-fzf.git'\'''
11:10:40.397812 run-command.c:667       trace: run_command: git rev-list --objects --stdin --not --exclude-hidden=fetch --all --quiet --alternate-refs
11:10:40.397869 run-command.c:759       trace: start_command: /usr/local/opt/git/libexec/git-core/git rev-list --objects --stdin --not --exclude-hidden=fetch --all --quiet --alternate-refs
From github.com:tim-janik/jj-fzf
 = [up to date]      jj_change_id -> origin/jj_change_id
 = [up to date]      next         -> origin/next
 = [up to date]      trunk        -> origin/trunk
11:10:40.455224 run-command.c:1535      run_processes_parallel: preparing to run up to 1 tasks
11:10:40.455271 run-command.c:1562      run_processes_parallel: done
11:10:40.455294 run-command.c:667       trace: run_command: git maintenance run --auto --no-quiet --detach
11:10:40.455354 run-command.c:759       trace: start_command: /usr/local/opt/git/libexec/git-core/git maintenance run --auto --no-quiet --detach
11:10:40.466861 git.c:476               trace: built-in: git maintenance run --auto --no-quiet --detach

This is specific to macOS since the fsmonitor--daemon executable only works there; this isn't a problem with git's watchman hook on Linux since, well, the hook has to be established first.

Again, I'm not sure exactly what's going on here. It's something about that fetch command.

Steps to Reproduce the Problem

  1. Install jj on macOS
  2. Enable the fsmonitor feature in the global or system gitconfig
  3. Run jj git clone --colocate

Expected Behavior

A git repo should be cloned and then a JJ repo should be colocated in the git repo

Actual Behavior

The command hangs forever

Specifications

  • Platform: macOS
  • Version: git >= 2.37.0, jj 0.28.2-b9ebe2f03c976515d2a155a411a368ae773c5493

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions