diff options
author | Axel Rasmussen <axelrasmussen@google.com> | 2015-06-01 13:43:54 -0600 |
---|---|---|
committer | Axel Rasmussen <axelrasmussen@google.com> | 2015-09-18 23:33:55 -0700 |
commit | e7de893ef899705f7b7e2d9894a7fda147b6d091 (patch) | |
tree | 6cc30bbed8a0c2935c634ab241395de83200c4eb | |
parent | cdef1fad366808e71e3cae3ffcbfca7111ce93a1 (diff) | |
download | libgit2-e7de893ef899705f7b7e2d9894a7fda147b6d091.tar.gz |
cmake: add USE_NSEC, and only check nanosec m/ctime if enabled
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/diff.c | 4 | ||||
-rw-r--r-- | src/index.c | 7 | ||||
-rw-r--r-- | tests/merge/workdir/dirty.c | 8 |
4 files changed, 21 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 713640d6a..5790a03c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) OPTION( USE_ICONV "Link with and use iconv library" OFF ) OPTION( USE_SSH "Link with libssh to enable SSH support" ON ) OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF ) +OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" OFF ) OPTION( VALGRIND "Configure build for valgrind" OFF ) OPTION( CURL "User curl for HTTP if available" ON) @@ -500,6 +501,10 @@ IF (THREADSAFE) ADD_DEFINITIONS(-DGIT_THREADS) ENDIF() +IF (USE_NSEC) + ADD_DEFINITIONS(-DGIT_USE_NSEC) +ENDIF() + ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) # Collect sourcefiles 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)) ? diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c index 4bf984c23..ed402bd14 100644 --- a/tests/merge/workdir/dirty.c +++ b/tests/merge/workdir/dirty.c @@ -163,9 +163,15 @@ static void hack_index(char *files[]) cl_git_pass(p_stat(path.ptr, &statbuf)); entry->ctime.seconds = (git_time_t)statbuf.st_ctime; - entry->ctime.nanoseconds = 0; entry->mtime.seconds = (git_time_t)statbuf.st_mtime; +#if !defined(GIT_WIN32) && !defined(__APPLE__) + /* Apple and Windows doesn't provide these struct stat fields. */ + entry->ctime.nanoseconds = statbuf.st_ctim.tv_nsec; + entry->mtime.nanoseconds = statbuf.st_mtim.tv_nsec; +#else + entry->ctime.nanoseconds = 0; entry->mtime.nanoseconds = 0; +#endif entry->dev = statbuf.st_dev; entry->ino = statbuf.st_ino; entry->uid = statbuf.st_uid; |