From b6c93aef4276051f9c4536ecbed48f4cd093bd1b Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 21 Feb 2012 14:46:24 -0800 Subject: Uniform iterators for trees, index, and workdir This create a new git_iterator type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner. --- tests-clar/diff/diff_helpers.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests-clar/diff/diff_helpers.c (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c new file mode 100644 index 00000000..b2dbe9ee --- /dev/null +++ b/tests-clar/diff/diff_helpers.c @@ -0,0 +1,22 @@ +#include "clar_libgit2.h" +#include "diff_helpers.h" + +git_tree *resolve_commit_oid_to_tree( + git_repository *repo, + const char *partial_oid) +{ + size_t len = strlen(partial_oid); + git_oid oid; + git_object *obj; + git_tree *tree; + + if (git_oid_fromstrn(&oid, partial_oid, len) == 0) + git_object_lookup_prefix(&obj, repo, &oid, len, GIT_OBJ_ANY); + cl_assert(obj); + if (git_object_type(obj) == GIT_OBJ_TREE) + return (git_tree *)obj; + cl_assert(git_object_type(obj) == GIT_OBJ_COMMIT); + cl_git_pass(git_commit_tree(&tree, (git_commit *)obj)); + git_object_free(obj); + return tree; +} -- cgit v1.2.1