Skip to content

worktree: Stop filtering low-frequency .git file events - #62980

Open
Ariestar wants to merge 1 commit into
zed-industries:mainfrom
Ariestar:fix/git-external-refs
Open

worktree: Stop filtering low-frequency .git file events#62980
Ariestar wants to merge 1 commit into
zed-industries:mainfrom
Ariestar:fix/git-external-refs

Conversation

@Ariestar

@Ariestar Ariestar commented Aug 21, 2026

Copy link
Copy Markdown

Problem

The git panel goes stale after git operations performed outside Zed (a terminal, an
agent tool, or a second Zed window). A common report: after git fetch / git pull
/ git commit in the terminal, the panel still shows old ahead/behind counts and
modified-file markers -- even clicking the panel's Fetch action does not update it.
No error is surfaced. See #61273, #60102, #60882.

Root cause

The worktree filters filesystem events inside .git directories, ignoring "noisy"
paths to avoid triggering unnecessary git rescans. That filtering included a
file-name denylist:

let skipped_file_names_in_dot_git =
    [COMMIT_MESSAGE, FETCH_HEAD, ORIG_HEAD, BISECT_LOG, GC_PID];

Every external git operation writes one of these files exactly once: FETCH_HEAD
(fetch/pull), ORIG_HEAD (reset/merge), COMMIT_EDITMSG (commit), BISECT_LOG
(bisect), gc.pid (gc). Because those events are dropped, the worktree never bumps
the repository's git_dir_scan_id, no UpdatedGitRepositories event is emitted, and
the git store never re-runs git status — so the panel stays stale indefinitely.
When a fetch brings no new refs, FETCH_HEAD is the only signal, so
refs-directory watches (#60660) do not cover this case.

Solution

Drop the file-name denylist entirely. Instead of maintaining a list of "which
low-frequency files are worth a rescan", treat every .git file event outside the
known high-frequency directories as worth one git-state check:

  • Removed the file-name denylist (COMMIT_EDITMSG, FETCH_HEAD, ORIG_HEAD,
    BISECT_LOG, gc.pid now all trigger a rescan).
  • Kept the directory-level filtering (objects/, logs/, fsmonitor-daemon/,
    lfs/, rebase-*, sequencer/) and the transient-file filtering (*.lock,
    single-level *.new / *.tmp). These are either written continuously during
    long-running git operations (fetch/gc), redundant with ref/index events, or
    necessary to avoid a rescan self-triggering loop (index.lock, see the existing
    comment in process_events).

This is safe against rescan storms by construction: the denylisted files are each
written once per git operation, and the existing snapshot diff
(git_dir_scan_id comparison) already suppresses UpdatedGitRepositories when git
state is unchanged.

Testing

  • test_noisy_dot_git_events_do_not_emit_git_repo_updateFETCH_HEAD,
    ORIG_HEAD, COMMIT_EDITMSG, BISECT_LOG, gc.pid now assert that events emit
    UpdatedGitRepositories; object writes, reflogs, lock files, rebase-* and
    sequencer/ events still do not.
  • All 21 git-related worktree tests pass, including the 100-seed random test
    test_random_git_updates_with_watcher_overflows.

Related issues

Release Notes:

  • Fixed git panel not refreshing after git fetch / git pull / git commit
    performed outside Zed.

@cla-bot

cla-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Ariestar on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Aug 21, 2026
@maxdeviant maxdeviant changed the title fix(worktree): honor FETCH_HEAD events from external git operations worktree: Honor FETCH_HEAD events from external git operations Aug 21, 2026
@zed-industries-bot

zed-industries-bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️
worktree: stop filtering low-frequency .git file events
          ^

Write PR titles using sentence case.

Have feedback on this plugin? Let's hear it!

Generated by 🚫 dangerJS against debb739

@Ariestar
Ariestar force-pushed the fix/git-external-refs branch from 74b2d07 to debb739 Compare August 21, 2026 04:48
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 21, 2026
@Ariestar Ariestar changed the title worktree: Honor FETCH_HEAD events from external git operations worktree: stop filtering low-frequency .git file events Aug 21, 2026
@SomeoneToIgnore SomeoneToIgnore added area:scanning Worktree scanning related PRs. area:integrations/git Git integration feedback labels Aug 21, 2026
@Ariestar
Ariestar force-pushed the fix/git-external-refs branch from debb739 to e9b519b Compare August 21, 2026 13:24
@Ariestar Ariestar changed the title worktree: stop filtering low-frequency .git file events worktree: Stop filtering low-frequency .git file events Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:integrations/git Git integration feedback area:scanning Worktree scanning related PRs. cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Git panel Push status out of sync with repository even after triggering Fetch from Zed

3 participants