]> git.ipfire.org Git - thirdparty/git.git/commit
t7800: fix racy "difftool --dir-diff syncs worktree" test
authorPaul Tarjan <github@paulisageek.com>
Sat, 3 Jan 2026 20:40:09 +0000 (20:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 4 Jan 2026 02:28:14 +0000 (11:28 +0900)
commit0b495cd390ec39045542f6fcae53ce64264301b7
tree335dba040fe1456973fe019f3134d3da6804b2cc
parent68cb7f9e92a5d8e9824f5b52ac3d0a9d8f653dbe
t7800: fix racy "difftool --dir-diff syncs worktree" test

The "difftool --dir-diff syncs worktree without unstaged change" test
fails intermittently on Windows CI, as seen at:

  https://github.com/git/git/actions/runs/20624095002/job/59231745784#step:5:416

The root cause is that the original file content and the replacement
content have identical sizes:

  - Original: "main\ntest\na\n" = 12 bytes
  - New:      "new content\n"   = 12 bytes

When difftool's sync-back mechanism checks for changes, it compares
stat data between the temporary index and the modified files. If the
modification happens within the same timestamp granularity window and
file size stays the same, the change goes undetected.

On Windows, this is more likely to manifest because Git relies on
inode changes as a fallback when other stat fields match, but Windows
filesystems lack inodes. This is a real bug that could affect users
scripting difftool similarly, as seen at:

  https://github.com/git-for-windows/git/issues/5132

Fix the test by changing the replacement content to "modified content"
(17 bytes), ensuring the size difference is detected regardless of
timestamp resolution or platform-specific stat behavior.

Note: This fixes the test flakiness but not the underlying issue in
difftool's change detection. Other tests with same-size file patterns
(t0010-racy-git.sh, t2200-add-update.sh) are not affected because they
use normal index operations with proper racy-git detection.

Signed-off-by: Paul Tarjan <github@paulisageek.com>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7800-difftool.sh