summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorMarc Pegon <pegon.marc@gmail.com>2011-05-28 21:24:25 +0200
committerVicent Marti <tanoku@gmail.com>2011-06-01 23:40:41 +0200
commitac2b94ad7658b53035b8518842348a083decd418 (patch)
tree19c5220d8493f697a4f09557ca4dfafb6cc12b36 /include/git2
parentdd453c4dbf9a1fa38530b1f51e079852736b8f66 (diff)
downloadlibgit2-ac2b94ad7658b53035b8518842348a083decd418.tar.gz
Added a GIT_OID_MINPREFIXLEN constant to define the minimum length allowed for oid prefixes (set to 4, like in git). Consequently updated some object lookup methods and their documentation.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/object.h6
-rw-r--r--include/git2/odb.h5
-rw-r--r--include/git2/oid.h4
3 files changed, 10 insertions, 5 deletions
diff --git a/include/git2/object.h b/include/git2/object.h
index 4cb6af0ad..cadb942e0 100644
--- a/include/git2/object.h
+++ b/include/git2/object.h
@@ -65,9 +65,9 @@ GIT_EXTERN(int) git_object_lookup(git_object **object, git_repository *repo, con
* The object obtained will be so that its identifier
* matches the first 'len' hexadecimal characters
* (packets of 4 bits) of the given 'id'.
- * 'len' must be long enough to identify a unique
- * object matching the prefix; otherwise the method will
- * fail.
+ * 'len' must be at least GIT_OID_MINPREFIXLEN, and
+ * long enough to identify a unique object matching
+ * the prefix; otherwise the method will fail.
*
* The generated reference is owned by the repository and
* should be closed with the `git_object_close` method
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 483934ad3..6c08ade54 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -132,9 +132,10 @@ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *i
* This method queries all available ODB backends
* trying to match the 'len' first hexadecimal
* characters of the 'short_id'.
- * The remaining bits (GIT_OID_HEXSZ-len)*4 bits of
+ * The remaining (GIT_OID_HEXSZ-len)*4 bits of
* 'short_id' must be 0s.
- * The prefix must be long enough to identify
+ * 'len' must be at least GIT_OID_MINPREFIXLEN,
+ * and the prefix must be long enough to identify
* a unique object in all the backends; the
* method will fail otherwise.
*
diff --git a/include/git2/oid.h b/include/git2/oid.h
index e8803ced8..062b9ca8b 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -43,6 +43,10 @@ GIT_BEGIN_DECL
/** Size (in bytes) of a hex formatted oid */
#define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2)
+/** Minimum length (in number of hex characters,
+ * i.e. packets of 4 bits) of an oid prefix */
+#define GIT_OID_MINPREFIXLEN 4
+
/** Unique identity of any object (commit, tree, blob, tag). */
typedef struct {
/** raw binary formatted id */