Functions
2.1 Annotated Commit
2.2 Blame
2.3 Blob
2.4 Branch
2.5 Buffer
2.6 Checkout
2.7 Cherrypick
2.8 Clone
2.9 Commit
2.10 Config
2.11 Credentials
2.12 Describe
2.13 Diff
2.14 Fetch
2.15 Filter
2.16 Errors
2.17 Graph
2.18 Ignore
2.19 Index
2.20 Indexer
2.21 Global
2.22 Merge
2.23 Message
2.24 Note
2.25 Object
2.26 Object Database
2.27 Oid
2.28 Oid Array
2.29 Packbuilder
2.30 Patch
2.31 Pathspec
2.32 Proxy
2.33 Push
2.34 Rebase
2.35 Refdb
2.36 Reference
2.37 Reflog
2.38 Refspec
2.39 Remote
2.40 Repository
2.41 Reset
2.42 Revert
2.43 Revparse
2.44 Revwalk
2.45 Signature
2.46 Stash
2.47 Status
2.48 Strarray
2.49 Submodule
2.50 Tag
2.51 Tree
2.52 Treebuilder
On this page:
git_  oid_  cmp
git_  oid_  cpy
git_  oid_  equal
git_  oid_  fmt
git_  oid_  fromraw
git_  oid_  fromstr
git_  oid_  fromstrn
git_  oid_  fromstrp
git_  oid_  iszero
git_  oid_  ncmp
git_  oid_  nfmt
git_  oid_  pathfmt
git_  oid_  shorten_  add
git_  oid_  shorten_  free
git_  oid_  shorten_  new
git_  oid_  strcmp
git_  oid_  streq
git_  oid_  tostr
git_  oid_  tostr_  s
7.7

2.27 Oid

 (require libgit2/include/oid) package: libgit2

procedure

(git_oid_cmp a b)  integer?

  a : oid?
  b : oid?
Compare two oid structures.

procedure

(git_oid_cpy out src)  integer?

  out : oid?
  src : oid?
Copy an oid from one structure to another.

procedure

(git_oid_equal a b)  boolean?

  a : oid?
  b : oid?
Compare two oid structures for equality

procedure

(git_oid_fmt out id)  void?

  out : string?
  id : oid?
Format a git_oid into a hex string.

procedure

(git_oid_fromraw out raw)  void?

  out : oid?
  raw : bytes?
Copy an already raw oid into a git_oid structure.

procedure

(git_oid_fromstr out str)  integer?

  out : oid?
  str : string?
Parse a hex formatted object id into a git_oid.

procedure

(git_oid_fromstrn out str length)  integer?

  out : oid?
  str : string?
  length : integer?
Parse N characters of a hex formatted object id into a git_oid

If N is odd, N-1 characters will be parsed instead. The remaining space in the git_oid will be set to zero.

procedure

(git_oid_fromstrp out str)  integer?

  out : oid?
  str : string?
Parse a hex formatted null-terminated string into a git_oid.

procedure

(git_oid_iszero id)  boolean?

  id : oid?
Check is an oid is all zeros.

procedure

(git_oid_ncmp a b len)  integer?

  a : oid?
  b : oid?
  len : integer?
Compare the first ’len’ hexadecimal characters (packets of 4 bits) of two oid structures.

procedure

(git_oid_nfmt out n id)  void?

  out : string?
  n : integer?
  id : oid?
Format a git_oid into a partial hex string.

procedure

(git_oid_pathfmt out id)  void?

  out : string?
  id : oid?
Format a git_oid into a loose-object path string.

The resulting string is "aa/...", where "aa" is the first two hex digits of the oid and "..." is the remaining 38 digits.

procedure

(git_oid_shorten_add os text_id)  integer?

  os : oid_shorten?
  text_id : string?
Add a new OID to set of shortened OIDs and calculate the minimal length to uniquely identify all the OIDs in the set.

The OID is expected to be a 40-char hexadecimal string. The OID is owned by the user and will not be modified or freed.

For performance reasons, there is a hard-limit of how many OIDs can be added to a single set (around ~32000, assuming a mostly randomized distribution), which should be enough for any kind of program, and keeps the algorithm fast and memory-efficient.

Attempting to add more than those OIDs will result in a GITERR_INVALID error

procedure

(git_oid_shorten_free os)  void?

  os : oid_shorten?
Free an OID shortener instance

procedure

(git_oid_shorten_new min_length)  integer?

  min_length : integer?
Create a new OID shortener.

The OID shortener is used to process a list of OIDs in text form and return the shortest length that would uniquely identify all of them.

E.g. look at the result of git log –abbrev.

procedure

(git_oid_strcmp id str)  integer?

  id : oid?
  str : string?
Compare an oid to an hex formatted object id.

procedure

(git_oid_streq id str)  boolean?

  id : oid?
  str : string?
Check if an oid equals an hex formatted object id.

procedure

(git_oid_tostr out n id)  string?

  out : ?
  n : size_t
  id : oid?
Format a git_oid into a buffer as a hex format c-string.

If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting oid c-string will be truncated to n-1 characters (but will still be NUL-byte terminated).

If there are any input parameter errors (out == NULL, n == 0, oid == NULL), then a pointer to an empty string is returned, so that the return value can always be printed.

procedure

(git_oid_tostr_s oid)  string?

  oid : oid?
Format a git_oid into a statically allocated c-string.

The c-string is owned by the library and should not be freed by the user. If libgit2 is built with thread support, the string will be stored in TLS (i.e. one buffer per thread) to allow for concurrent calls of the function.