summaryrefslogtreecommitdiff
path: root/tests/clar_libgit2.c
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-05-02 09:50:15 -0700
committerVicent Marti <vicent@github.com>2014-05-02 09:50:15 -0700
commit272b462db7cfb50c1ab69e1edda214b21f242ae5 (patch)
tree13c7a7ef6e7ef1e6d90949e60a3d4677ef9096e4 /tests/clar_libgit2.c
parent9862ef8ef8ffd95a74be8082acab9fea0de85edb (diff)
parent99dfa470398b9c4e06e5a5ee61868d3b9e21b26e (diff)
downloadlibgit2-272b462db7cfb50c1ab69e1edda214b21f242ae5.tar.gz
Merge pull request #2308 from libgit2/rb/diff-update-index-stat-cache
Reduce excessive OID calculation for diff and stat
Diffstat (limited to 'tests/clar_libgit2.c')
-rw-r--r--tests/clar_libgit2.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 6f6143dad..f457adb33 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -484,23 +484,36 @@ void clar__assert_equal_file(
(size_t)expected_bytes, (size_t)total_bytes);
}
-void cl_fake_home(git_buf *restore)
+static char *_cl_restore_home = NULL;
+
+void cl_fake_home_cleanup(void *payload)
+{
+ char *restore = _cl_restore_home;
+ _cl_restore_home = NULL;
+
+ GIT_UNUSED(payload);
+
+ if (restore) {
+ cl_git_pass(git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore));
+ git__free(restore);
+ }
+}
+
+void cl_fake_home(void)
{
git_buf path = GIT_BUF_INIT;
cl_git_pass(git_libgit2_opts(
- GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore));
+ GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &path));
+
+ _cl_restore_home = git_buf_detach(&path);
+ cl_set_cleanup(cl_fake_home_cleanup, NULL);
- cl_must_pass(p_mkdir("home", 0777));
+ if (!git_path_exists("home"))
+ cl_must_pass(p_mkdir("home", 0777));
cl_git_pass(git_path_prettify(&path, "home", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
git_buf_free(&path);
}
-
-void cl_fake_home_cleanup(git_buf *restore)
-{
- cl_git_pass(git_libgit2_opts(
- GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore->ptr));
- git_buf_free(restore);
-}