On this page:
git_  commit_  amend
git_  commit_  author
git_  commit_  body
git_  commit_  committer
git_  commit_  create
git_  commit_  create_  buffer
git_  commit_  create_  from_  callback
git_  commit_  create_  from_  ids
git_  commit_  create_  v
git_  commit_  create_  with_  signature
git_  commit_  dup
git_  commit_  extract_  signature
git_  commit_  free
git_  commit_  header_  field
git_  commit_  id
git_  commit_  lookup
git_  commit_  lookup_  prefix
git_  commit_  message
git_  commit_  message_  encoding
git_  commit_  message_  raw
git_  commit_  nth_  gen_  ancestor
git_  commit_  owner
git_  commit_  parent
git_  commit_  parent_  id
git_  commit_  parentcount
git_  commit_  raw_  header
git_  commit_  summary
git_  commit_  time
git_  commit_  time_  offset
git_  commit_  tree
git_  commit_  tree_  id
8.12

9 Commit🔗ℹ

 (require libgit2/include/commit) package: libgit2

procedure

(git_commit_amend id    
  commit_to_amend    
  update_ref    
  author    
  committer    
  message_encoding    
  message    
  tree)  integer?
  id : oid?
  commit_to_amend : commit?
  update_ref : (or/c string? #f)
  author : (or/c signature? #f)
  committer : (or/c signature? #f)
  message_encoding : (or/c string? #f)
  message : (or/c string? #f)
  tree : (or/c tree? #f)
Amend an existing commit by replacing only non-NULL values.

This creates a new commit that is exactly the same as the old commit, except that any non-NULL values will be updated. The new commit has the same parents as the old commit.

The update_ref value works as in the regular git_commit_create(), updating the ref to point to the newly rewritten commit. If you want to amend a commit that is not currently the tip of the branch and then rewrite the following commits to reach a ref, pass this as NULL and update the rest of the commit chain and ref separately.

Unlike git_commit_create(), the author, committer, message, message_encoding, and tree parameters can be NULL in which case this will use the values from the original commit_to_amend.

All parameters have the same meanings as in git_commit_create().

procedure

(git_commit_author commit)  signature?

  commit : commit?
Get the author of a commit.

procedure

(git_commit_body commit)  string?

  commit : commit?
Get the long "body" of the git commit message.

The returned message is the body of the commit, comprising everything but the first paragraph of the message. Leading and trailing whitespaces are trimmed.

procedure

(git_commit_committer commit)  signature?

  commit : commit?
Get the committer of a commit.

procedure

(git_commit_create id    
  repo    
  update_ref    
  author    
  committer    
  message_encoding    
  message    
  tree    
  parent_count    
  parents)  integer?
  id : oid?
  repo : repository?
  update_ref : (or/c string? #f)
  author : signature?
  committer : signature?
  message_encoding : (or/c string? #f)
  message : string?
  tree : tree?
  parent_count : exact-positive-integer?
  parents : (or/c (cpointer commit) #f)
Create new commit in the repository from a list of git_object pointers

The message will not be cleaned up automatically. You can do that with the git_message_prettify() function.

procedure

(git_commit_create_buffer out    
  repo    
  author    
  committer    
  message_encoding    
  message    
  tree    
  parent_count    
  parents)  integer?
  out : buf?
  repo : repository?
  author : signature?
  committer : signature?
  message_encoding : (or/c string? #f)
  message : string?
  tree : tree?
  parent_count : exact-positive-integer?
  parents : (or/c (cpointer commit) #f)
Create a commit and write it into a buffer

Create a commit as with git_commit_create() but instead of writing it to the objectdb, write the contents of the object into a buffer.

procedure

(git_commit_create_from_callback id    
  repo    
  update_ref    
  author    
  committer    
  message_encoding    
  message    
  tree    
  parent_cb    
  parent_payload)  integer?
  id : oid?
  repo : repository?
  update_ref : (or/c string? #f)
  author : signature?
  committer : signature?
  message_encoding : (or/c string? #f)
  message : string?
  tree : oid?
  parent_cb : git_commit_parent_callback
  parent_payload : (or/c (cpointer void) #f)
Create a new commit in the repository with an callback to supply parents.

See documentation for git_commit_create() for information about the parameters, as the meaning is identical excepting that tree takes a git_oid and doesn’t check for validity, and parent_cb is invoked with parent_payload and should return git_oid values or NULL to indicate that all parents are accounted for.

procedure

(git_commit_create_from_ids id    
  repo    
  update_ref    
  author    
  committer    
  message_encoding    
  message    
  tree    
  parent_count    
  parents)  integer?
  id : oid?
  repo : repository?
  update_ref : (or/c string? #f)
  author : signature?
  committer : signature?
  message_encoding : (or/c string? #f)
  message : string?
  tree : oid?
  parent_count : size_t
  parents : (cpointer oid)
Create new commit in the repository from a list of git_oid values.

See documentation for git_commit_create() for information about the parameters, as the meaning is identical excepting that tree and parents now take git_oid. This is a dangerous API in that nor the tree, neither the parents list of git_oids are checked for validity.

procedure

(git_commit_create_v id    
  repo    
  update_ref    
  author    
  committer    
  message_encoding    
  message    
  tree    
  parent_count)  integer?
  id : oid?
  repo : repository?
  update_ref : (or/c string? #f)
  author : signature?
  committer : signature?
  message_encoding : (or/c string? #f)
  message : string?
  tree : tree?
  parent_count : exact-positive-integer?
Create new commit in the repository using a variable argument list.

The message will not be cleaned up automatically. You can do that with the git_message_prettify() function.

The parents for the commit are specified as a variable list of pointers to const git_commit *. Note that this is a convenience method which may not be safe to export for certain languages or compilers

All other parameters remain the same as git_commit_create().

procedure

(git_commit_create_with_signature out    
  repo    
  commit_content    
  signature    
  signature_field)  integer?
  out : oid?
  repo : repository?
  commit_content : string?
  signature : string?
  signature_field : (or/c string? #f)
Create a commit object from the given buffer and signature

Given the unsigned commit object’s contents, its signature and the header field in which to store the signature, attach the signature to the commit and write it into the given repository.

’signature_field’ defaults to "gpgsig"

procedure

(git_commit_dup source)  commit?

  source : commit?
Create an in-memory copy of a commit. The copy must be explicitly free’d or it will leak.

procedure

(git_commit_extract_signature signature    
  signed_data    
  repo    
  commit_id    
  field)  integer?
  signature : buf?
  signed_data : buf?
  repo : repository?
  commit_id : oid?
  field : (or/c string? #f)
Extract the signature from a commit

If the id is not for a commit, the error class will be GITERR_INVALID. If the commit does not have a signature, the error class will be GITERR_OBJECT.

’field’ defaults to "gpgsig"

procedure

(git_commit_free commit)  void?

  commit : commit?
Close an open commit

This is a wrapper around git_object_free()

IMPORTANT: It is necessary to call this method when you stop using a commit. Failure to do so will cause a memory leak.

procedure

(git_commit_header_field out commit field)  integer?

  out : buf?
  commit : commit?
  field : string?
Get an arbitrary header field

procedure

(git_commit_id commit)  oid?

  commit : commit?
Get the id of a commit.

procedure

(git_commit_lookup repo id)  commit?

  repo : repository?
  id : oid?
Lookup a commit object from a repository.

The returned object should be released with git_commit_free when no longer needed.

procedure

(git_commit_lookup_prefix repo id len)  commit?

  repo : repository?
  id : oid?
  len : exact-positive-integer?
Lookup a commit object from a repository, given a prefix of its identifier (short id).

The returned object should be released with git_commit_free when no longer needed.

procedure

(git_commit_message commit)  string?

  commit : commit?
Get the full message of a commit.

The returned message will be slightly prettified by removing any potential leading newlines.

procedure

(git_commit_message_encoding commit)  string?

  commit : commit?
Get the encoding for the message of a commit, as a string representing a standard encoding name.

The encoding may be NULL if the encoding header in the commit is missing; in that case UTF-8 is assumed.

procedure

(git_commit_message_raw commit)  bytes?

  commit : commit?
Get the full raw message of a commit.

procedure

(git_commit_nth_gen_ancestor commit int)  commit?

  commit : commit?
  int : unsigned
Get the commit object that is the <n

th generation ancestor of the named commit object, following only the first parents. The returned commit has to be freed by the caller.

Passing 0 as the generation number returns another instance of the base commit itself.

procedure

(git_commit_owner commit)  repository?

  commit : commit?
Get the repository that contains the commit.

procedure

(git_commit_parent commit int)  commit?

  commit : commit?
  int : unsigned
Get the specified parent of the commit.

procedure

(git_commit_parent_id commit int)  oid?

  commit : commit?
  int : unsigned
Get the oid of a specified parent for a commit. This is different from git_commit_parent, which will attempt to load the parent commit from the ODB.

procedure

(git_commit_parentcount commit)  integer?

  commit : commit?
Get the number of parents of this commit

procedure

(git_commit_raw_header commit)  string?

  commit : commit?
Get the full raw text of the commit header.

procedure

(git_commit_summary commit)  string?

  commit : commit?
Get the short "summary" of the git commit message.

The returned message is the summary of the commit, comprising the first paragraph of the message with whitespace trimmed and squashed.

procedure

(git_commit_time commit)  git_time_t?

  commit : commit?
Get the commit time (i.e. committer time) of a commit.

procedure

(git_commit_time_offset commit)  integer?

  commit : commit?
Get the commit timezone offset (i.e. committer’s preferred timezone) of a commit.

procedure

(git_commit_tree commit)  tree?

  commit : commit?
Get the tree pointed to by a commit.

procedure

(git_commit_tree_id commit)  oid?

  commit : commit?
Get the id of the tree pointed to by a commit. This differs from git_commit_tree in that no attempts are made to fetch an object from the ODB.