diff options
| author | Russell Belfer <rb@github.com> | 2012-04-13 10:33:14 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-04-17 10:44:50 -0700 |
| commit | f201d613a80f7ad6f54d90eb7a7a0d8b8c72676b (patch) | |
| tree | c3cd8f0eee145f40b640519e06ae628cdb942eb3 /include/git2/refs.h | |
| parent | 1a6e8f8a54eea1159a950cd8a49cedae3699ff9a (diff) | |
| download | libgit2-f201d613a80f7ad6f54d90eb7a7a0d8b8c72676b.tar.gz | |
Add git_reference_lookup_oid and lookup_resolved
Adds a new public reference function `git_reference_lookup_oid`
that directly resolved a reference name to an OID without returning
the intermediate `git_reference` object (hence, no free needed).
Internally, this adds a `git_reference_lookup_resolved` function
that combines looking up and resolving a reference. This allows
us to be more efficient with memory reallocation.
The existing `git_reference_lookup` and `git_reference_resolve`
are reimplmented on top of the new utility and a few places in the
code are changed to use one of the two new functions.
Diffstat (limited to 'include/git2/refs.h')
| -rw-r--r-- | include/git2/refs.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/git2/refs.h b/include/git2/refs.h index 5395ded4b..6f2ac3ce9 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -33,6 +33,16 @@ GIT_BEGIN_DECL GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name); /** + * Lookup a reference by name and resolve immediately to OID. + * + * @param oid Pointer to oid to be filled in + * @param repo The repository in which to look up the reference + * @param name The long name for the reference + * @return 0 on success, -1 if name could not be resolved + */ +GIT_EXTERN(int) git_reference_lookup_oid(git_oid *out, git_repository *repo, const char *name); + +/** * Create a new symbolic reference. * * The reference will be created in the repository and written @@ -304,6 +314,15 @@ GIT_EXTERN(int) git_reference_reload(git_reference *ref); */ GIT_EXTERN(void) git_reference_free(git_reference *ref); +/** + * Compare two references. + * + * @param ref1 The first git_reference + * @param ref2 The second git_reference + * @return GIT_SUCCESS if the same, else a stable but meaningless ordering. + */ +GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2); + /** @} */ GIT_END_DECL #endif |
