diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-11-12 19:53:09 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-11-12 19:53:09 +0100 |
| commit | 75a0ccf52fef2cab281de886730cda595d3736aa (patch) | |
| tree | 977b981aca588511e96f20dca4acec983d993a16 /src/fileops.c | |
| parent | 2c26c8679ffc02b6644e20eba9458121b944beb6 (diff) | |
| parent | 28659e50d56bb79460c8a1d2315443267d6e6f66 (diff) | |
| download | libgit2-75a0ccf52fef2cab281de886730cda595d3736aa.tar.gz | |
Merge pull request #3170 from CmdrMoozy/nsec_fix
git_index_entry__init_from_stat: set nsec fields in entry stats
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/fileops.c b/src/fileops.c index cfc22bb53..07eb504bd 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -366,7 +366,7 @@ GIT_INLINE(int) mkdir_validate_mode( return 0; } - + GIT_INLINE(int) mkdir_canonicalize( git_buf *path, uint32_t flags) @@ -1034,6 +1034,11 @@ int git_futils_filestamp_check( git_futils_filestamp *stamp, const char *path) { struct stat st; +#if defined(__APPLE__) + const struct timespec *statmtime = &st.st_mtimespec; +#else + const struct timespec *statmtime = &st.st_mtim; +#endif /* if the stamp is NULL, then always reload */ if (stamp == NULL) @@ -1042,12 +1047,18 @@ int git_futils_filestamp_check( if (p_stat(path, &st) < 0) return GIT_ENOTFOUND; - if (stamp->mtime == (git_time_t)st.st_mtime && + if (stamp->mtime.tv_sec == statmtime->tv_sec && +#if defined(GIT_USE_NSEC) + stamp->mtime.tv_nsec == statmtime->tv_nsec && +#endif stamp->size == (git_off_t)st.st_size && stamp->ino == (unsigned int)st.st_ino) return 0; - stamp->mtime = (git_time_t)st.st_mtime; + stamp->mtime.tv_sec = statmtime->tv_sec; +#if defined(GIT_USE_NSEC) + stamp->mtime.tv_nsec = statmtime->tv_nsec; +#endif stamp->size = (git_off_t)st.st_size; stamp->ino = (unsigned int)st.st_ino; @@ -1069,8 +1080,17 @@ void git_futils_filestamp_set( void git_futils_filestamp_set_from_stat( git_futils_filestamp *stamp, struct stat *st) { +#if defined(__APPLE__) + const struct timespec *statmtime = &st->st_mtimespec; +#else + const struct timespec *statmtime = &st->st_mtim; +#endif + if (st) { - stamp->mtime = (git_time_t)st->st_mtime; + stamp->mtime = *statmtime; +#if !defined(GIT_USE_NSEC) + stamp->mtime.tv_nsec = 0; +#endif stamp->size = (git_off_t)st->st_size; stamp->ino = (unsigned int)st->st_ino; } else { |
