Commit 4afe536b by Edward Thomson

tests: use legitimate object ids

Use legitimate (existing) object IDs in tests so that we have the
ability to turn on strict object validation when running tests.
parent 98c34149
...@@ -185,9 +185,9 @@ static void do_conflicted_diff(diff_expects *exp, unsigned long flags) ...@@ -185,9 +185,9 @@ static void do_conflicted_diff(diff_expects *exp, unsigned long flags)
ancestor.path = ours.path = theirs.path = "staged_changes"; ancestor.path = ours.path = theirs.path = "staged_changes";
ancestor.mode = ours.mode = theirs.mode = GIT_FILEMODE_BLOB; ancestor.mode = ours.mode = theirs.mode = GIT_FILEMODE_BLOB;
git_oid_fromstr(&ancestor.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&ancestor.id, "d427e0b2e138501a3d15cc376077a3631e15bd46");
git_oid_fromstr(&ours.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&ours.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
git_oid_fromstr(&theirs.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&theirs.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
cl_git_pass(git_index_conflict_add(index, &ancestor, &ours, &theirs)); cl_git_pass(git_index_conflict_add(index, &ancestor, &ours, &theirs));
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, &opts)); cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, &opts));
...@@ -255,7 +255,7 @@ void test_diff_index__not_in_head_conflicted(void) ...@@ -255,7 +255,7 @@ void test_diff_index__not_in_head_conflicted(void)
theirs.path = "file_not_in_head"; theirs.path = "file_not_in_head";
theirs.mode = GIT_FILEMODE_BLOB; theirs.mode = GIT_FILEMODE_BLOB;
git_oid_fromstr(&theirs.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&theirs.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
cl_git_pass(git_index_conflict_add(index, NULL, NULL, &theirs)); cl_git_pass(git_index_conflict_add(index, NULL, NULL, &theirs));
cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, NULL)); cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, index, NULL));
......
...@@ -85,9 +85,11 @@ void test_diff_workdir__to_index_with_conflicts(void) ...@@ -85,9 +85,11 @@ void test_diff_workdir__to_index_with_conflicts(void)
/* Adding an entry that represents a rename gets two files in conflict */ /* Adding an entry that represents a rename gets two files in conflict */
our_entry.path = "subdir/modified_file"; our_entry.path = "subdir/modified_file";
our_entry.mode = 0100644; our_entry.mode = 0100644;
git_oid_fromstr(&our_entry.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
their_entry.path = "subdir/rename_conflict"; their_entry.path = "subdir/rename_conflict";
their_entry.mode = 0100644; their_entry.mode = 0100644;
git_oid_fromstr(&their_entry.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
cl_git_pass(git_repository_index(&index, g_repo)); cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_index_conflict_add(index, NULL, &our_entry, &their_entry)); cl_git_pass(git_index_conflict_add(index, NULL, &our_entry, &their_entry));
...@@ -1975,9 +1977,9 @@ void test_diff_workdir__to_index_conflicted(void) { ...@@ -1975,9 +1977,9 @@ void test_diff_workdir__to_index_conflicted(void) {
ancestor.path = ours.path = theirs.path = "_file"; ancestor.path = ours.path = theirs.path = "_file";
ancestor.mode = ours.mode = theirs.mode = 0100644; ancestor.mode = ours.mode = theirs.mode = 0100644;
git_oid_fromstr(&ancestor.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&ancestor.id, "d427e0b2e138501a3d15cc376077a3631e15bd46");
git_oid_fromstr(&ours.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&ours.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
git_oid_fromstr(&theirs.id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); git_oid_fromstr(&theirs.id, "2bd0a343aeef7a2cf0d158478966a6e587ff3863");
cl_git_pass(git_index_conflict_add(index, &ancestor, &ours, &theirs)); cl_git_pass(git_index_conflict_add(index, &ancestor, &ours, &theirs));
cl_git_pass(git_diff_tree_to_index(&diff1, g_repo, a, index, NULL)); cl_git_pass(git_diff_tree_to_index(&diff1, g_repo, a, index, NULL));
......
...@@ -134,6 +134,7 @@ void test_index_bypath__add_honors_existing_case_2(void) ...@@ -134,6 +134,7 @@ void test_index_bypath__add_honors_existing_case_2(void)
clar__skip(); clar__skip();
dummy.mode = GIT_FILEMODE_BLOB; dummy.mode = GIT_FILEMODE_BLOB;
cl_git_pass(git_oid_fromstr(&dummy.id, "f990a25a74d1a8281ce2ab018ea8df66795cd60b"));
/* note that `git_index_add` does no checking to canonical directories */ /* note that `git_index_add` does no checking to canonical directories */
dummy.path = "Just_a_dir/file0.txt"; dummy.path = "Just_a_dir/file0.txt";
...@@ -189,6 +190,7 @@ void test_index_bypath__add_honors_existing_case_3(void) ...@@ -189,6 +190,7 @@ void test_index_bypath__add_honors_existing_case_3(void)
clar__skip(); clar__skip();
dummy.mode = GIT_FILEMODE_BLOB; dummy.mode = GIT_FILEMODE_BLOB;
cl_git_pass(git_oid_fromstr(&dummy.id, "f990a25a74d1a8281ce2ab018ea8df66795cd60b"));
dummy.path = "just_a_dir/filea.txt"; dummy.path = "just_a_dir/filea.txt";
cl_git_pass(git_index_add(g_idx, &dummy)); cl_git_pass(git_index_add(g_idx, &dummy));
...@@ -219,6 +221,7 @@ void test_index_bypath__add_honors_existing_case_4(void) ...@@ -219,6 +221,7 @@ void test_index_bypath__add_honors_existing_case_4(void)
clar__skip(); clar__skip();
dummy.mode = GIT_FILEMODE_BLOB; dummy.mode = GIT_FILEMODE_BLOB;
cl_git_pass(git_oid_fromstr(&dummy.id, "f990a25a74d1a8281ce2ab018ea8df66795cd60b"));
dummy.path = "just_a_dir/a/b/c/d/e/file1.txt"; dummy.path = "just_a_dir/a/b/c/d/e/file1.txt";
cl_git_pass(git_index_add(g_idx, &dummy)); cl_git_pass(git_index_add(g_idx, &dummy));
......
...@@ -111,7 +111,7 @@ void test_index_cache__read_tree_no_children(void) ...@@ -111,7 +111,7 @@ void test_index_cache__read_tree_no_children(void)
memset(&entry, 0x0, sizeof(git_index_entry)); memset(&entry, 0x0, sizeof(git_index_entry));
entry.path = "new.txt"; entry.path = "new.txt";
entry.mode = GIT_FILEMODE_BLOB; entry.mode = GIT_FILEMODE_BLOB;
git_oid_fromstr(&entry.id, "45b983be36b73c0788dc9cbcb76cbb80fc7bb057"); git_oid_fromstr(&entry.id, "d4bcc68acd4410bf836a39f20afb2c2ece09584e");
cl_git_pass(git_index_add(index, &entry)); cl_git_pass(git_index_add(index, &entry));
cl_assert_equal_i(-1, index->tree->entry_count); cl_assert_equal_i(-1, index->tree->entry_count);
...@@ -191,7 +191,7 @@ void test_index_cache__read_tree_children(void) ...@@ -191,7 +191,7 @@ void test_index_cache__read_tree_children(void)
memset(&entry, 0x0, sizeof(git_index_entry)); memset(&entry, 0x0, sizeof(git_index_entry));
entry.path = "top-level"; entry.path = "top-level";
entry.mode = GIT_FILEMODE_BLOB; entry.mode = GIT_FILEMODE_BLOB;
git_oid_fromstr(&entry.id, "45b983be36b73c0788dc9cbcb76cbb80fc7bb057"); git_oid_fromstr(&entry.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
cl_git_pass(git_index_add(index, &entry)); cl_git_pass(git_index_add(index, &entry));
...@@ -217,7 +217,7 @@ void test_index_cache__read_tree_children(void) ...@@ -217,7 +217,7 @@ void test_index_cache__read_tree_children(void)
/* override with a slightly different id, also dummy */ /* override with a slightly different id, also dummy */
entry.path = "subdir/some-file"; entry.path = "subdir/some-file";
git_oid_fromstr(&entry.id, "45b983be36b73c0788dc9cbcb76cbb80fc7bb058"); git_oid_fromstr(&entry.id, "ee3fa1b8c00aff7fe02065fdb50864bb0d932ccf");
cl_git_pass(git_index_add(index, &entry)); cl_git_pass(git_index_add(index, &entry));
cl_assert_equal_i(-1, index->tree->entry_count); cl_assert_equal_i(-1, index->tree->entry_count);
......
...@@ -16,11 +16,6 @@ static git_index *repo_index; ...@@ -16,11 +16,6 @@ static git_index *repo_index;
#define CONFLICTS_TWO_OUR_OID "8b3f43d2402825c200f835ca1762413e386fd0b2" #define CONFLICTS_TWO_OUR_OID "8b3f43d2402825c200f835ca1762413e386fd0b2"
#define CONFLICTS_TWO_THEIR_OID "220bd62631c8cf7a83ef39c6b94595f00517211e" #define CONFLICTS_TWO_THEIR_OID "220bd62631c8cf7a83ef39c6b94595f00517211e"
#define TEST_STAGED_OID "beefdadafeedabedcafedeedbabedeadbeaddeaf"
#define TEST_ANCESTOR_OID "f00ff00ff00ff00ff00ff00ff00ff00ff00ff00f"
#define TEST_OUR_OID "b44bb44bb44bb44bb44bb44bb44bb44bb44bb44b"
#define TEST_THEIR_OID "0123456789abcdef0123456789abcdef01234567"
// Fixture setup and teardown // Fixture setup and teardown
void test_index_conflicts__initialize(void) void test_index_conflicts__initialize(void)
{ {
...@@ -49,17 +44,17 @@ void test_index_conflicts__add(void) ...@@ -49,17 +44,17 @@ void test_index_conflicts__add(void)
ancestor_entry.path = "test-one.txt"; ancestor_entry.path = "test-one.txt";
ancestor_entry.mode = 0100644; ancestor_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1); GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); git_oid_fromstr(&ancestor_entry.id, CONFLICTS_ONE_ANCESTOR_OID);
our_entry.path = "test-one.txt"; our_entry.path = "test-one.txt";
our_entry.mode = 0100644; our_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&our_entry, 2); GIT_IDXENTRY_STAGE_SET(&our_entry, 2);
git_oid_fromstr(&our_entry.id, TEST_OUR_OID); git_oid_fromstr(&our_entry.id, CONFLICTS_ONE_OUR_OID);
their_entry.path = "test-one.txt"; their_entry.path = "test-one.txt";
their_entry.mode = 0100644; their_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 2); GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 2);
git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); git_oid_fromstr(&their_entry.id, CONFLICTS_ONE_THEIR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
...@@ -80,17 +75,17 @@ void test_index_conflicts__add_fixes_incorrect_stage(void) ...@@ -80,17 +75,17 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
ancestor_entry.path = "test-one.txt"; ancestor_entry.path = "test-one.txt";
ancestor_entry.mode = 0100644; ancestor_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3); GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); git_oid_fromstr(&ancestor_entry.id, CONFLICTS_ONE_ANCESTOR_OID);
our_entry.path = "test-one.txt"; our_entry.path = "test-one.txt";
our_entry.mode = 0100644; our_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&our_entry, 1); GIT_IDXENTRY_STAGE_SET(&our_entry, 1);
git_oid_fromstr(&our_entry.id, TEST_OUR_OID); git_oid_fromstr(&our_entry.id, CONFLICTS_ONE_OUR_OID);
their_entry.path = "test-one.txt"; their_entry.path = "test-one.txt";
their_entry.mode = 0100644; their_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&their_entry, 2); GIT_IDXENTRY_STAGE_SET(&their_entry, 2);
git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); git_oid_fromstr(&their_entry.id, CONFLICTS_ONE_THEIR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
...@@ -105,36 +100,33 @@ void test_index_conflicts__add_fixes_incorrect_stage(void) ...@@ -105,36 +100,33 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
void test_index_conflicts__add_removes_stage_zero(void) void test_index_conflicts__add_removes_stage_zero(void)
{ {
git_index_entry staged, ancestor_entry, our_entry, their_entry; git_index_entry ancestor_entry, our_entry, their_entry;
const git_index_entry *conflict_entry[3]; const git_index_entry *conflict_entry[3];
cl_assert(git_index_entrycount(repo_index) == 8); cl_assert(git_index_entrycount(repo_index) == 8);
memset(&staged, 0x0, sizeof(git_index_entry));
memset(&ancestor_entry, 0x0, sizeof(git_index_entry)); memset(&ancestor_entry, 0x0, sizeof(git_index_entry));
memset(&our_entry, 0x0, sizeof(git_index_entry)); memset(&our_entry, 0x0, sizeof(git_index_entry));
memset(&their_entry, 0x0, sizeof(git_index_entry)); memset(&their_entry, 0x0, sizeof(git_index_entry));
staged.path = "test-one.txt"; cl_git_mkfile("./mergedrepo/test-one.txt", "new-file\n");
staged.mode = 0100644; cl_git_pass(git_index_add_bypath(repo_index, "test-one.txt"));
git_oid_fromstr(&staged.id, TEST_STAGED_OID);
cl_git_pass(git_index_add(repo_index, &staged));
cl_assert(git_index_entrycount(repo_index) == 9); cl_assert(git_index_entrycount(repo_index) == 9);
ancestor_entry.path = "test-one.txt"; ancestor_entry.path = "test-one.txt";
ancestor_entry.mode = 0100644; ancestor_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3); GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 3);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); git_oid_fromstr(&ancestor_entry.id, CONFLICTS_ONE_ANCESTOR_OID);
our_entry.path = "test-one.txt"; our_entry.path = "test-one.txt";
our_entry.mode = 0100644; our_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&our_entry, 1); GIT_IDXENTRY_STAGE_SET(&our_entry, 1);
git_oid_fromstr(&our_entry.id, TEST_OUR_OID); git_oid_fromstr(&our_entry.id, CONFLICTS_ONE_OUR_OID);
their_entry.path = "test-one.txt"; their_entry.path = "test-one.txt";
their_entry.mode = 0100644; their_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&their_entry, 2); GIT_IDXENTRY_STAGE_SET(&their_entry, 2);
git_oid_fromstr(&their_entry.id, TEST_THEIR_OID); git_oid_fromstr(&their_entry.id, CONFLICTS_ONE_THEIR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry)); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, &our_entry, &their_entry));
...@@ -330,7 +322,7 @@ void test_index_conflicts__partial(void) ...@@ -330,7 +322,7 @@ void test_index_conflicts__partial(void)
ancestor_entry.path = "test-one.txt"; ancestor_entry.path = "test-one.txt";
ancestor_entry.mode = 0100644; ancestor_entry.mode = 0100644;
GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1); GIT_IDXENTRY_STAGE_SET(&ancestor_entry, 1);
git_oid_fromstr(&ancestor_entry.id, TEST_ANCESTOR_OID); git_oid_fromstr(&ancestor_entry.id, CONFLICTS_ONE_ANCESTOR_OID);
cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, NULL, NULL)); cl_git_pass(git_index_conflict_add(repo_index, &ancestor_entry, NULL, NULL));
cl_assert(git_index_entrycount(repo_index) == 9); cl_assert(git_index_entrycount(repo_index) == 9);
......
...@@ -236,12 +236,19 @@ void test_index_filemodes__invalid(void) ...@@ -236,12 +236,19 @@ void test_index_filemodes__invalid(void)
{ {
git_index *index; git_index *index;
git_index_entry entry; git_index_entry entry;
const git_index_entry *dummy;
cl_git_pass(git_repository_index(&index, g_repo)); cl_git_pass(git_repository_index(&index, g_repo));
/* add a dummy file so that we have a valid id */
cl_git_mkfile("./filemodes/dummy-file.txt", "new-file\n");
cl_git_pass(git_index_add_bypath(index, "dummy-file.txt"));
cl_assert((dummy = git_index_get_bypath(index, "dummy-file.txt", 0)));
GIT_IDXENTRY_STAGE_SET(&entry, 0); GIT_IDXENTRY_STAGE_SET(&entry, 0);
entry.path = "foo"; entry.path = "foo";
entry.mode = GIT_OBJ_BLOB; entry.mode = GIT_OBJ_BLOB;
git_oid_cpy(&entry.id, &dummy->id);
cl_git_fail(git_index_add(index, &entry)); cl_git_fail(git_index_add(index, &entry));
entry.mode = GIT_FILEMODE_BLOB; entry.mode = GIT_FILEMODE_BLOB;
......
...@@ -178,6 +178,7 @@ static void setup_uptodate_files(void) ...@@ -178,6 +178,7 @@ static void setup_uptodate_files(void)
{ {
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
git_index *index; git_index *index;
const git_index_entry *a_entry;
git_index_entry new_entry = {{0}}; git_index_entry new_entry = {{0}};
cl_git_pass(git_repository_index(&index, g_repo)); cl_git_pass(git_repository_index(&index, g_repo));
...@@ -188,9 +189,12 @@ static void setup_uptodate_files(void) ...@@ -188,9 +189,12 @@ static void setup_uptodate_files(void)
/* Put 'A' into the index */ /* Put 'A' into the index */
cl_git_pass(git_index_add_bypath(index, "A")); cl_git_pass(git_index_add_bypath(index, "A"));
cl_assert((a_entry = git_index_get_bypath(index, "A", 0)));
/* Put 'B' into the index */ /* Put 'B' into the index */
new_entry.path = "B"; new_entry.path = "B";
new_entry.mode = GIT_FILEMODE_BLOB; new_entry.mode = GIT_FILEMODE_BLOB;
git_oid_cpy(&new_entry.id, &a_entry->id);
cl_git_pass(git_index_add(index, &new_entry)); cl_git_pass(git_index_add(index, &new_entry));
/* Put 'C' into the index */ /* Put 'C' into the index */
......
...@@ -133,15 +133,18 @@ void test_object_tree_write__sorted_subtrees(void) ...@@ -133,15 +133,18 @@ void test_object_tree_write__sorted_subtrees(void)
{ GIT_FILEMODE_TREE, "vendors"} { GIT_FILEMODE_TREE, "vendors"}
}; };
git_oid blank_oid, tree_oid; git_oid bid, tid, tree_oid;
memset(&blank_oid, 0x0, sizeof(blank_oid)); cl_git_pass(git_oid_fromstr(&bid, blob_oid));
cl_git_pass(git_oid_fromstr(&tid, first_tree));
cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL)); cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL));
for (i = 0; i < ARRAY_SIZE(entries); ++i) { for (i = 0; i < ARRAY_SIZE(entries); ++i) {
git_oid *id = entries[i].attr == GIT_FILEMODE_TREE ? &tid : &bid;
cl_git_pass(git_treebuilder_insert(NULL, cl_git_pass(git_treebuilder_insert(NULL,
builder, entries[i].filename, &blank_oid, entries[i].attr)); builder, entries[i].filename, id, entries[i].attr));
} }
cl_git_pass(git_treebuilder_write(&tree_oid, builder)); cl_git_pass(git_treebuilder_write(&tree_oid, builder));
...@@ -189,10 +192,10 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void) ...@@ -189,10 +192,10 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void)
{ {
git_treebuilder *builder; git_treebuilder *builder;
int i, aardvark_i, apple_i, apple_after_i, apple_extra_i, last_i; int i, aardvark_i, apple_i, apple_after_i, apple_extra_i, last_i;
git_oid blank_oid, tree_oid; git_oid entry_oid, tree_oid;
git_tree *tree; git_tree *tree;
memset(&blank_oid, 0x0, sizeof(blank_oid)); cl_git_pass(git_oid_fromstr(&entry_oid, blob_oid));
cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL)); cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL));
...@@ -200,7 +203,7 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void) ...@@ -200,7 +203,7 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void)
for (i = 0; _entries[i].filename; ++i) for (i = 0; _entries[i].filename; ++i)
cl_git_pass(git_treebuilder_insert(NULL, cl_git_pass(git_treebuilder_insert(NULL,
builder, _entries[i].filename, &blank_oid, _entries[i].attr)); builder, _entries[i].filename, &entry_oid, _entries[i].attr));
cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder));
...@@ -211,12 +214,12 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void) ...@@ -211,12 +214,12 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void)
cl_assert_equal_i(4, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(4, (int)git_treebuilder_entrycount(builder));
cl_git_pass(git_treebuilder_insert( cl_git_pass(git_treebuilder_insert(
NULL, builder, "before_last", &blank_oid, GIT_FILEMODE_BLOB)); NULL, builder, "before_last", &entry_oid, GIT_FILEMODE_BLOB));
cl_assert_equal_i(5, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(5, (int)git_treebuilder_entrycount(builder));
/* reinsert apple_after */ /* reinsert apple_after */
cl_git_pass(git_treebuilder_insert( cl_git_pass(git_treebuilder_insert(
NULL, builder, "apple_after", &blank_oid, GIT_FILEMODE_BLOB)); NULL, builder, "apple_after", &entry_oid, GIT_FILEMODE_BLOB));
cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder));
cl_git_pass(git_treebuilder_remove(builder, "last")); cl_git_pass(git_treebuilder_remove(builder, "last"));
...@@ -224,11 +227,11 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void) ...@@ -224,11 +227,11 @@ void test_object_tree_write__removing_and_re_adding_in_treebuilder(void)
/* reinsert last */ /* reinsert last */
cl_git_pass(git_treebuilder_insert( cl_git_pass(git_treebuilder_insert(
NULL, builder, "last", &blank_oid, GIT_FILEMODE_BLOB)); NULL, builder, "last", &entry_oid, GIT_FILEMODE_BLOB));
cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder));
cl_git_pass(git_treebuilder_insert( cl_git_pass(git_treebuilder_insert(
NULL, builder, "apple_extra", &blank_oid, GIT_FILEMODE_BLOB)); NULL, builder, "apple_extra", &entry_oid, GIT_FILEMODE_BLOB));
cl_assert_equal_i(7, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(7, (int)git_treebuilder_entrycount(builder));
cl_git_pass(git_treebuilder_write(&tree_oid, builder)); cl_git_pass(git_treebuilder_write(&tree_oid, builder));
...@@ -280,16 +283,16 @@ void test_object_tree_write__filtering(void) ...@@ -280,16 +283,16 @@ void test_object_tree_write__filtering(void)
{ {
git_treebuilder *builder; git_treebuilder *builder;
int i; int i;
git_oid blank_oid, tree_oid; git_oid entry_oid, tree_oid;
git_tree *tree; git_tree *tree;
memset(&blank_oid, 0x0, sizeof(blank_oid)); git_oid_fromstr(&entry_oid, blob_oid);
cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL)); cl_git_pass(git_treebuilder_new(&builder, g_repo, NULL));
for (i = 0; _entries[i].filename; ++i) for (i = 0; _entries[i].filename; ++i)
cl_git_pass(git_treebuilder_insert(NULL, cl_git_pass(git_treebuilder_insert(NULL,
builder, _entries[i].filename, &blank_oid, _entries[i].attr)); builder, _entries[i].filename, &entry_oid, _entries[i].attr));
cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder)); cl_assert_equal_i(6, (int)git_treebuilder_entrycount(builder));
...@@ -408,6 +411,8 @@ void test_object_tree_write__protect_filesystems(void) ...@@ -408,6 +411,8 @@ void test_object_tree_write__protect_filesystems(void)
git_treebuilder *builder; git_treebuilder *builder;
git_oid bid; git_oid bid;
cl_git_pass(git_oid_fromstr(&bid, "fa49b077972391ad58037050f2a75f74e3671e92"));
/* Ensure that (by default) we can write objects with funny names on /* Ensure that (by default) we can write objects with funny names on
* platforms that are not affected. * platforms that are not affected.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment