path: root/entry.c
diff options
authorJohannes Sixt <>2009-04-20 08:17:00 (GMT)
committerJunio C Hamano <>2009-04-20 19:14:02 (GMT)
commit34779c535c4e121414197ab08b4b502a22a75433 (patch)
treed856d59cbc54cbb7a79c5d22abc0d31bf93acd0c /entry.c
parent6ac6f87818edfd33fea8ce3c95b47fe00a4e4b91 (diff)
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." ( 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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'entry.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/entry.c b/entry.c
index 5daacc2..915514a 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;