summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/checkout/index.c1
-rw-r--r--tests-clar/clar.c36
-rw-r--r--tests-clar/clone/nonetwork.c3
-rw-r--r--tests-clar/commit/signature.c2
-rw-r--r--tests-clar/diff/blob.c238
-rw-r--r--tests-clar/diff/drivers.c125
-rw-r--r--tests-clar/diff/patch.c2
-rw-r--r--tests-clar/diff/rename.c2
-rw-r--r--tests-clar/diff/submodules.c1
-rw-r--r--tests-clar/fetchhead/nonetwork.c2
-rw-r--r--tests-clar/merge/merge_helpers.c2
-rw-r--r--tests-clar/odb/alternates.c2
-rw-r--r--tests-clar/online/clone.c3
-rw-r--r--tests-clar/online/fetchhead.c2
-rw-r--r--tests-clar/refs/delete.c5
-rw-r--r--tests-clar/refs/pack.c10
-rw-r--r--tests-clar/refs/reflog/reflog.c2
-rw-r--r--tests-clar/refs/rename.c13
-rw-r--r--tests-clar/repo/discover.c2
-rw-r--r--tests-clar/status/ignore.c2
-rw-r--r--tests-clar/status/worktree.c2
21 files changed, 425 insertions, 32 deletions
diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c
index 78ff5ac62..a3a0f8fda 100644
--- a/tests-clar/checkout/index.c
+++ b/tests-clar/checkout/index.c
@@ -2,6 +2,7 @@
#include "checkout_helpers.h"
#include "git2/checkout.h"
+#include "fileops.h"
#include "repository.h"
static git_repository *g_repo;
diff --git a/tests-clar/clar.c b/tests-clar/clar.c
index fed87c30d..0eae81bf5 100644
--- a/tests-clar/clar.c
+++ b/tests-clar/clar.c
@@ -183,10 +183,10 @@ clar_run_test(
}
static void
-clar_run_suite(const struct clar_suite *suite)
+clar_run_suite(const struct clar_suite *suite, const char *name)
{
const struct clar_func *test = suite->tests;
- size_t i;
+ size_t i, namelen;
if (!suite->enabled)
return;
@@ -200,7 +200,23 @@ clar_run_suite(const struct clar_suite *suite)
_clar.active_suite = suite->name;
_clar.suite_errors = 0;
+ if (name) {
+ size_t suitelen = strlen(suite->name);
+ namelen = strlen(name);
+ if (namelen <= suitelen) {
+ name = NULL;
+ } else {
+ name += suitelen;
+ while (*name == ':')
+ ++name;
+ namelen = strlen(name);
+ }
+ }
+
for (i = 0; i < suite->test_count; ++i) {
+ if (name && strncmp(test[i].name, name, namelen))
+ continue;
+
_clar.active_test = test[i].name;
clar_run_test(&test[i], &suite->initialize, &suite->cleanup);
@@ -240,7 +256,7 @@ clar_parse_args(int argc, char **argv)
case 'x': { /* given suite name */
int offset = (argument[2] == '=') ? 3 : 2, found = 0;
char action = argument[1];
- size_t j, len;
+ size_t j, len, cmplen;
argument += offset;
len = strlen(argument);
@@ -249,7 +265,11 @@ clar_parse_args(int argc, char **argv)
clar_usage(argv[0]);
for (j = 0; j < _clar_suite_count; ++j) {
- if (strncmp(argument, _clar_suites[j].name, len) == 0) {
+ cmplen = strlen(_clar_suites[j].name);
+ if (cmplen > len)
+ cmplen = len;
+
+ if (strncmp(argument, _clar_suites[j].name, cmplen) == 0) {
int exact = !strcmp(argument, _clar_suites[j].name);
++found;
@@ -258,9 +278,9 @@ clar_parse_args(int argc, char **argv)
_clar.report_suite_names = 1;
switch (action) {
- case 's': clar_run_suite(&_clar_suites[j]); break;
- case 'i': _clar_suites[j].enabled = 1; break;
- case 'x': _clar_suites[j].enabled = 0; break;
+ case 's': clar_run_suite(&_clar_suites[j], argument); break;
+ case 'i': _clar_suites[j].enabled = 1; break;
+ case 'x': _clar_suites[j].enabled = 0; break;
}
if (exact)
@@ -318,7 +338,7 @@ clar_test(int argc, char **argv)
if (!_clar.suites_ran) {
size_t i;
for (i = 0; i < _clar_suite_count; ++i)
- clar_run_suite(&_clar_suites[i]);
+ clar_run_suite(&_clar_suites[i], NULL);
}
clar_print_shutdown(
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index 8aae1fb52..339b1e70d 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -1,8 +1,9 @@
#include "clar_libgit2.h"
#include "git2/clone.h"
-#include "repository.h"
#include "remote.h"
+#include "fileops.h"
+#include "repository.h"
#define LIVE_REPO_URL "git://github.com/libgit2/TestGitRepository"
diff --git a/tests-clar/commit/signature.c b/tests-clar/commit/signature.c
index aef72a80d..e9dcfab41 100644
--- a/tests-clar/commit/signature.c
+++ b/tests-clar/commit/signature.c
@@ -31,6 +31,8 @@ static void assert_name_and_email(
void test_commit_signature__leading_and_trailing_spaces_are_trimmed(void)
{
assert_name_and_email("nulltoken", "emeric.fermas@gmail.com", " nulltoken ", " emeric.fermas@gmail.com ");
+ assert_name_and_email("nulltoken", "emeric.fermas@gmail.com", " nulltoken ", " emeric.fermas@gmail.com \n");
+ assert_name_and_email("nulltoken", "emeric.fermas@gmail.com", " \t nulltoken \n", " \n emeric.fermas@gmail.com \n");
}
void test_commit_signature__angle_brackets_in_names_are_not_supported(void)
diff --git a/tests-clar/diff/blob.c b/tests-clar/diff/blob.c
index 2ac8dbc51..b12186d98 100644
--- a/tests-clar/diff/blob.c
+++ b/tests-clar/diff/blob.c
@@ -120,6 +120,93 @@ void test_diff_blob__can_compare_text_blobs(void)
git_blob_free(c);
}
+void test_diff_blob__can_compare_text_blobs_with_patch(void)
+{
+ git_blob *a, *b, *c;
+ git_oid a_oid, b_oid, c_oid;
+ git_diff_patch *p;
+ size_t tc, ta, td;
+
+ /* tests/resources/attr/root_test1 */
+ cl_git_pass(git_oid_fromstrn(&a_oid, "45141a79", 8));
+ cl_git_pass(git_blob_lookup_prefix(&a, g_repo, &a_oid, 4));
+
+ /* tests/resources/attr/root_test2 */
+ cl_git_pass(git_oid_fromstrn(&b_oid, "4d713dc4", 8));
+ cl_git_pass(git_blob_lookup_prefix(&b, g_repo, &b_oid, 4));
+
+ /* tests/resources/attr/root_test3 */
+ cl_git_pass(git_oid_fromstrn(&c_oid, "c96bbb2c2557a832", 16));
+ cl_git_pass(git_blob_lookup_prefix(&c, g_repo, &c_oid, 8));
+
+ /* Doing the equivalent of a `git diff -U1` on these files */
+
+ /* diff on tests/resources/attr/root_test1 */
+ cl_git_pass(git_diff_patch_from_blobs(&p, a, b, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_MODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(6, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ cl_git_pass(git_diff_patch_line_stats(&tc, &ta, &td, p));
+ cl_assert_equal_i(1, (int)tc);
+ cl_assert_equal_i(5, (int)ta);
+ cl_assert_equal_i(0, (int)td);
+
+ git_diff_patch_free(p);
+
+ /* diff on tests/resources/attr/root_test2 */
+ cl_git_pass(git_diff_patch_from_blobs(&p, b, c, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_MODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(15, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ cl_git_pass(git_diff_patch_line_stats(&tc, &ta, &td, p));
+ cl_assert_equal_i(3, (int)tc);
+ cl_assert_equal_i(9, (int)ta);
+ cl_assert_equal_i(3, (int)td);
+
+ git_diff_patch_free(p);
+
+ /* diff on tests/resources/attr/root_test3 */
+ cl_git_pass(git_diff_patch_from_blobs(&p, a, c, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_MODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(13, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ cl_git_pass(git_diff_patch_line_stats(&tc, &ta, &td, p));
+ cl_assert_equal_i(0, (int)tc);
+ cl_assert_equal_i(12, (int)ta);
+ cl_assert_equal_i(1, (int)td);
+
+ git_diff_patch_free(p);
+
+ /* one more */
+ cl_git_pass(git_diff_patch_from_blobs(&p, c, d, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_MODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(2, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(5, git_diff_patch_num_lines_in_hunk(p, 0));
+ cl_assert_equal_i(9, git_diff_patch_num_lines_in_hunk(p, 1));
+
+ cl_git_pass(git_diff_patch_line_stats(&tc, &ta, &td, p));
+ cl_assert_equal_i(4, (int)tc);
+ cl_assert_equal_i(6, (int)ta);
+ cl_assert_equal_i(4, (int)td);
+
+ git_diff_patch_free(p);
+
+ git_blob_free(a);
+ git_blob_free(b);
+ git_blob_free(c);
+}
+
void test_diff_blob__can_compare_against_null_blobs(void)
{
git_blob *e = NULL;
@@ -175,6 +262,66 @@ void test_diff_blob__can_compare_against_null_blobs(void)
cl_assert_equal_i(0, expected.lines);
}
+void test_diff_blob__can_compare_against_null_blobs_with_patch(void)
+{
+ git_blob *e = NULL;
+ git_diff_patch *p;
+ int line;
+ char origin;
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, d, e, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_DELETED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(14, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ for (line = 0; line < git_diff_patch_num_lines_in_hunk(p, 0); ++line) {
+ cl_git_pass(git_diff_patch_get_line_in_hunk(
+ &origin, NULL, NULL, NULL, NULL, p, 0, line));
+ cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)origin);
+ }
+
+ git_diff_patch_free(p);
+
+ opts.flags |= GIT_DIFF_REVERSE;
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, d, e, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_ADDED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(14, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ for (line = 0; line < git_diff_patch_num_lines_in_hunk(p, 0); ++line) {
+ cl_git_pass(git_diff_patch_get_line_in_hunk(
+ &origin, NULL, NULL, NULL, NULL, p, 0, line));
+ cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)origin);
+ }
+
+ git_diff_patch_free(p);
+
+ opts.flags ^= GIT_DIFF_REVERSE;
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, alien, NULL, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_DELETED, git_diff_patch_delta(p)->status);
+ cl_assert((git_diff_patch_delta(p)->flags & GIT_DIFF_FLAG_BINARY) != 0);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+
+ git_diff_patch_free(p);
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, NULL, alien, &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_ADDED, git_diff_patch_delta(p)->status);
+ cl_assert((git_diff_patch_delta(p)->flags & GIT_DIFF_FLAG_BINARY) != 0);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+
+ git_diff_patch_free(p);
+}
+
static void assert_identical_blobs_comparison(diff_expects *expected)
{
cl_assert_equal_i(1, expected->files);
@@ -206,6 +353,29 @@ void test_diff_blob__can_compare_identical_blobs(void)
assert_identical_blobs_comparison(&expected);
}
+void test_diff_blob__can_compare_identical_blobs_with_patch(void)
+{
+ git_diff_patch *p;
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, d, d, &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_UNMODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+ git_diff_patch_free(p);
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, NULL, NULL, &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_UNMODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+ git_diff_patch_free(p);
+
+ cl_git_pass(git_diff_patch_from_blobs(&p, alien, alien, &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_UNMODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+ git_diff_patch_free(p);
+}
+
static void assert_binary_blobs_comparison(diff_expects *expected)
{
cl_assert(expected->files_binary > 0);
@@ -428,6 +598,74 @@ void test_diff_blob__can_compare_blob_to_buffer(void)
git_blob_free(a);
}
+void test_diff_blob__can_compare_blob_to_buffer_with_patch(void)
+{
+ git_diff_patch *p;
+ git_blob *a;
+ git_oid a_oid;
+ const char *a_content = "Hello from the root\n";
+ const char *b_content = "Hello from the root\n\nSome additional lines\n\nDown here below\n\n";
+ size_t tc, ta, td;
+
+ /* tests/resources/attr/root_test1 */
+ cl_git_pass(git_oid_fromstrn(&a_oid, "45141a79", 8));
+ cl_git_pass(git_blob_lookup_prefix(&a, g_repo, &a_oid, 4));
+
+ /* diff from blob a to content of b */
+ cl_git_pass(git_diff_patch_from_blob_and_buffer(
+ &p, a, b_content, strlen(b_content), &opts));
+
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_MODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(6, git_diff_patch_num_lines_in_hunk(p, 0));
+
+ cl_git_pass(git_diff_patch_line_stats(&tc, &ta, &td, p));
+ cl_assert_equal_i(1, (int)tc);
+ cl_assert_equal_i(5, (int)ta);
+ cl_assert_equal_i(0, (int)td);
+
+ git_diff_patch_free(p);
+
+ /* diff from blob a to content of a */
+ cl_git_pass(git_diff_patch_from_blob_and_buffer(
+ &p, a, a_content, strlen(a_content), &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_UNMODIFIED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(0, (int)git_diff_patch_num_hunks(p));
+ git_diff_patch_free(p);
+
+ /* diff from NULL blob to content of a */
+ cl_git_pass(git_diff_patch_from_blob_and_buffer(
+ &p, NULL, a_content, strlen(a_content), &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_ADDED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(1, git_diff_patch_num_lines_in_hunk(p, 0));
+ git_diff_patch_free(p);
+
+ /* diff from blob a to NULL buffer */
+ cl_git_pass(git_diff_patch_from_blob_and_buffer(
+ &p, a, NULL, 0, &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_DELETED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(1, git_diff_patch_num_lines_in_hunk(p, 0));
+ git_diff_patch_free(p);
+
+ /* diff with reverse */
+ opts.flags ^= GIT_DIFF_REVERSE;
+
+ cl_git_pass(git_diff_patch_from_blob_and_buffer(
+ &p, a, NULL, 0, &opts));
+ cl_assert(p != NULL);
+ cl_assert_equal_i(GIT_DELTA_ADDED, git_diff_patch_delta(p)->status);
+ cl_assert_equal_i(1, (int)git_diff_patch_num_hunks(p));
+ cl_assert_equal_i(1, git_diff_patch_num_lines_in_hunk(p, 0));
+ git_diff_patch_free(p);
+
+ git_blob_free(a);
+}
static void assert_one_modified_with_lines(diff_expects *expected, int lines)
{
diff --git a/tests-clar/diff/drivers.c b/tests-clar/diff/drivers.c
new file mode 100644
index 000000000..06ab2ff14
--- /dev/null
+++ b/tests-clar/diff/drivers.c
@@ -0,0 +1,125 @@
+#include "clar_libgit2.h"
+#include "diff_helpers.h"
+#include "repository.h"
+#include "diff_driver.h"
+
+static git_repository *g_repo = NULL;
+
+void test_diff_drivers__initialize(void)
+{
+}
+
+void test_diff_drivers__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+ g_repo = NULL;
+}
+
+void test_diff_drivers__patterns(void)
+{
+ git_config *cfg;
+ const char *one_sha = "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13";
+ git_tree *one;
+ git_diff_list *diff;
+ git_diff_patch *patch;
+ char *text;
+ const char *expected0 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\n--- a/untimely.txt\n+++ b/untimely.txt\n@@ -22,3 +22,5 @@ Comes through the blood of the vanguards who\n dreamed--too soon--it had sounded.\r\n \r\n -- Rudyard Kipling\r\n+\r\n+Some new stuff\r\n";
+ const char *expected1 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\nBinary files a/untimely.txt and b/untimely.txt differ\n";
+ const char *expected2 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\n--- a/untimely.txt\n+++ b/untimely.txt\n@@ -22,3 +22,5 @@ Heaven delivers on earth the Hour that cannot be\n dreamed--too soon--it had sounded.\r\n \r\n -- Rudyard Kipling\r\n+\r\n+Some new stuff\r\n";
+
+ g_repo = cl_git_sandbox_init("renames");
+
+ one = resolve_commit_oid_to_tree(g_repo, one_sha);
+
+ /* no diff */
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(0, (int)git_diff_num_deltas(diff));
+ git_diff_list_free(diff);
+
+ /* default diff */
+
+ cl_git_append2file("renames/untimely.txt", "\r\nSome new stuff\r\n");
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+
+ cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+ cl_git_pass(git_diff_patch_to_str(&text, patch));
+ cl_assert_equal_s(expected0, text);
+
+ git__free(text);
+ git_diff_patch_free(patch);
+ git_diff_list_free(diff);
+
+ /* attribute diff set to false */
+
+ cl_git_rewritefile("renames/.gitattributes", "untimely.txt -diff\n");
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+
+ cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+ cl_git_pass(git_diff_patch_to_str(&text, patch));
+ cl_assert_equal_s(expected1, text);
+
+ git__free(text);
+ git_diff_patch_free(patch);
+ git_diff_list_free(diff);
+
+ /* attribute diff set to unconfigured value (should use default) */
+
+ cl_git_rewritefile("renames/.gitattributes", "untimely.txt diff=kipling0\n");
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+
+ cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+ cl_git_pass(git_diff_patch_to_str(&text, patch));
+ cl_assert_equal_s(expected0, text);
+
+ git__free(text);
+ git_diff_patch_free(patch);
+ git_diff_list_free(diff);
+
+ /* let's define that driver */
+
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+ cl_git_pass(git_config_set_bool(cfg, "diff.kipling0.binary", 1));
+ git_config_free(cfg);
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+
+ cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+ cl_git_pass(git_diff_patch_to_str(&text, patch));
+ cl_assert_equal_s(expected1, text);
+
+ git__free(text);
+ git_diff_patch_free(patch);
+ git_diff_list_free(diff);
+
+ /* let's use a real driver with some regular expressions */
+
+ git_diff_driver_registry_free(g_repo->diff_drivers);
+ g_repo->diff_drivers = NULL;
+
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+ cl_git_pass(git_config_set_bool(cfg, "diff.kipling0.binary", 0));
+ cl_git_pass(git_config_set_string(cfg, "diff.kipling0.xfuncname", "^H"));
+ git_config_free(cfg);
+
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
+
+ cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
+ cl_git_pass(git_diff_patch_to_str(&text, patch));
+ cl_assert_equal_s(expected2, text);
+
+ git__free(text);
+ git_diff_patch_free(patch);
+ git_diff_list_free(diff);
+
+ git_tree_free(one);
+}
+
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index f9e913a74..3f14a0de7 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -543,7 +543,7 @@ void test_diff_patch__line_counts_with_eofnl(void)
"index 378a7d9..3d0154e 100644\n"
"--- a/songof7cities.txt\n"
"+++ b/songof7cities.txt\n"
- "@@ -42,7 +42,7 @@\n"
+ "@@ -42,7 +42,7 @@ With peoples undefeated of the dark, enduring blood.\n"
" \n"
" To the sound of trumpets shall their seed restore my Cities\n"
" Wealthy and well-weaponed, that once more may I behold\n"
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index 2ec1e20eb..fd31a3859 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -558,7 +558,7 @@ void test_diff_rename__patch(void)
git_diff_patch *patch;
const git_diff_delta *delta;
char *text;
- const char *expected = "diff --git a/sixserving.txt b/ikeepsix.txt\nindex ad0a8e5..36020db 100644\n--- a/sixserving.txt\n+++ b/ikeepsix.txt\n@@ -1,3 +1,6 @@\n+I Keep Six Honest Serving-Men\n+=============================\n+\n I KEEP six honest serving-men\n (They taught me all I knew);\n Their names are What and Why and When\n@@ -21,4 +24,4 @@\n One million Hows, two million Wheres,\n And seven million Whys!\n \n- -- Rudyard Kipling\n+ -- Rudyard Kipling\n";
+ const char *expected = "diff --git a/sixserving.txt b/ikeepsix.txt\nindex ad0a8e5..36020db 100644\n--- a/sixserving.txt\n+++ b/ikeepsix.txt\n@@ -1,3 +1,6 @@\n+I Keep Six Honest Serving-Men\n+=============================\n+\n I KEEP six honest serving-men\n (They taught me all I knew);\n Their names are What and Why and When\n@@ -21,4 +24,4 @@ She sends'em abroad on her own affairs,\n One million Hows, two million Wheres,\n And seven million Whys!\n \n- -- Rudyard Kipling\n+ -- Rudyard Kipling\n";
old_tree = resolve_commit_oid_to_tree(g_repo, sha0);
new_tree = resolve_commit_oid_to_tree(g_repo, sha1);
diff --git a/tests-clar/diff/submodules.c b/tests-clar/diff/submodules.c
index f152af46f..6e52a6319 100644
--- a/tests-clar/diff/submodules.c
+++ b/tests-clar/diff/submodules.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "repository.h"
+#include "posix.h"
#include "../submodule/submodule_helpers.h"
static git_repository *g_repo = NULL;
diff --git a/tests-clar/fetchhead/nonetwork.c b/tests-clar/fetchhead/nonetwork.c
index ef30679f9..a68ebb0b7 100644
--- a/tests-clar/fetchhead/nonetwork.c
+++ b/tests-clar/fetchhead/nonetwork.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "fetchhead.h"
#include "fetchhead_data.h"
diff --git a/tests-clar/merge/merge_helpers.c b/tests-clar/merge/merge_helpers.c
index bc31b1f44..e4092787c 100644
--- a/tests-clar/merge/merge_helpers.c
+++ b/tests-clar/merge/merge_helpers.c
@@ -1,5 +1,5 @@
#include "clar_libgit2.h"
-#include "buffer.h"
+#include "fileops.h"
#include "refs.h"
#include "tree.h"
#include "merge_helpers.h"
diff --git a/tests-clar/odb/alternates.c b/tests-clar/odb/alternates.c
index be7bfa9cd..4e876c2b3 100644
--- a/tests-clar/odb/alternates.c
+++ b/tests-clar/odb/alternates.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
#include "odb.h"
-#include "repository.h"
+#include "filebuf.h"
static git_buf destpath, filepath;
static const char *paths[] = {
diff --git a/tests-clar/online/clone.c b/tests-clar/online/clone.c
index aa12e47c9..bc4285a00 100644
--- a/tests-clar/online/clone.c
+++ b/tests-clar/online/clone.c
@@ -2,8 +2,9 @@
#include "git2/clone.h"
#include "git2/cred_helpers.h"
-#include "repository.h"
#include "remote.h"
+#include "fileops.h"
+#include "refs.h"
#define LIVE_REPO_URL "http://github.com/libgit2/TestGitRepository"
#define LIVE_EMPTYREPO_URL "http://github.com/libgit2/TestEmptyRepository"
diff --git a/tests-clar/online/fetchhead.c b/tests-clar/online/fetchhead.c
index e14ae0926..58717eef8 100644
--- a/tests-clar/online/fetchhead.c
+++ b/tests-clar/online/fetchhead.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "fetchhead.h"
#include "../fetchhead/fetchhead_data.h"
#include "git2/clone.h"
diff --git a/tests-clar/refs/delete.c b/tests-clar/refs/delete.c
index 053f41229..973768aeb 100644
--- a/tests-clar/refs/delete.c
+++ b/tests-clar/refs/delete.c
@@ -1,7 +1,8 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "git2/reflog.h"
+#include "git2/refdb.h"
#include "reflog.h"
#include "ref_helpers.h"
@@ -31,7 +32,7 @@ void test_refs_delete__packed_loose(void)
git_buf temp_path = GIT_BUF_INIT;
/* Ensure the loose reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, packed_test_head_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the reference */
diff --git a/tests-clar/refs/pack.c b/tests-clar/refs/pack.c
index 412c4c5fd..d8d5cc6d0 100644
--- a/tests-clar/refs/pack.c
+++ b/tests-clar/refs/pack.c
@@ -1,8 +1,10 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "git2/reflog.h"
+#include "git2/refdb.h"
#include "reflog.h"
+#include "refs.h"
#include "ref_helpers.h"
static const char *loose_tag_ref_name = "refs/tags/e90810b";
@@ -33,7 +35,7 @@ void test_refs_pack__empty(void)
// create a packfile for an empty folder
git_buf temp_path = GIT_BUF_INIT;
- cl_git_pass(git_buf_join_n(&temp_path, '/', 3, g_repo->path_repository, GIT_REFS_HEADS_DIR, "empty_dir"));
+ cl_git_pass(git_buf_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir"));
cl_git_pass(git_futils_mkdir_r(temp_path.ptr, NULL, GIT_REFS_DIR_MODE));
git_buf_free(&temp_path);
@@ -60,7 +62,7 @@ void test_refs_pack__loose(void)
packall();
/* Ensure the packed-refs file exists */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, GIT_PACKEDREFS_FILE));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
cl_assert(git_path_exists(temp_path.ptr));
/* Ensure the known ref can still be looked up but is now packed */
@@ -69,7 +71,7 @@ void test_refs_pack__loose(void)
cl_assert_equal_s(reference->name, loose_tag_ref_name);
/* Ensure the known ref has been removed from the loose folder structure */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, loose_tag_ref_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
cl_assert(!git_path_exists(temp_path.ptr));
git_reference_free(reference);
diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c
index 1cd0ddd92..095cabf04 100644
--- a/tests-clar/refs/reflog/reflog.c
+++ b/tests-clar/refs/reflog/reflog.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "git2/reflog.h"
#include "reflog.h"
diff --git a/tests-clar/refs/rename.c b/tests-clar/refs/rename.c
index 5ab84c48e..543bc4d62 100644
--- a/tests-clar/refs/rename.c
+++ b/tests-clar/refs/rename.c
@@ -1,8 +1,9 @@
#include "clar_libgit2.h"
-#include "repository.h"
+#include "fileops.h"
#include "git2/reflog.h"
#include "reflog.h"
+#include "refs.h"
#include "ref_helpers.h"
static const char *loose_tag_ref_name = "refs/tags/e90810b";
@@ -38,7 +39,7 @@ void test_refs_rename__loose(void)
const char *new_name = "refs/tags/Nemo/knows/refs.kung-fu";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, new_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* Retrieval of the reference to rename */
@@ -64,7 +65,7 @@ void test_refs_rename__loose(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref can be found in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, new_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
@@ -80,7 +81,7 @@ void test_refs_rename__packed(void)
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, packed_head_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* The reference can however be looked-up... */
@@ -106,7 +107,7 @@ void test_refs_rename__packed(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref now happily lives in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, brand_new_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
@@ -122,7 +123,7 @@ void test_refs_rename__packed_doesnt_pack_others(void)
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the other reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, g_repo->path_repository, packed_test_head_name));
+ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the other reference */
diff --git a/tests-clar/repo/discover.c b/tests-clar/repo/discover.c
index 3d9aeedd7..f93ff2462 100644
--- a/tests-clar/repo/discover.c
+++ b/tests-clar/repo/discover.c
@@ -1,9 +1,9 @@
#include "clar_libgit2.h"
#include "odb.h"
+#include "fileops.h"
#include "repository.h"
-
#define TEMP_REPO_FOLDER "temprepo/"
#define DISCOVER_FOLDER TEMP_REPO_FOLDER "discover.git"
diff --git a/tests-clar/status/ignore.c b/tests-clar/status/ignore.c
index 2d3898ba4..4f6879cfc 100644
--- a/tests-clar/status/ignore.c
+++ b/tests-clar/status/ignore.c
@@ -169,7 +169,7 @@ void test_status_ignore__ignore_pattern_ignorecase(void)
cl_git_mkfile("empty_standard_repo/A.txt", "Differs in case");
cl_git_pass(git_repository_index(&index, g_repo));
- ignore_case = index->ignore_case;
+ ignore_case = (git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0;
git_index_free(index);
cl_git_pass(git_status_file(&flags, g_repo, "A.txt"));
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 062a09aeb..13335843b 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -105,7 +105,7 @@ void test_status_worktree__swap_subdir_and_file(void)
bool ignore_case;
cl_git_pass(git_repository_index(&index, repo));
- ignore_case = index->ignore_case;
+ ignore_case = (git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0;
git_index_free(index);
/* first alter the contents of the worktree */