summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/attr/ignore.c5
-rw-r--r--tests/attr/repo.c5
-rw-r--r--tests/clar_libgit2.c33
-rw-r--r--tests/clar_libgit2.h9
-rw-r--r--tests/config/global.c35
-rw-r--r--tests/diff/blob.c2
-rw-r--r--tests/diff/tree.c2
-rw-r--r--tests/diff/workdir.c98
-rw-r--r--tests/refs/branches/create.c9
-rw-r--r--tests/refs/branches/delete.c7
-rw-r--r--tests/refs/branches/ishead.c24
-rw-r--r--tests/status/ignore.c5
-rw-r--r--tests/status/worktree.c78
-rw-r--r--tests/structinit/structinit.c4
14 files changed, 236 insertions, 80 deletions
diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c
index 5eadc7b3e..b187db01c 100644
--- a/tests/attr/ignore.c
+++ b/tests/attr/ignore.c
@@ -148,12 +148,11 @@ void test_attr_ignore__skip_gitignore_directory(void)
void test_attr_ignore__expand_tilde_to_homedir(void)
{
- git_buf cleanup = GIT_BUF_INIT;
git_config *cfg;
assert_is_ignored(false, "example.global_with_tilde");
- cl_fake_home(&cleanup);
+ cl_fake_home();
/* construct fake home with fake global excludes */
cl_git_mkfile("home/globalexclude", "# found me\n*.global_with_tilde\n");
@@ -168,7 +167,7 @@ void test_attr_ignore__expand_tilde_to_homedir(void)
cl_git_pass(git_futils_rmdir_r("home", NULL, GIT_RMDIR_REMOVE_FILES));
- cl_fake_home_cleanup(&cleanup);
+ cl_fake_home_cleanup(NULL);
git_attr_cache_flush(g_repo); /* must reset to pick up change */
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index 9aab7ed96..5e812a72b 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -9,11 +9,6 @@ static git_repository *g_repo = NULL;
void test_attr_repo__initialize(void)
{
- /* Before each test, instantiate the attr repo from the fixtures and
- * rename the .gitted to .git so it is a repo with a working dir.
- * Also rename gitattributes to .gitattributes, because it contains
- * macro definitions which are only allowed in the root.
- */
g_repo = cl_git_sandbox_init("attr");
}
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);
-}
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index 082fa9f4a..f84d9e353 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -131,7 +131,12 @@ int cl_repo_get_bool(git_repository *repo, const char *cfg);
void cl_repo_set_string(git_repository *repo, const char *cfg, const char *value);
-void cl_fake_home(git_buf *restore);
-void cl_fake_home_cleanup(git_buf *restore);
+/* set up a fake "home" directory and set libgit2 GLOBAL search path.
+ *
+ * automatically configures cleanup function to restore the regular search
+ * path, although you can call it explicitly if you wish (with NULL).
+ */
+void cl_fake_home(void);
+void cl_fake_home_cleanup(void *);
#endif
diff --git a/tests/config/global.c b/tests/config/global.c
index d5f95f504..006b34628 100644
--- a/tests/config/global.c
+++ b/tests/config/global.c
@@ -2,22 +2,36 @@
#include "buffer.h"
#include "fileops.h"
+static git_config_level_t setting[3] = {
+ GIT_CONFIG_LEVEL_GLOBAL,
+ GIT_CONFIG_LEVEL_XDG,
+ GIT_CONFIG_LEVEL_SYSTEM
+};
+static char *restore[3];
+
void test_config_global__initialize(void)
{
+ int i;
git_buf path = GIT_BUF_INIT;
- cl_assert_equal_i(0, p_mkdir("home", 0777));
+ /* snapshot old settings to restore later */
+ for (i = 0; i < 3; ++i) {
+ cl_git_pass(
+ git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, setting[i], &path));
+ restore[i] = git_buf_detach(&path);
+ }
+
+ cl_git_pass(git_futils_mkdir_r("home", NULL, 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));
- cl_assert_equal_i(0, p_mkdir("xdg", 0777));
- cl_assert_equal_i(0, p_mkdir("xdg/git", 0777));
+ cl_git_pass(git_futils_mkdir_r("xdg/git", NULL, 0777));
cl_git_pass(git_path_prettify(&path, "xdg/git", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr));
- cl_assert_equal_i(0, p_mkdir("etc", 0777));
+ cl_git_pass(git_futils_mkdir_r("etc", NULL, 0777));
cl_git_pass(git_path_prettify(&path, "etc", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));
@@ -27,13 +41,18 @@ void test_config_global__initialize(void)
void test_config_global__cleanup(void)
{
+ int i;
+
+ for (i = 0; i < 3; ++i) {
+ cl_git_pass(
+ git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, setting[i], restore[i]));
+ git__free(restore[i]);
+ restore[i] = NULL;
+ }
+
cl_git_pass(git_futils_rmdir_r("home", NULL, GIT_RMDIR_REMOVE_FILES));
cl_git_pass(git_futils_rmdir_r("xdg", NULL, GIT_RMDIR_REMOVE_FILES));
cl_git_pass(git_futils_rmdir_r("etc", NULL, GIT_RMDIR_REMOVE_FILES));
-
- git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, NULL);
- git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, NULL);
- git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, NULL);
}
void test_config_global__open_global(void)
diff --git a/tests/diff/blob.c b/tests/diff/blob.c
index d1fff9c5b..527007965 100644
--- a/tests/diff/blob.c
+++ b/tests/diff/blob.c
@@ -26,7 +26,7 @@ void test_diff_blob__initialize(void)
g_repo = cl_git_sandbox_init("attr");
- cl_git_pass(git_diff_options_init(&opts, GIT_DIFF_OPTIONS_VERSION));
+ cl_git_pass(git_diff_init_options(&opts, GIT_DIFF_OPTIONS_VERSION));
opts.context_lines = 1;
memset(&expected, 0, sizeof(expected));
diff --git a/tests/diff/tree.c b/tests/diff/tree.c
index 582174b8b..6ab49fdb0 100644
--- a/tests/diff/tree.c
+++ b/tests/diff/tree.c
@@ -9,7 +9,7 @@ static diff_expects expect;
void test_diff_tree__initialize(void)
{
- cl_git_pass(git_diff_options_init(&opts, GIT_DIFF_OPTIONS_VERSION));
+ cl_git_pass(git_diff_init_options(&opts, GIT_DIFF_OPTIONS_VERSION));
memset(&expect, 0, sizeof(expect));
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 6128e820e..a6d48abc6 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -1,13 +1,10 @@
#include "clar_libgit2.h"
#include "diff_helpers.h"
#include "repository.h"
+#include "git2/sys/diff.h"
static git_repository *g_repo = NULL;
-void test_diff_workdir__initialize(void)
-{
-}
-
void test_diff_workdir__cleanup(void)
{
cl_git_sandbox_cleanup();
@@ -60,6 +57,14 @@ void test_diff_workdir__to_index(void)
cl_assert_equal_i(5, exp.line_dels);
}
+ {
+ git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT;
+ cl_git_pass(git_diff_get_perfdata(&perf, diff));
+ cl_assert_equal_sz(
+ 13 /* in root */ + 3 /* in subdir */, perf.stat_calls);
+ cl_assert_equal_sz(5, perf.oid_calculations);
+ }
+
git_diff_free(diff);
}
@@ -1490,3 +1495,88 @@ void test_diff_workdir__with_stale_index(void)
git_index_free(idx);
}
+
+static int touch_file(void *payload, git_buf *path)
+{
+ int fd;
+ char b;
+
+ GIT_UNUSED(payload);
+ if (git_path_isdir(path->ptr))
+ return 0;
+
+ cl_assert((fd = p_open(path->ptr, O_RDWR)) >= 0);
+ cl_assert_equal_i(1, p_read(fd, &b, 1));
+ cl_must_pass(p_lseek(fd, 0, SEEK_SET));
+ cl_must_pass(p_write(fd, &b, 1));
+ cl_must_pass(p_close(fd));
+
+ return 0;
+}
+
+static void basic_diff_status(git_diff **out, const git_diff_options *opts)
+{
+ diff_expects exp;
+
+ cl_git_pass(git_diff_index_to_workdir(out, g_repo, NULL, opts));
+
+ memset(&exp, 0, sizeof(exp));
+
+ cl_git_pass(git_diff_foreach(
+ *out, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
+
+ cl_assert_equal_i(13, exp.files);
+ cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(4, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_IGNORED]);
+ cl_assert_equal_i(4, exp.file_status[GIT_DELTA_UNTRACKED]);
+}
+
+void test_diff_workdir__can_update_index(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_diff *diff = NULL;
+ git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT;
+
+ g_repo = cl_git_sandbox_init("status");
+
+ /* touch all the files so stat times are different */
+ {
+ git_buf path = GIT_BUF_INIT;
+ cl_git_pass(git_buf_sets(&path, "status"));
+ cl_git_pass(git_path_direach(&path, 0, touch_file, NULL));
+ git_buf_free(&path);
+ }
+
+ opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
+
+ basic_diff_status(&diff, &opts);
+
+ cl_git_pass(git_diff_get_perfdata(&perf, diff));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(5, perf.oid_calculations);
+
+ git_diff_free(diff);
+
+ /* now allow diff to update stat cache */
+ opts.flags |= GIT_DIFF_UPDATE_INDEX;
+
+ basic_diff_status(&diff, &opts);
+
+ cl_git_pass(git_diff_get_perfdata(&perf, diff));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(5, perf.oid_calculations);
+
+ git_diff_free(diff);
+
+ /* now if we do it again, we should see fewer OID calculations */
+
+ basic_diff_status(&diff, &opts);
+
+ cl_git_pass(git_diff_get_perfdata(&perf, diff));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(0, perf.oid_calculations);
+
+ git_diff_free(diff);
+}
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index b91eed6e8..38af2f681 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -7,10 +7,9 @@ static git_reference *branch;
void test_refs_branches_create__initialize(void)
{
- cl_fixture_sandbox("testrepo.git");
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
-
+ repo = cl_git_sandbox_init("testrepo.git");
branch = NULL;
+ target = NULL;
}
void test_refs_branches_create__cleanup(void)
@@ -21,10 +20,8 @@ void test_refs_branches_create__cleanup(void)
git_commit_free(target);
target = NULL;
- git_repository_free(repo);
+ cl_git_sandbox_cleanup();
repo = NULL;
-
- cl_fixture_cleanup("testrepo.git");
}
static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha)
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index ed5f1627b..e3199e230 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -10,8 +10,7 @@ void test_refs_branches_delete__initialize(void)
{
git_oid id;
- cl_fixture_sandbox("testrepo.git");
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
+ repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0, NULL, NULL));
@@ -22,10 +21,8 @@ void test_refs_branches_delete__cleanup(void)
git_reference_free(fake_remote);
fake_remote = NULL;
- git_repository_free(repo);
+ cl_git_sandbox_cleanup();
repo = NULL;
-
- cl_fixture_cleanup("testrepo.git");
}
void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void)
diff --git a/tests/refs/branches/ishead.c b/tests/refs/branches/ishead.c
index 12a8c4449..d16a79652 100644
--- a/tests/refs/branches/ishead.c
+++ b/tests/refs/branches/ishead.c
@@ -7,7 +7,8 @@ static git_reference *branch;
void test_refs_branches_ishead__initialize(void)
{
- cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ repo = cl_git_sandbox_init("testrepo.git");
+ branch = NULL;
}
void test_refs_branches_ishead__cleanup(void)
@@ -15,7 +16,7 @@ void test_refs_branches_ishead__cleanup(void)
git_reference_free(branch);
branch = NULL;
- git_repository_free(repo);
+ cl_git_sandbox_cleanup();
repo = NULL;
}
@@ -28,34 +29,20 @@ void test_refs_branches_ishead__can_tell_if_a_branch_is_pointed_at_by_HEAD(void)
void test_refs_branches_ishead__can_properly_handle_unborn_HEAD(void)
{
- git_repository_free(repo);
-
- repo = cl_git_sandbox_init("testrepo.git");
-
make_head_unborn(repo, NON_EXISTING_HEAD);
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
cl_assert_equal_i(false, git_branch_is_head(branch));
-
- cl_git_sandbox_cleanup();
- repo = NULL;
}
void test_refs_branches_ishead__can_properly_handle_missing_HEAD(void)
{
- git_repository_free(repo);
-
- repo = cl_git_sandbox_init("testrepo.git");
-
delete_head(repo);
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
cl_assert_equal_i(false, git_branch_is_head(branch));
-
- cl_git_sandbox_cleanup();
- repo = NULL;
}
void test_refs_branches_ishead__can_tell_if_a_branch_is_not_pointed_at_by_HEAD(void)
@@ -95,9 +82,6 @@ void test_refs_branches_ishead__only_direct_references_are_considered(void)
{
git_reference *linked, *super, *head;
- git_repository_free(repo);
- repo = cl_git_sandbox_init("testrepo.git");
-
cl_git_pass(git_reference_symbolic_create(&linked, repo, "refs/heads/linked", "refs/heads/master", 0, NULL, NULL));
cl_git_pass(git_reference_symbolic_create(&super, repo, "refs/heads/super", "refs/heads/linked", 0, NULL, NULL));
cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/heads/super", 1, NULL, NULL));
@@ -111,6 +95,4 @@ void test_refs_branches_ishead__only_direct_references_are_considered(void)
git_reference_free(linked);
git_reference_free(super);
git_reference_free(head);
- cl_git_sandbox_cleanup();
- repo = NULL;
}
diff --git a/tests/status/ignore.c b/tests/status/ignore.c
index d88b2eb6b..caa1f1927 100644
--- a/tests/status/ignore.c
+++ b/tests/status/ignore.c
@@ -364,7 +364,6 @@ void test_status_ignore__leading_slash_ignores(void)
{
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
status_entry_counts counts;
- git_buf home = GIT_BUF_INIT;
static const char *paths_2[] = {
"dir/.gitignore",
"dir/a/ignore_me",
@@ -385,7 +384,7 @@ void test_status_ignore__leading_slash_ignores(void)
make_test_data(test_repo_1, test_files_1);
- cl_fake_home(&home);
+ cl_fake_home();
cl_git_mkfile("home/.gitignore", "/ignore_me\n");
{
git_config *cfg;
@@ -412,8 +411,6 @@ void test_status_ignore__leading_slash_ignores(void)
cl_assert_equal_i(counts.expected_entry_count, counts.entry_count);
cl_assert_equal_i(0, counts.wrong_status_flags_count);
cl_assert_equal_i(0, counts.wrong_sorted_path);
-
- cl_fake_home_cleanup(&home);
}
void test_status_ignore__contained_dir_with_matching_name(void)
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index def3d60f0..ca9068aba 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -5,6 +5,8 @@
#include "posix.h"
#include "util.h"
#include "path.h"
+#include "../diff/diff_helpers.h"
+#include "git2/sys/diff.h"
/**
* Cleanup
@@ -40,11 +42,15 @@ void test_status_worktree__whole_repository(void)
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
-void assert_show(const int entry_counts, const char *entry_paths[],
- const unsigned int entry_statuses[], git_status_show_t show)
+void assert_show(
+ const int entry_counts,
+ const char *entry_paths[],
+ const unsigned int entry_statuses[],
+ git_repository *repo,
+ git_status_show_t show,
+ unsigned int extra_flags)
{
status_entry_counts counts;
- git_repository *repo = cl_git_sandbox_init("status");
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
memset(&counts, 0x0, sizeof(status_entry_counts));
@@ -52,7 +58,7 @@ void assert_show(const int entry_counts, const char *entry_paths[],
counts.expected_paths = entry_paths;
counts.expected_statuses = entry_statuses;
- opts.flags = GIT_STATUS_OPT_DEFAULTS;
+ opts.flags = GIT_STATUS_OPT_DEFAULTS | extra_flags;
opts.show = show;
cl_git_pass(
@@ -67,19 +73,19 @@ void assert_show(const int entry_counts, const char *entry_paths[],
void test_status_worktree__show_index_and_workdir(void)
{
assert_show(entry_count0, entry_paths0, entry_statuses0,
- GIT_STATUS_SHOW_INDEX_AND_WORKDIR);
+ cl_git_sandbox_init("status"), GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0);
}
void test_status_worktree__show_index_only(void)
{
assert_show(entry_count5, entry_paths5, entry_statuses5,
- GIT_STATUS_SHOW_INDEX_ONLY);
+ cl_git_sandbox_init("status"), GIT_STATUS_SHOW_INDEX_ONLY, 0);
}
void test_status_worktree__show_workdir_only(void)
{
assert_show(entry_count6, entry_paths6, entry_statuses6,
- GIT_STATUS_SHOW_WORKDIR_ONLY);
+ cl_git_sandbox_init("status"), GIT_STATUS_SHOW_WORKDIR_ONLY, 0);
}
/* this test is equivalent to t18-status.c:statuscb1 */
@@ -578,7 +584,11 @@ void test_status_worktree__line_endings_dont_count_as_changes_with_autocrlf(void
cl_git_pass(git_status_file(&status, repo, "current_file"));
- cl_assert_equal_i(GIT_STATUS_CURRENT, status);
+ /* stat data on file should no longer match stat cache, even though
+ * file diff will be empty because of line-ending conversion - matches
+ * the Git command-line behavior here.
+ */
+ cl_assert_equal_i(GIT_STATUS_WT_MODIFIED, status);
}
void test_status_worktree__line_endings_dont_count_as_changes_with_autocrlf_issue_1397(void)
@@ -873,3 +883,55 @@ void test_status_worktree__long_filenames(void)
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
+/* The update stat cache tests mostly just mirror other tests and try
+ * to make sure that updating the stat cache doesn't change the results
+ * while reducing the amount of work that needs to be done
+ */
+
+static void check_status0(git_status_list *status)
+{
+ size_t i, max_i = git_status_list_entrycount(status);
+ cl_assert_equal_sz(entry_count0, max_i);
+ for (i = 0; i < max_i; ++i) {
+ const git_status_entry *entry = git_status_byindex(status, i);
+ cl_assert_equal_i(entry_statuses0[i], entry->status);
+ }
+}
+
+void test_status_worktree__update_stat_cache_0(void)
+{
+ git_repository *repo = cl_git_sandbox_init("status");
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+ git_status_list *status;
+ git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT;
+
+ opts.flags = GIT_STATUS_OPT_DEFAULTS;
+
+ cl_git_pass(git_status_list_new(&status, repo, &opts));
+ check_status0(status);
+ cl_git_pass(git_status_list_get_perfdata(&perf, status));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(5, perf.oid_calculations);
+
+ git_status_list_free(status);
+
+ opts.flags |= GIT_STATUS_OPT_UPDATE_INDEX;
+
+ cl_git_pass(git_status_list_new(&status, repo, &opts));
+ check_status0(status);
+ cl_git_pass(git_status_list_get_perfdata(&perf, status));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(5, perf.oid_calculations);
+
+ git_status_list_free(status);
+
+ opts.flags &= ~GIT_STATUS_OPT_UPDATE_INDEX;
+
+ cl_git_pass(git_status_list_new(&status, repo, &opts));
+ check_status0(status);
+ cl_git_pass(git_status_list_get_perfdata(&perf, status));
+ cl_assert_equal_sz(13 + 3, perf.stat_calls);
+ cl_assert_equal_sz(0, perf.oid_calculations);
+
+ git_status_list_free(status);
+}
diff --git a/tests/structinit/structinit.c b/tests/structinit/structinit.c
index 2942099dd..38bedada7 100644
--- a/tests/structinit/structinit.c
+++ b/tests/structinit/structinit.c
@@ -48,7 +48,7 @@ void test_structinit_structinit__compare(void)
/* checkout */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
- GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_opts);
+ GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_options);
/* clone */
CHECK_MACRO_FUNC_INIT_EQUAL( \
@@ -98,7 +98,7 @@ void test_structinit_structinit__compare(void)
/* revert */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_revert_options, GIT_REVERT_OPTIONS_VERSION, \
- GIT_REVERT_OPTIONS_INIT, git_revert_init_opts);
+ GIT_REVERT_OPTIONS_INIT, git_revert_init_options);
/* status */
CHECK_MACRO_FUNC_INIT_EQUAL( \