Skip to content

Conversation

@claude
Copy link
Contributor

@claude claude bot commented Jan 7, 2026

Problem

The test_list_full_working_tree_conflicts test was failing on macOS in CI (run 20766920768).

The test expected to see !✗ (modified + conflict) in the status column, but was seeing (behind) instead. This happened because git's index cache wasn't detecting the file modification, even with the 10ms sleep added in commit ca0d27f.

Root Cause

Git uses mtime comparisons to detect file changes for performance. When a file is written and then git status is called very quickly:

  • If the mtime hasn't changed (same timestamp resolution window)
  • Git's index cache assumes the file hasn't changed
  • The working tree modification goes undetected

The 10ms sleep was insufficient on macOS CI runners because:

  1. Filesystem time resolution can vary
  2. Sleep duration isn't guaranteed
  3. Even with proper timing, mtime-based detection is inherently racy

Solution

Replace the sleep with an explicit git update-index --refresh call after the file write. This forces git to immediately re-scan the working tree and detect the modification, regardless of mtime values.

This is the standard git pattern for ensuring index consistency in tests.

Testing

  • ✅ Test passes locally on Linux
  • Waiting for macOS CI to verify the fix

Related

  • Fixes CI failure from commit 928b301
  • Improves on the sleep-based fix from commit ca0d27f

🤖 This is an automated fix for human review

The previous fix attempted to address git index cache issues on macOS by
adding a 10ms sleep after file writes. However, this was insufficient as
git's mtime-based caching can still miss changes even with the delay,
especially on fast filesystems.

This commit replaces the sleep with an explicit `git update-index --refresh`
call, which forces git to immediately re-scan the working tree and detect
the file modification. This is more reliable than relying on timing and
filesystem characteristics.

Fixes CI failure from commit 928b301 where test_list_full_working_tree_conflicts
was flaky on macOS, sometimes showing `↓` (behind) instead of `!✗` (modified
+ conflict) because git hadn't detected the working tree change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@max-sixty max-sixty merged commit 84dbe7f into main Jan 7, 2026
19 checks passed
@max-sixty max-sixty deleted the fix/ci-git-index-refresh-macos branch January 7, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants