git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t4130: work around Windows limitation

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 27, 2016, 12:39 UTC
Message-ID
<5bd59ca2f87e388350f3c8fb17c9a287661cd055.1469623136.git.johannes.schindelin@gmx.de>

On Windows, it is already pretty expensive to try to recreate the stat() data that Git assumes is cheap to obtain. To make things halfway decent in performance, we even have to skip emulating the inode and to determine the number of hard links.

This is not a huge problem, usually, as either the size or the mtime or the ctime are tell-tale enough to say when a file has changed, and even if not, those changes are typically made after the index file was written, triggering a rehashing of the files' contents.

The t4130-apply-criss-cross-rename test case, however, requires the inode to determine that files of equal size were swapped, as renaming files does not update their mtime. And even if we use nanosecond-precision mtimes on Windows, the file system's time granularity is typically much coarser (100ms for NTFS, 2s for FAT).

That means that every once in a while, t4130 fails on Windows.

This patch provides the work-around by pretending that the index file was written earlier than it actually was.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/git/releases/tag/t4130-mingw-v1
 t/t4130-apply-criss-cross-rename.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/t/t4130-apply-criss-cross-rename.sh b/t/t4130-apply-criss-cross-rename.sh
index d173acd..ee91af8 100755
--- a/t/t4130-apply-criss-cross-rename.sh
+++ b/t/t4130-apply-criss-cross-rename.sh
@@ -29,6 +29,14 @@ test_expect_success 'criss-cross rename' '
 '
 
 test_expect_success 'diff -M -B' '
+	if test_have_prereq MINGW
+	then
+		# On Windows it is prohbitively expensive to retrieve the
+		# equivalent of an "inode" when calling stat(), therefore we
+		# rely on mtime/ctime/size changes to let us know whether a
+		# file has changed, including the mtime relative to the index.
+		test-chmtime -1 .git/index
+	fi &&
 	git diff -M -B > diff &&
 	git reset --hard
 
@@ -52,6 +60,14 @@ test_expect_success 'criss-cross rename' '
 '
 
 test_expect_success 'diff -M -B' '
+	if test_have_prereq MINGW
+	then
+		# On Windows it is prohbitively expensive to retrieve the
+		# equivalent of an "inode" when calling stat(), therefore we
+		# rely on mtime/ctime/size changes to let us know whether a
+		# file has changed, including the mtime relative to the index.
+		test-chmtime -1 .git/index
+	fi &&
 	git diff -M -B > diff &&
 	git reset --hard
 '
-- 
2.9.0.281.g286a8d9

base-commit: 8c6d1f9807c67532e7fb545a944b064faff0f70b
Next: Johannes Sixt
Message 1 of 8 in “t4130: work around Windows limitation”
  1. t4130: work around Windows limitationJohannes Schindelin, Jul 27, 2016
  2. Johannes SixtJul 27, 2016
  3. Junio C HamanoJul 27, 2016
  4. Johannes SchindelinJul 30, 2016
  5. t4130: work around Windows limitationJohannes Sixt, Aug 3, 2016
  6. Johannes SchindelinAug 3, 2016
  7. Junio C HamanoAug 3, 2016
  8. Johannes SixtAug 4, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.