From 58206c9ae79af8ef675e30087e5430065b078bbb Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 16 May 2013 10:38:27 -0700 Subject: Add cat-file example and increase const use in API This adds an example implementation that emulates git cat-file. It is a convenient and relatively simple example of getting data out of a repository. Implementing this also revealed that there are a number of APIs that are still not using const pointers to objects that really ought to be. The main cause of this is that `git_vector_bsearch` may need to call `git_vector_sort` before doing the search, so a const pointer to the vector is not allowed. However, for tree objects, with a little care, we can ensure that the vector of tree entries is always sorted and allow lookups to take a const pointer. Also, the missing const in commit objects just looks like an oversight. --- src/tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tree.h') diff --git a/src/tree.h b/src/tree.h index 7cb2dd36c..f07039a07 100644 --- a/src/tree.h +++ b/src/tree.h @@ -47,7 +47,7 @@ int git_tree__parse(void *tree, git_odb_object *obj); * @param prefix the beginning of a path to find in the tree. * @return index of the first item at or after the given prefix. */ -int git_tree__prefix_position(git_tree *tree, const char *prefix); +int git_tree__prefix_position(const git_tree *tree, const char *prefix); /** -- cgit v1.2.1