From 13f7ecd7b9c5244441eeaae798c8657d1818ea7f Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 4 Mar 2014 16:23:28 -0800 Subject: Add git_object_short_id API to get short id string This finds a short id string that will unambiguously select the given object, starting with the core.abbrev length (usually 7) and growing until it is no longer ambiguous. --- include/git2/object.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/git2/object.h b/include/git2/object.h index c40631fa6..416feffbc 100644 --- a/include/git2/object.h +++ b/include/git2/object.h @@ -10,6 +10,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "buffer.h" /** * @file git2/object.h @@ -103,6 +104,15 @@ GIT_EXTERN(int) git_object_lookup_bypath( */ GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj); +/** + * Get a short abbreviated OID string for the object + * + * @param out Buffer to write string into + * @param obj The object to get an ID for + * @return 0 on success, <0 for error + */ +GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj); + /** * Get the object type of an object * -- cgit v1.2.1