git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t4130: work around Windows limitation
@ 2016-07-27 12:39 Johannes Schindelin
  2016-07-27 16:37 ` Johannes Sixt
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2016-07-27 12:39 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-08-04  5:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27 12:39 [PATCH] t4130: work around Windows limitation Johannes Schindelin
2016-07-27 16:37 ` Johannes Sixt
2016-07-27 16:40   ` Junio C Hamano
2016-07-30  8:11     ` Johannes Schindelin
2016-08-03  6:15       ` [PATCH v2] " Johannes Sixt
2016-08-03 12:03         ` Johannes Schindelin
2016-08-03 15:50         ` Junio C Hamano
2016-08-04  5:31           ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).