summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAxel Rasmussen <axelrasmussen@google.com>2015-06-01 13:43:54 -0600
committerAxel Rasmussen <axelrasmussen@google.com>2015-09-18 23:33:55 -0700
commite7de893ef899705f7b7e2d9894a7fda147b6d091 (patch)
tree6cc30bbed8a0c2935c634ab241395de83200c4eb /src
parentcdef1fad366808e71e3cae3ffcbfca7111ce93a1 (diff)
downloadlibgit2-e7de893ef899705f7b7e2d9894a7fda147b6d091.tar.gz
cmake: add USE_NSEC, and only check nanosec m/ctime if enabled
Diffstat (limited to 'src')
-rw-r--r--src/diff.c4
-rw-r--r--src/index.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/src/diff.c b/src/diff.c
index d97dcd9d2..b2259c74d 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -835,7 +835,11 @@ static int maybe_modified(
*/
} else if (git_oid_iszero(&nitem->id) && new_is_workdir) {
bool use_ctime = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0);
+#ifdef GIT_USE_NSEC
bool use_nanos = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_NANOSECS) != 0);
+#else
+ bool use_nanos = false;
+#endif
git_index *index;
git_iterator_index(&index, info->new_iter);
diff --git a/src/index.c b/src/index.c
index 2e8934780..54a8b1eec 100644
--- a/src/index.c
+++ b/src/index.c
@@ -858,8 +858,11 @@ void git_index_entry__init_from_stat(
{
entry->ctime.seconds = (git_time_t)st->st_ctime;
entry->mtime.seconds = (git_time_t)st->st_mtime;
- /* entry->mtime.nanoseconds = st->st_mtimensec; */
- /* entry->ctime.nanoseconds = st->st_ctimensec; */
+#if !defined(GIT_WIN32) && !defined(__APPLE__)
+ /* Apple and Windows doesn't provide these struct stat fields. */
+ entry->mtime.nanoseconds = st->st_mtim.tv_nsec;
+ entry->ctime.nanoseconds = st->st_ctim.tv_nsec;
+#endif
entry->dev = st->st_rdev;
entry->ino = st->st_ino;
entry->mode = (!trust_mode && S_ISREG(st->st_mode)) ?