Skip to content

FSEvents infinite loop caused by git index writeback in lineChanges #842

Description

@pacificleo

What happened?

Upstream's new FSEvents file monitor watches the .git directory to trigger line-count updates dynamically. When a file change is detected, GitClient.lineChanges executes git diff HEAD --shortstat. However, because GIT_OPTIONAL_LOCKS=0 is not passed to the git invocation, git diff implicitly updates the .git/index cache. This index writeback triggers the FSEventStream again, creating an infinite background loop of file-system events and git diffs that drains the CPU and battery on large repositories.

Additionally, the O(N) lstat scan on large repositories is very slow, which can be fixed by passing -c core.fsmonitor=true.

Steps to reproduce

  1. Open Supacode in a Git repository.
  2. Make a file change.
  3. Observe that WorktreeFileEventMonitor triggers continuously in an infinite loop due to .git/index writebacks.

Supacode version and build

Latest main

macOS version

macOS 26.0+

System locale

en_US

Mac hardware

No response

Relevant logs or screenshots

No response

Are you planning to fix this yourself?

  • I intend to open a pull request once this is confirmed and marked ready.

Before submitting

  • I searched existing issues and this is not a duplicate.
  • I am on the latest available version of Supacode.
  • I understand pull requests are closed until the issue is marked ready.
  • I agree to follow this project's Code of Conduct.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions