]> git.ipfire.org Git - thirdparty/git.git/commitdiff
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)
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

index bf0f67378dbb239075650dd7b8bff78b4374cf9a..8a91ff3603ff9281f77a7a35c654c91808ec45e4 100755 (executable)
@@ -647,21 +647,21 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlinks without unstaged ch
 '
 
 write_script modify-right-file <<\EOF
-echo "new content" >"$2/file"
+echo "modified content" >"$2/file"
 EOF
 
 run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
        test_when_finished git reset --hard &&
        echo "orig content" >file &&
        git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
-       echo "new content" >expect &&
+       echo "modified content" >expect &&
        test_cmp expect file
 '
 
 run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
        test_when_finished git reset --hard &&
        git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
-       echo "new content" >expect &&
+       echo "modified content" >expect &&
        test_cmp expect file
 '