diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-03-12 16:04:46 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-14 23:52:32 +0200 |
| commit | 005718280712634486a097427212e652b0e29f36 (patch) | |
| tree | 00aba58f1f723bee77a251382cc3e407e2840fa5 /include/git2 | |
| parent | 58d06cf120eb9bb9247bb807bb105981bb3482a8 (diff) | |
| download | libgit2-005718280712634486a097427212e652b0e29f36.tar.gz | |
Add new method `git_reference_listall`
Lists all the references in a repository. Listing may be filtered by
reference type.
This should applease Lord Clem.
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/common.h | 16 | ||||
| -rw-r--r-- | include/git2/refs.h | 23 | ||||
| -rw-r--r-- | include/git2/types.h | 1 |
3 files changed, 40 insertions, 0 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index 34efe808b..11a08f897 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -27,6 +27,7 @@ #include "thread-utils.h" #include <time.h> +#include <stdlib.h> #ifdef __cplusplus # define GIT_BEGIN_DECL extern "C" { @@ -158,6 +159,21 @@ #define GIT_EINVALIDREFSTATE (GIT_ERROR - 21) GIT_BEGIN_DECL + +typedef struct { + char **strings; + size_t count; +} git_strarray; + +GIT_INLINE(void) git_strarray_free(git_strarray *array) +{ + size_t i; + for (i = 0; i < array->count; ++i) + free(array->strings[i]); + + free(array->strings); +} + /** @} */ GIT_END_DECL #endif diff --git a/include/git2/refs.h b/include/git2/refs.h index 1702d7ee1..4ffc5ce5b 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -218,6 +218,29 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref); */ GIT_EXTERN(int) git_reference_packall(git_repository *repo); +/** + * Fill a list with all the references that can be found + * in a repository. + * + * The listed references may be filtered by type, or using + * a bitwise OR of several types. Use the magic value + * `GIT_REF_LISTALL` to obtain all references, including + * packed ones. + * + * The string array will be filled with the names of all + * references; these values are owned by the user and + * should be free'd manually when no longer needed, using + * `git_strarray_free`. + * + * @param array Pointer to a git_strarray structure where + * the reference names will be stored + * @param repo Repository where to find the refs + * @param list_flags Filtering flags for the reference + * listing. + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_reference_listall(git_strarray *array, git_repository *repo, unsigned int list_flags); + /** @} */ GIT_END_DECL #endif diff --git a/include/git2/types.h b/include/git2/types.h index 62467ec45..b5a8d7b2d 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -145,6 +145,7 @@ typedef enum { GIT_REF_SYMBOLIC = 2, /** A reference which points at another reference */ GIT_REF_PACKED = 4, GIT_REF_HAS_PEEL = 8, + GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC|GIT_REF_PACKED, } git_rtype; /** @} */ |
