Skip to content

Commit 0b495cd

Browse files
ptarjangitster
authored andcommitted
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: git-for-windows#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>
1 parent 68cb7f9 commit 0b495cd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

t/t7800-difftool.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,21 +647,21 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlinks without unstaged ch
647647
'
648648

649649
write_script modify-right-file <<\EOF
650-
echo "new content" >"$2/file"
650+
echo "modified content" >"$2/file"
651651
EOF
652652

653653
run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
654654
test_when_finished git reset --hard &&
655655
echo "orig content" >file &&
656656
git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
657-
echo "new content" >expect &&
657+
echo "modified content" >expect &&
658658
test_cmp expect file
659659
'
660660

661661
run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
662662
test_when_finished git reset --hard &&
663663
git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
664-
echo "new content" >expect &&
664+
echo "modified content" >expect &&
665665
test_cmp expect file
666666
'
667667

0 commit comments

Comments
 (0)