aboutsummaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorKjetil Barvik <barvik@broadpark.no>2009-03-04 18:47:40 +0100
committerJunio C Hamano <gitster@pobox.com>2009-03-07 20:25:16 -0800
commitc06ff4908bf9ad8bf2448439a3574321c9399b17 (patch)
tree269f1fcbb4c60ceeccdc4dcf1f270d1f3f72d977 /read-cache.c
parente1afca4fd3e7cb4000874e991277f10119de4ad2 (diff)
downloadgit-c06ff4908bf9ad8bf2448439a3574321c9399b17.tar.gz
git-c06ff4908bf9ad8bf2448439a3574321c9399b17.tar.xz
Record ns-timestamps if possible, but do not use it without USE_NSEC
Traditionally, the lack of USE_NSEC meant "do not record nor use the nanosecond resolution part of the file timestamps". To avoid problems on filesystems that lose the ns part when the metadata is flushed to the disk and then later read back in, disabling USE_NSEC has been a good idea in general. If you are on a filesystem without such an issue, it does not hurt to read and store them in the cached stat data in the index entries even if your git is compiled without USE_NSEC. The index left with such a version of git can be read by git compiled with USE_NSEC and it can make use of the nanosecond part to optimize the check to see if the path on the filesystem hsa been modified since we last looked at. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/read-cache.c b/read-cache.c
index 91f1d03c0..b819abbd0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -69,13 +69,8 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
{
ce->ce_ctime.sec = (unsigned int)st->st_ctime;
ce->ce_mtime.sec = (unsigned int)st->st_mtime;
-#ifdef USE_NSEC
- ce->ce_ctime.nsec = (unsigned int)st->st_ctim.tv_nsec;
- ce->ce_mtime.nsec = (unsigned int)st->st_mtim.tv_nsec;
-#else
- ce->ce_ctime.nsec = 0;
- ce->ce_mtime.nsec = 0;
-#endif
+ ce->ce_ctime.nsec = ST_CTIME_NSEC(*st);
+ ce->ce_mtime.nsec = ST_MTIME_NSEC(*st);
ce->ce_dev = st->st_dev;
ce->ce_ino = st->st_ino;
ce->ce_uid = st->st_uid;
@@ -1183,13 +1178,8 @@ static void convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_en
ce->ce_ctime.sec = ntohl(ondisk->ctime.sec);
ce->ce_mtime.sec = ntohl(ondisk->mtime.sec);
-#ifdef USE_NSEC
ce->ce_ctime.nsec = ntohl(ondisk->ctime.nsec);
ce->ce_mtime.nsec = ntohl(ondisk->mtime.nsec);
-#else
- ce->ce_ctime.nsec = 0;
- ce->ce_mtime.nsec = 0;
-#endif
ce->ce_dev = ntohl(ondisk->dev);
ce->ce_ino = ntohl(ondisk->ino);
ce->ce_mode = ntohl(ondisk->mode);
@@ -1309,11 +1299,7 @@ int read_index_from(struct index_state *istate, const char *path)
dst_offset += ce_size(ce);
}
istate->timestamp.sec = st.st_mtime;
-#ifdef USE_NSEC
- istate->timestamp.nsec = (unsigned int)st.st_mtim.tv_nsec;
-#else
- istate->timestamp.nsec = 0;
-#endif
+ istate->timestamp.nsec = ST_MTIME_NSEC(st);
while (src_offset <= mmap_size - 20 - 8) {
/* After an array of active_nr index entries,
@@ -1500,13 +1486,8 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
ondisk->ctime.sec = htonl(ce->ce_ctime.sec);
ondisk->mtime.sec = htonl(ce->ce_mtime.sec);
-#ifdef USE_NSEC
ondisk->ctime.nsec = htonl(ce->ce_ctime.nsec);
ondisk->mtime.nsec = htonl(ce->ce_mtime.nsec);
-#else
- ondisk->ctime.nsec = 0;
- ondisk->mtime.nsec = 0;
-#endif
ondisk->dev = htonl(ce->ce_dev);
ondisk->ino = htonl(ce->ce_ino);
ondisk->mode = htonl(ce->ce_mode);
@@ -1583,9 +1564,7 @@ int write_index(struct index_state *istate, int newfd)
if (ce_flush(&c, newfd) || fstat(newfd, &st))
return -1;
istate->timestamp.sec = (unsigned int)st.st_ctime;
-#ifdef USE_NSEC
- istate->timestamp.nsec = (unsigned int)st.st_ctim.tv_nsec;
-#endif
+ istate->timestamp.nsec = ST_CTIME_NSEC(st);
return 0;
}