summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-07-22 13:34:19 -0400
committerEdward Thomson <ethomson@github.com>2016-08-04 15:12:04 -0400
commit27051d4e3134e53096b10089654a965064a77403 (patch)
tree8954ca3d25e96ebaf252d4e05de78f74ca46b591 /tests
parent8f09a98e1809dcdfd9d25b8268657bac4d942e6a (diff)
downloadlibgit2-ethomson/refresh_objects.tar.gz
odb: only freshen pack files every 2 secondsethomson/refresh_objects
Since writing multiple objects may all already exist in a single packfile, avoid freshening that packfile repeatedly in a tight loop. Instead, only freshen pack files every 2 seconds.
Diffstat (limited to 'tests')
-rw-r--r--tests/odb/freshen.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/odb/freshen.c b/tests/odb/freshen.c
index 0f2e0d017..d8d6c029a 100644
--- a/tests/odb/freshen.c
+++ b/tests/odb/freshen.c
@@ -68,6 +68,7 @@ void test_odb_freshen__packed_object(void)
cl_must_pass(p_utimes("testrepo.git/objects/pack/" PACKED_FN, old_times));
cl_must_pass(p_lstat("testrepo.git/objects/pack/" PACKED_FN, &before));
+ /* ensure that packfile is freshened */
cl_git_pass(git_odb_write(&id, odb, PACKED_STR,
CONST_STRLEN(PACKED_STR), GIT_OBJ_BLOB));
cl_assert_equal_oid(&expected_id, &id);
@@ -75,5 +76,18 @@ void test_odb_freshen__packed_object(void)
cl_assert(before.st_atime < after.st_atime);
cl_assert(before.st_mtime < after.st_mtime);
+
+ memcpy(&before, &after, sizeof(struct stat));
+
+ /* ensure that the pack file is not freshened again immediately */
+ cl_git_pass(git_odb_write(&id, odb, PACKED_STR,
+ CONST_STRLEN(PACKED_STR), GIT_OBJ_BLOB));
+ cl_assert_equal_oid(&expected_id, &id);
+ cl_must_pass(p_lstat("testrepo.git/objects/pack/" PACKED_FN, &after));
+
+ cl_assert(before.st_atime == after.st_atime);
+ cl_assert(before.st_atime_nsec == after.st_atime_nsec);
+ cl_assert(before.st_mtime == after.st_mtime);
+ cl_assert(before.st_mtime_nsec == after.st_mtime_nsec);
}