Merge pull request #448 from nulltoken/ntk/topic/treeentry-random-access Add git_tree_frompath()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
diff --git a/include/git2/oid.h b/include/git2/oid.h
index f9636d1..b9824b8 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -150,6 +150,16 @@ GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, unsigned int len);
/**
+ * Check if an oid equals an hex formatted object id.
+ *
+ * @param a oid structure.
+ * @param str input hex string of an object id.
+ * @return GIT_ENOTOID if str is not a valid hex string,
+ * GIT_SUCCESS in case of a match, GIT_ERROR otherwise.
+ */
+GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str);
+
+/**
* OID Shortener object
*/
typedef struct git_oid_shorten git_oid_shorten;
diff --git a/include/git2/tree.h b/include/git2/tree.h
index d781ea1..8d638f7 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -268,6 +268,20 @@ GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(cons
*/
GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld);
+/**
+ * Retrieve the tree object containing a tree entry, given
+ * a relative path to this tree entry
+ *
+ * The returned tree is owned by the repository and
+ * should be closed with the `git_object_close` method.
+ *
+ * @param parent_out Pointer where to store the parent tree
+ * @param root A previously loaded tree which will be the root of the relative path
+ * @param treeentry_path Path to the tree entry from which to extract the last tree object
+ * @return GIT_SUCCESS on success; GIT_ENOTFOUND if the path does not lead to an
+ * entry, GIT_EINVALIDPATH or an error code
+ */
+GIT_EXTERN(int) git_tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path);
/** @} */
GIT_END_DECL
#endif
diff --git a/src/oid.c b/src/oid.c
index b47fa2c..bbf19ea 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -197,6 +197,17 @@ int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, unsigned int len)
return 0;
}
+int git_oid_streq(const git_oid *a, const char *str)
+{
+ git_oid id;
+ int error;
+
+ if ((error = git_oid_fromstr(&id, str)) < GIT_SUCCESS)
+ return git__rethrow(error, "Failed to convert '%s' to oid.", str);
+
+ return git_oid_cmp(a, &id) == 0 ? GIT_SUCCESS : GIT_ERROR;
+}
+
typedef short node_index;
typedef union {
diff --git a/src/transports/http.c b/src/transports/http.c
index 3426b34..680354b 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -502,7 +502,6 @@ cleanup:
static int http_negotiate_fetch(git_transport *transport, git_repository *repo, git_headarray *wants)
{
transport_http *t = (transport_http *) transport;
- GIT_UNUSED_ARG(list);
int error;
unsigned int i;
char buff[128];
diff --git a/src/tree.c b/src/tree.c
index 0acf74e..3801df1 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -559,4 +559,49 @@ void git_treebuilder_free(git_treebuilder *bld)
free(bld);
}
+static int tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path, int offset)
+{
+ char *slash_pos = NULL;
+ const git_tree_entry* entry;
+ int error = GIT_SUCCESS;
+ git_tree *subtree;
+
+ if (!*(treeentry_path + offset))
+ return git__rethrow(GIT_EINVALIDPATH, "Invalid relative path to a tree entry '%s'.", treeentry_path);
+
+ slash_pos = (char *)strchr(treeentry_path + offset, '/');
+
+ if (slash_pos == NULL)
+ return git_tree_lookup(parent_out, root->object.repo, git_object_id((const git_object *)root));
+
+ if (slash_pos == treeentry_path + offset)
+ return git__rethrow(GIT_EINVALIDPATH, "Invalid relative path to a tree entry '%s'.", treeentry_path);
+
+ *slash_pos = '\0';
+
+ entry = git_tree_entry_byname(root, treeentry_path + offset);
+
+ if (slash_pos != NULL)
+ *slash_pos = '/';
+
+ if (entry == NULL)
+ return git__rethrow(GIT_ENOTFOUND, "No tree entry can be found from the given tree and relative path '%s'.", treeentry_path);
+ if ((error = git_tree_lookup(&subtree, root->object.repo, &entry->oid)) < GIT_SUCCESS)
+ return error;
+
+ error = tree_frompath(parent_out, subtree, treeentry_path, slash_pos - treeentry_path + 1);
+
+ git_tree_close(subtree);
+ return error;
+}
+
+int git_tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path)
+{
+ char buffer[GIT_PATH_MAX];
+
+ assert(root && treeentry_path);
+
+ strcpy(buffer, treeentry_path);
+ return tree_frompath(parent_out, root, buffer, 0);
+}
diff --git a/tests-clay/clay.h b/tests-clay/clay.h
index 184635e..bc4267b 100644
--- a/tests-clay/clay.h
+++ b/tests-clay/clay.h
@@ -57,17 +57,6 @@ void cl_fixture_cleanup(const char *fixture_name);
/**
* Test method declarations
*/
-extern void test_status_single__hash_single_file(void);
-extern void test_status_worktree__initialize(void);
-extern void test_status_worktree__cleanup(void);
-extern void test_status_worktree__whole_repository(void);
-extern void test_status_worktree__empty_repository(void);
-extern void test_network_remotes__initialize(void);
-extern void test_network_remotes__cleanup(void);
-extern void test_network_remotes__parsing(void);
-extern void test_network_remotes__refspec_parsing(void);
-extern void test_network_remotes__fnmatch(void);
-extern void test_network_remotes__transform(void);
extern void test_core_dirent__dont_traverse_dot(void);
extern void test_core_dirent__traverse_subfolder(void);
extern void test_core_dirent__traverse_slash_terminated_folder(void);
@@ -76,6 +65,8 @@ extern void test_core_dirent__traverse_weird_filenames(void);
extern void test_core_filebuf__0(void);
extern void test_core_filebuf__1(void);
extern void test_core_filebuf__2(void);
+extern void test_core_oid__initialize(void);
+extern void test_core_oid__streq(void);
extern void test_core_path__0(void);
extern void test_core_path__1(void);
extern void test_core_path__2(void);
@@ -91,5 +82,21 @@ extern void test_core_strtol__int64(void);
extern void test_core_vector__0(void);
extern void test_core_vector__1(void);
extern void test_core_vector__2(void);
+extern void test_network_remotes__initialize(void);
+extern void test_network_remotes__cleanup(void);
+extern void test_network_remotes__parsing(void);
+extern void test_network_remotes__refspec_parsing(void);
+extern void test_network_remotes__fnmatch(void);
+extern void test_network_remotes__transform(void);
+extern void test_object_tree_frompath__initialize(void);
+extern void test_object_tree_frompath__cleanup(void);
+extern void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void);
+extern void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void);
+extern void test_object_tree_frompath__fail_when_processing_an_invalid_path(void);
+extern void test_status_single__hash_single_file(void);
+extern void test_status_worktree__initialize(void);
+extern void test_status_worktree__cleanup(void);
+extern void test_status_worktree__whole_repository(void);
+extern void test_status_worktree__empty_repository(void);
#endif
diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c
index cca23f4..da90872 100644
--- a/tests-clay/clay_main.c
+++ b/tests-clay/clay_main.c
@@ -660,107 +660,123 @@ cl_fs_cleanup(void)
static const struct clay_func _all_callbacks[] = {
- {"hash_single_file", &test_status_single__hash_single_file, 0},
- {"whole_repository", &test_status_worktree__whole_repository, 1},
- {"empty_repository", &test_status_worktree__empty_repository, 1},
- {"parsing", &test_network_remotes__parsing, 2},
- {"refspec_parsing", &test_network_remotes__refspec_parsing, 2},
- {"fnmatch", &test_network_remotes__fnmatch, 2},
- {"transform", &test_network_remotes__transform, 2},
- {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 3},
- {"traverse_subfolder", &test_core_dirent__traverse_subfolder, 3},
- {"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder, 3},
- {"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders, 3},
- {"traverse_weird_filenames", &test_core_dirent__traverse_weird_filenames, 3},
- {"0", &test_core_filebuf__0, 4},
- {"1", &test_core_filebuf__1, 4},
- {"2", &test_core_filebuf__2, 4},
- {"0", &test_core_path__0, 5},
- {"1", &test_core_path__1, 5},
- {"2", &test_core_path__2, 5},
- {"5", &test_core_path__5, 5},
- {"6", &test_core_path__6, 5},
- {"delete_recursive", &test_core_rmdir__delete_recursive, 6},
- {"fail_to_delete_non_empty_dir", &test_core_rmdir__fail_to_delete_non_empty_dir, 6},
- {"0", &test_core_string__0, 7},
- {"1", &test_core_string__1, 7},
- {"int32", &test_core_strtol__int32, 8},
- {"int64", &test_core_strtol__int64, 8},
- {"0", &test_core_vector__0, 9},
- {"1", &test_core_vector__1, 9},
- {"2", &test_core_vector__2, 9}
+ {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 0},
+ {"traverse_subfolder", &test_core_dirent__traverse_subfolder, 0},
+ {"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder, 0},
+ {"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders, 0},
+ {"traverse_weird_filenames", &test_core_dirent__traverse_weird_filenames, 0},
+ {"0", &test_core_filebuf__0, 1},
+ {"1", &test_core_filebuf__1, 1},
+ {"2", &test_core_filebuf__2, 1},
+ {"streq", &test_core_oid__streq, 2},
+ {"0", &test_core_path__0, 3},
+ {"1", &test_core_path__1, 3},
+ {"2", &test_core_path__2, 3},
+ {"5", &test_core_path__5, 3},
+ {"6", &test_core_path__6, 3},
+ {"delete_recursive", &test_core_rmdir__delete_recursive, 4},
+ {"fail_to_delete_non_empty_dir", &test_core_rmdir__fail_to_delete_non_empty_dir, 4},
+ {"0", &test_core_string__0, 5},
+ {"1", &test_core_string__1, 5},
+ {"int32", &test_core_strtol__int32, 6},
+ {"int64", &test_core_strtol__int64, 6},
+ {"0", &test_core_vector__0, 7},
+ {"1", &test_core_vector__1, 7},
+ {"2", &test_core_vector__2, 7},
+ {"parsing", &test_network_remotes__parsing, 8},
+ {"refspec_parsing", &test_network_remotes__refspec_parsing, 8},
+ {"fnmatch", &test_network_remotes__fnmatch, 8},
+ {"transform", &test_network_remotes__transform, 8},
+ {"retrieve_tree_from_path_to_treeentry", &test_object_tree_frompath__retrieve_tree_from_path_to_treeentry, 9},
+ {"fail_when_processing_an_unknown_tree_segment", &test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment, 9},
+ {"fail_when_processing_an_invalid_path", &test_object_tree_frompath__fail_when_processing_an_invalid_path, 9},
+ {"hash_single_file", &test_status_single__hash_single_file, 10},
+ {"whole_repository", &test_status_worktree__whole_repository, 11},
+ {"empty_repository", &test_status_worktree__empty_repository, 11}
};
static const struct clay_suite _all_suites[] = {
{
- "status::single",
+ "core::dirent",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[0], 1
+ &_all_callbacks[0], 5
},
{
- "status::worktree",
- {"initialize", &test_status_worktree__initialize, 1},
- {"cleanup", &test_status_worktree__cleanup, 1},
- &_all_callbacks[1], 2
- },
- {
- "network::remotes",
- {"initialize", &test_network_remotes__initialize, 2},
- {"cleanup", &test_network_remotes__cleanup, 2},
- &_all_callbacks[3], 4
- },
- {
- "core::dirent",
+ "core::filebuf",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[7], 5
+ &_all_callbacks[5], 3
},
{
- "core::filebuf",
- {NULL, NULL, 0},
+ "core::oid",
+ {"initialize", &test_core_oid__initialize, 2},
{NULL, NULL, 0},
- &_all_callbacks[12], 3
+ &_all_callbacks[8], 1
},
{
"core::path",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[15], 5
+ &_all_callbacks[9], 5
},
{
"core::rmdir",
- {"initialize", &test_core_rmdir__initialize, 6},
+ {"initialize", &test_core_rmdir__initialize, 4},
{NULL, NULL, 0},
- &_all_callbacks[20], 2
+ &_all_callbacks[14], 2
},
{
"core::string",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[22], 2
+ &_all_callbacks[16], 2
},
{
"core::strtol",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[24], 2
+ &_all_callbacks[18], 2
},
{
"core::vector",
{NULL, NULL, 0},
{NULL, NULL, 0},
- &_all_callbacks[26], 3
+ &_all_callbacks[20], 3
+ },
+ {
+ "network::remotes",
+ {"initialize", &test_network_remotes__initialize, 8},
+ {"cleanup", &test_network_remotes__cleanup, 8},
+ &_all_callbacks[23], 4
+ },
+ {
+ "object::tree::frompath",
+ {"initialize", &test_object_tree_frompath__initialize, 9},
+ {"cleanup", &test_object_tree_frompath__cleanup, 9},
+ &_all_callbacks[27], 3
+ },
+ {
+ "status::single",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[30], 1
+ },
+ {
+ "status::worktree",
+ {"initialize", &test_status_worktree__initialize, 11},
+ {"cleanup", &test_status_worktree__cleanup, 11},
+ &_all_callbacks[31], 2
}
};
-static const char _suites_str[] = "status::single, status::worktree, network::remotes, core::dirent, core::filebuf, core::path, core::rmdir, core::string, core::strtol, core::vector";
+static const char _suites_str[] = "core::dirent, core::filebuf, core::oid, core::path, core::rmdir, core::string, core::strtol, core::vector, network::remotes, object::tree::frompath, status::single, status::worktree";
int _MAIN_CC main(int argc, char *argv[])
{
return clay_test(
argc, argv, _suites_str,
- _all_callbacks, 29,
- _all_suites, 10
+ _all_callbacks, 33,
+ _all_suites, 12
);
}
diff --git a/tests-clay/core/oid.c b/tests-clay/core/oid.c
new file mode 100644
index 0000000..44597c5
--- /dev/null
+++ b/tests-clay/core/oid.c
@@ -0,0 +1,18 @@
+#include "clay_libgit2.h"
+
+static git_oid id;
+const char *str_oid = "ae90f12eea699729ed24555e40b9fd669da12a12";
+
+void test_core_oid__initialize(void)
+{
+ cl_git_pass(git_oid_fromstr(&id, str_oid));
+}
+
+void test_core_oid__streq(void)
+{
+ cl_assert(git_oid_streq(&id, str_oid) == GIT_SUCCESS);
+ cl_assert(git_oid_streq(&id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef") == GIT_ERROR);
+
+ cl_assert(git_oid_streq(&id, "deadbeef") == GIT_ENOTOID);
+ cl_assert(git_oid_streq(&id, "I'm not an oid.... :)") == GIT_ENOTOID);
+}
\ No newline at end of file
diff --git a/tests-clay/object/tree/frompath.c b/tests-clay/object/tree/frompath.c
new file mode 100644
index 0000000..33a76e8
--- /dev/null
+++ b/tests-clay/object/tree/frompath.c
@@ -0,0 +1,76 @@
+#include "clay_libgit2.h"
+
+#define REPOSITORY_FOLDER "testrepo.git"
+
+static git_repository *repo;
+const char *tree_with_subtrees_oid = "ae90f12eea699729ed24555e40b9fd669da12a12";
+static git_tree *tree;
+
+void test_object_tree_frompath__initialize(void)
+{
+ git_oid id;
+
+ cl_fixture_sandbox(REPOSITORY_FOLDER);
+ cl_git_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ cl_assert(repo != NULL);
+
+ cl_git_pass(git_oid_fromstr(&id, tree_with_subtrees_oid));
+ cl_git_pass(git_tree_lookup(&tree, repo, &id));
+ cl_assert(tree != NULL);
+}
+
+void test_object_tree_frompath__cleanup(void)
+{
+ git_tree_close(tree);
+ git_repository_free(repo);
+}
+
+static void assert_tree_from_path(git_tree *root, const char *path, git_error expected_result, const char *expected_raw_oid)
+{
+ git_tree *containing_tree = NULL;
+
+ cl_assert(git_tree_frompath(&containing_tree, root, path) == expected_result);
+
+ if (containing_tree == NULL && expected_result != GIT_SUCCESS)
+ return;
+
+ cl_assert(containing_tree != NULL && expected_result == GIT_SUCCESS);
+
+ cl_assert(git_oid_streq(git_object_id((const git_object *)containing_tree), expected_raw_oid) == GIT_SUCCESS);
+
+ git_tree_close(containing_tree);
+}
+
+void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void)
+{
+ /* Will return self if given a one path segment... */
+ assert_tree_from_path(tree, "README", GIT_SUCCESS, tree_with_subtrees_oid);
+
+ /* ...even one that lead to a non existent tree entry. */
+ assert_tree_from_path(tree, "i-do-not-exist.txt", GIT_SUCCESS, tree_with_subtrees_oid);
+
+ /* Will return fgh tree oid given this following path... */
+ assert_tree_from_path(tree, "ab/de/fgh/1.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
+
+ /* ... and ab tree oid given this one. */
+ assert_tree_from_path(tree, "ab/de", GIT_SUCCESS, "f1425cef211cc08caa31e7b545ffb232acb098c3");
+
+ /* Will succeed if given a valid path which leads to a tree entry which doesn't exist */
+ assert_tree_from_path(tree, "ab/de/fgh/i-do-not-exist.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
+}
+
+void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void)
+{
+ assert_tree_from_path(tree, "nope/de/fgh/1.txt", GIT_ENOTFOUND, NULL);
+ assert_tree_from_path(tree, "ab/me-neither/fgh/2.txt", GIT_ENOTFOUND, NULL);
+}
+
+void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)
+{
+ assert_tree_from_path(tree, "/", GIT_EINVALIDPATH, NULL);
+ assert_tree_from_path(tree, "/ab", GIT_EINVALIDPATH, NULL);
+ assert_tree_from_path(tree, "/ab/de", GIT_EINVALIDPATH, NULL);
+ assert_tree_from_path(tree, "ab/", GIT_EINVALIDPATH, NULL);
+ assert_tree_from_path(tree, "ab//de", GIT_EINVALIDPATH, NULL);
+ assert_tree_from_path(tree, "ab/de/", GIT_EINVALIDPATH, NULL);
+}
diff --git a/tests/resources/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b b/tests/resources/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b
new file mode 100644
index 0000000..225c457
Binary files /dev/null and b/tests/resources/testrepo.git/objects/1f/67fc4386b2d171e0d21be1c447e12660561f9b differ
diff --git a/tests/resources/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d b/tests/resources/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d
new file mode 100644
index 0000000..df40d99
Binary files /dev/null and b/tests/resources/testrepo.git/objects/27/0b8ea76056d5cad83af921837702d3e3c2924d differ
diff --git a/tests/resources/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 b/tests/resources/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54
new file mode 100644
index 0000000..321eaa8
Binary files /dev/null and b/tests/resources/testrepo.git/objects/32/59a6bd5b57fb9c1281bb7ed3167b50f224cb54 differ
diff --git a/tests/resources/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af b/tests/resources/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af
new file mode 100644
index 0000000..716b0c6
--- /dev/null
+++ b/tests/resources/testrepo.git/objects/76/3d71aadf09a7951596c9746c024e7eece7c7af
@@ -0,0 +1 @@
+xAj!?009o}H6}jUPPZ&Y AԛpFdpz[fYPqLJ.,Z`Ů.`vq
$5+9Ot>/DE/龡W*eVdf1>覭ěʙFThk.i^0?PR,
\ No newline at end of file
diff --git a/tests/resources/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 b/tests/resources/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4
new file mode 100644
index 0000000..bf7b2bb
Binary files /dev/null and b/tests/resources/testrepo.git/objects/9a/03079b8a8ee85a0bee58bf9be3da8b62414ed4 differ
diff --git a/tests/resources/testrepo.git/objects/ae/90f12eea699729ed24555e40b9fd669da12a12 b/tests/resources/testrepo.git/objects/ae/90f12eea699729ed24555e40b9fd669da12a12
new file mode 100644
index 0000000..d952546
Binary files /dev/null and b/tests/resources/testrepo.git/objects/ae/90f12eea699729ed24555e40b9fd669da12a12 differ
diff --git a/tests/resources/testrepo.git/objects/b6/361fc6a97178d8fc8639fdeed71c775ab52593 b/tests/resources/testrepo.git/objects/b6/361fc6a97178d8fc8639fdeed71c775ab52593
new file mode 100644
index 0000000..f613670
Binary files /dev/null and b/tests/resources/testrepo.git/objects/b6/361fc6a97178d8fc8639fdeed71c775ab52593 differ
diff --git a/tests/resources/testrepo.git/objects/d6/c93164c249c8000205dd4ec5cbca1b516d487f b/tests/resources/testrepo.git/objects/d6/c93164c249c8000205dd4ec5cbca1b516d487f
new file mode 100644
index 0000000..a67d6e6
Binary files /dev/null and b/tests/resources/testrepo.git/objects/d6/c93164c249c8000205dd4ec5cbca1b516d487f differ
diff --git a/tests/resources/testrepo.git/objects/e7/b4ad382349ff96dd8199000580b9b1e2042eb0 b/tests/resources/testrepo.git/objects/e7/b4ad382349ff96dd8199000580b9b1e2042eb0
new file mode 100644
index 0000000..b135ecc
Binary files /dev/null and b/tests/resources/testrepo.git/objects/e7/b4ad382349ff96dd8199000580b9b1e2042eb0 differ
diff --git a/tests/resources/testrepo.git/objects/f1/425cef211cc08caa31e7b545ffb232acb098c3 b/tests/resources/testrepo.git/objects/f1/425cef211cc08caa31e7b545ffb232acb098c3
new file mode 100644
index 0000000..82e2790
Binary files /dev/null and b/tests/resources/testrepo.git/objects/f1/425cef211cc08caa31e7b545ffb232acb098c3 differ
diff --git a/tests/resources/testrepo.git/refs/heads/subtrees b/tests/resources/testrepo.git/refs/heads/subtrees
new file mode 100644
index 0000000..ad27e0b
--- /dev/null
+++ b/tests/resources/testrepo.git/refs/heads/subtrees
@@ -0,0 +1 @@
+763d71aadf09a7951596c9746c024e7eece7c7af
diff --git a/tests/t09-tree.c b/tests/t09-tree.c
index 543aea8..3af06ea 100644
--- a/tests/t09-tree.c
+++ b/tests/t09-tree.c
@@ -187,22 +187,22 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory")
must_pass(git_treebuilder_write(&subtree_id,repo,builder));
git_treebuilder_free(builder);
- // create parent tree
- must_pass(git_tree_lookup(&tree, repo, &id));
+ // create parent tree
+ must_pass(git_tree_lookup(&tree, repo, &id));
must_pass(git_treebuilder_create(&builder, tree));
must_pass(git_treebuilder_insert(NULL,builder,"new",&subtree_id,040000));
must_pass(git_treebuilder_write(&id_hiearar,repo,builder));
git_treebuilder_free(builder);
git_tree_close(tree);
- must_be_true(git_oid_cmp(&id_hiearar, &id3) == 0);
+ must_be_true(git_oid_cmp(&id_hiearar, &id3) == 0);
- // check data is correct
- must_pass(git_tree_lookup(&tree, repo, &id_hiearar));
- must_be_true(2 == git_tree_entrycount(tree));
+ // check data is correct
+ must_pass(git_tree_lookup(&tree, repo, &id_hiearar));
+ must_be_true(2 == git_tree_entrycount(tree));
git_tree_close(tree);
- close_temp_repo(repo);
+ close_temp_repo(repo);
END_TEST
@@ -215,4 +215,3 @@ BEGIN_SUITE(tree)
ADD_TEST(write2);
ADD_TEST(write3);
END_SUITE
-
diff --git a/tests/t10-refs.c b/tests/t10-refs.c
index 1b3e0a3..c7bfe4e 100644
--- a/tests/t10-refs.c
+++ b/tests/t10-refs.c
@@ -1004,10 +1004,10 @@ BEGIN_TEST(list0, "try to list all the references in our test repo")
printf("# %s\n", ref_list.strings[i]);
}*/
- /* We have exactly 8 refs in total if we include the packed ones:
+ /* We have exactly 9 refs in total if we include the packed ones:
* there is a reference that exists both in the packfile and as
* loose, but we only list it once */
- must_be_true(ref_list.count == 8);
+ must_be_true(ref_list.count == 9);
git_strarray_free(&ref_list);
git_repository_free(repo);