Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9224965

Browse files
committed
tree: use testrepo2 for the tree updater tests
This gives us trees with subdirectories, which the new test needs.
1 parent 1b56cda commit 9224965

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

tests/object/tree/update.c

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ static git_repository *g_repo;
55

66
void test_object_tree_update__initialize(void)
77
{
8-
g_repo = cl_git_sandbox_init("testrepo");
8+
g_repo = cl_git_sandbox_init("testrepo2");
99
}
1010

1111
void test_object_tree_update__cleanup(void)
1212
{
13-
cl_git_sandbox_cleanup();
13+
cl_git_sandbox_cleanup();
1414
}
1515

1616
void test_object_tree_update__remove_blob(void)
@@ -24,7 +24,36 @@ void test_object_tree_update__remove_blob(void)
2424
{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path},
2525
};
2626

27-
cl_git_pass(git_oid_fromstr(&base_id, "45dd856fdd4d89b884c340ba0e047752d9b085d6"));
27+
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
28+
cl_git_pass(git_tree_lookup(&base_tree, g_repo, &base_id));
29+
30+
/* Create it with an index */
31+
cl_git_pass(git_index_new(&idx));
32+
cl_git_pass(git_index_read_tree(idx, base_tree));
33+
cl_git_pass(git_index_remove(idx, path, 0));
34+
cl_git_pass(git_index_write_tree_to(&tree_index_id, idx, g_repo));
35+
git_index_free(idx);
36+
37+
/* Perform the same operation via the tree updater */
38+
cl_git_pass(git_tree_create_updated(&tree_updater_id, g_repo, base_tree, 1, updates));
39+
40+
cl_assert_equal_oid(&tree_index_id, &tree_updater_id);
41+
42+
git_tree_free(base_tree);
43+
}
44+
45+
void test_object_tree_update__remove_blob_deeper(void)
46+
{
47+
git_oid tree_index_id, tree_updater_id, base_id;
48+
git_tree *base_tree;
49+
git_index *idx;
50+
const char *path = "subdir/README";
51+
52+
git_tree_update updates[] = {
53+
{ GIT_TREE_UPDATE_REMOVE, {{0}}, GIT_FILEMODE_BLOB /* ignored */, path},
54+
};
55+
56+
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
2857
cl_git_pass(git_tree_lookup(&base_tree, g_repo, &base_id));
2958

3059
/* Create it with an index */
@@ -54,23 +83,23 @@ void test_object_tree_update__replace_blob(void)
5483
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, path},
5584
};
5685

57-
cl_git_pass(git_oid_fromstr(&base_id, "45dd856fdd4d89b884c340ba0e047752d9b085d6"));
86+
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
5887
cl_git_pass(git_tree_lookup(&base_tree, g_repo, &base_id));
5988

6089
/* Create it with an index */
6190
cl_git_pass(git_index_new(&idx));
6291
cl_git_pass(git_index_read_tree(idx, base_tree));
6392

6493
entry.path = path;
65-
cl_git_pass(git_oid_fromstr(&entry.id, "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"));
94+
cl_git_pass(git_oid_fromstr(&entry.id, "fa49b077972391ad58037050f2a75f74e3671e92"));
6695
entry.mode = GIT_FILEMODE_BLOB;
6796
cl_git_pass(git_index_add(idx, &entry));
6897

6998
cl_git_pass(git_index_write_tree_to(&tree_index_id, idx, g_repo));
7099
git_index_free(idx);
71100

72101
/* Perform the same operation via the tree updater */
73-
cl_git_pass(git_oid_fromstr(&updates[0].id, "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"));
102+
cl_git_pass(git_oid_fromstr(&updates[0].id, "fa49b077972391ad58037050f2a75f74e3671e92"));
74103
cl_git_pass(git_tree_create_updated(&tree_updater_id, g_repo, base_tree, 1, updates));
75104

76105
cl_assert_equal_oid(&tree_index_id, &tree_updater_id);
@@ -97,14 +126,14 @@ void test_object_tree_update__add_blobs(void)
97126
{ GIT_TREE_UPDATE_UPSERT, {{0}}, GIT_FILEMODE_BLOB, paths[2]},
98127
};
99128

100-
cl_git_pass(git_oid_fromstr(&base_id, "45dd856fdd4d89b884c340ba0e047752d9b085d6"));
129+
cl_git_pass(git_oid_fromstr(&base_id, "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"));
101130
cl_git_pass(git_tree_lookup(&base_tree, g_repo, &base_id));
102131

103132
entry.mode = GIT_FILEMODE_BLOB;
104-
cl_git_pass(git_oid_fromstr(&entry.id, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"));
133+
cl_git_pass(git_oid_fromstr(&entry.id, "fa49b077972391ad58037050f2a75f74e3671e92"));
105134

106135
for (i = 0; i < 3; i++) {
107-
cl_git_pass(git_oid_fromstr(&updates[i].id, "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"));
136+
cl_git_pass(git_oid_fromstr(&updates[i].id, "fa49b077972391ad58037050f2a75f74e3671e92"));
108137
}
109138

110139
for (i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)