@matheusbsbs / matheus-bagliano / commits / 5bcf109cdf
Fork 0

checkout bugfix: use stat.mtime instead of stat.ctime in two places

Commit e1afca4fd "write_index(): update index_state->timestamp after flushing to disk" on 2009-02-23 used stat.ctime to record the timestamp of the index-file. This is wrong, so fix this and use the correct stat.mtime timestamp instead. Commit 110c46a909 "Not all systems use st_[cm]tim field for ns resolution file timestamp" on 2009-03-08, has a similar bug for the builtin-fetch-pack.c file. Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kjetil Barvik committed Mar 15, 2009 at 12:38 UTC 5bcf109cdf7f7b676600883be8dc7dbf26ddb055
2 files changed +3 -3
builtin-fetch-pack.c
+1 -1
@@ -807,7 +807,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
807 die("shallow file was removed during fetch");
808 } else if (st.st_mtime != mtime.sec
809 #ifdef USE_NSEC
810 - || ST_CTIME_NSEC(st) != mtime.nsec
810 + || ST_MTIME_NSEC(st) != mtime.nsec
811 #endif
812 )
813 die("shallow file was changed during fetch");
read-cache.c
+2 -2
@@ -1563,8 +1563,8 @@ int write_index(struct index_state *istate, int newfd)
1563
1564 if (ce_flush(&c, newfd) || fstat(newfd, &st))
1565 return -1;
1566 - istate->timestamp.sec = (unsigned int)st.st_ctime;
1567 - istate->timestamp.nsec = ST_CTIME_NSEC(st);
1566 + istate->timestamp.sec = (unsigned int)st.st_mtime;
1567 + istate->timestamp.nsec = ST_MTIME_NSEC(st);
1568 return 0;
1569 }
1570