summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-02-25 11:31:18 -0500
committerEdward Thomson <ethomson@github.com>2016-02-25 11:40:40 -0500
commita4c55069e3481fda0ab6abe82f0c63672eb8b3e9 (patch)
treee678c44464649f9b9ec166263d6102db0bb5aa18
parent9dfe11403a9a02ed056d7ea5621ba35b53012524 (diff)
downloadlibgit2-a4c55069e3481fda0ab6abe82f0c63672eb8b3e9.tar.gz
nsec: update staging test for GIT_USE_NSECS
The index::nsec::staging_maintains_other_nanos test was created to ensure that when we stage an entry when GIT_USE_NSECS is *unset* that we truncate the index entry and do not persist the (old, invalid) nanosec values. Ensure that when GIT_USE_NSECS is *set* that we do not do that, and actually write the correct nanosecond values.
-rw-r--r--tests/index/nsec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/index/nsec.c b/tests/index/nsec.c
index 5004339f0..244ab6362 100644
--- a/tests/index/nsec.c
+++ b/tests/index/nsec.c
@@ -61,8 +61,17 @@ void test_index_nsec__staging_maintains_other_nanos(void)
cl_assert_equal_b(true, has_nsecs());
cl_assert((entry = git_index_get_bypath(repo_index, "a.txt", 0)));
+
+ /* if we are writing nanoseconds to the index, expect them to be
+ * nonzero. if we are *not*, expect that we truncated the entry.
+ */
+#ifdef GIT_USE_NSEC
+ cl_assert(entry->ctime.nanoseconds != 0);
+ cl_assert(entry->mtime.nanoseconds != 0);
+#else
cl_assert_equal_i(0, entry->ctime.nanoseconds);
cl_assert_equal_i(0, entry->mtime.nanoseconds);
+#endif
}
void test_index_nsec__status_doesnt_clear_nsecs(void)