aboutsummaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2009-04-20 10:17:00 +0200
committerJunio C Hamano <gitster@pobox.com>2009-04-20 12:14:02 -0700
commit34779c535c4e121414197ab08b4b502a22a75433 (patch)
treed856d59cbc54cbb7a79c5d22abc0d31bf93acd0c /entry.c
parent6ac6f87818edfd33fea8ce3c95b47fe00a4e4b91 (diff)
downloadgit-34779c535c4e121414197ab08b4b502a22a75433.tar.gz
git-34779c535c4e121414197ab08b4b502a22a75433.tar.xz
Windows: Skip fstat/lstat optimization in write_entry()
Commit e4c72923 (write_entry(): use fstat() instead of lstat() when file is open, 2009-02-09) introduced an optimization of write_entry(). Unfortunately, we cannot take advantage of this optimization on Windows because there is no guarantee that the time stamps are updated before the file is closed: "The only guarantee about a file timestamp is that the file time is correctly reflected when the handle that makes the change is closed." (http://msdn.microsoft.com/en-us/library/ms724290(VS.85).aspx) The failure of this optimization on Windows can be observed most easily by running a 'git checkout' that has to update several large files. In this case, 'git checkout' will report modified files, but infact only the timestamps were incorrectly recorded in the index, as can be verified by a subsequent 'git diff', which shows no change. Dmitry Potapov reports the same fix needs on Cygwin; this commit contains his updates for that. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/entry.c b/entry.c
index 5daacc2fe..915514aa5 100644
--- a/entry.c
+++ b/entry.c
@@ -147,7 +147,8 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
wrote = write_in_full(fd, new, size);
/* use fstat() only when path == ce->name */
- if (state->refresh_cache && !to_tempfile && !state->base_dir_len) {
+ if (fstat_is_reliable() &&
+ state->refresh_cache && !to_tempfile && !state->base_dir_len) {
fstat(fd, &st);
fstat_done = 1;
}