Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4c5506

Browse files
author
Edward Thomson
committed
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.
1 parent 9dfe114 commit a4c5506

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/index/nsec.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,17 @@ void test_index_nsec__staging_maintains_other_nanos(void)
6161
cl_assert_equal_b(true, has_nsecs());
6262

6363
cl_assert((entry = git_index_get_bypath(repo_index, "a.txt", 0)));
64+
65+
/* if we are writing nanoseconds to the index, expect them to be
66+
* nonzero. if we are *not*, expect that we truncated the entry.
67+
*/
68+
#ifdef GIT_USE_NSEC
69+
cl_assert(entry->ctime.nanoseconds != 0);
70+
cl_assert(entry->mtime.nanoseconds != 0);
71+
#else
6472
cl_assert_equal_i(0, entry->ctime.nanoseconds);
6573
cl_assert_equal_i(0, entry->mtime.nanoseconds);
74+
#endif
6675
}
6776

6877
void test_index_nsec__status_doesnt_clear_nsecs(void)

0 commit comments

Comments
 (0)