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_  merge
git_  merge_  analysis
git_  merge_  base
git_  merge_  base_  many
git_  merge_  base_  octopus
git_  merge_  bases
git_  merge_  bases_  many
git_  merge_  commits
git_  merge_  file
git_  merge_  file_  from_  index
git_  merge_  file_  init_  input
git_  merge_  file_  init_  options
git_  merge_  file_  result_  free
git_  merge_  init_  options
git_  merge_  trees
7.7

2.22 Merge

 (require libgit2/include/merge) package: libgit2

procedure

(git_merge repo    
  their_heads    
  their_heads_len    
  merge_opts    
  checkout_opts)  integer?
  repo : repository?
  their_heads : (cpointer annotated_commit?)
  their_heads_len : integer?
  merge_opts : git_merge_opts?
  checkout_opts : git_checkout_opts?
Merges the given commit(s) into HEAD, writing the results into the working directory. Any changes are staged for commit and any conflicts are written to the index. Callers should inspect the repository’s index after this completes, resolve any conflicts and prepare a commit.

For compatibility with git, the repository is put into a merging state. Once the commit is done (or if the uses wishes to abort), you should clear this state by calling git_repository_state_cleanup().

procedure

(git_merge_analysis analysis_out    
  preference_out    
  repo    
  their_heads    
  their_heads_len)  integer?
  analysis_out : (cpointer git_merge_analysis_t)
  preference_out : (cpointer gitmerge_preference_t)
  repo : repository?
  their_heads : (cpointer annotated_commit?)
  their_heads_len : integer?
Analyzes the given branch(es) and determines the opportunities for merging them into the HEAD of the repository.

procedure

(git_merge_base out repo one two)  integer?

  out : oid?
  repo : repository?
  one : oid?
  two : oid?
Find a merge base between two commits

procedure

(git_merge_base_many out    
  repo    
  length    
  input_array)  integer?
  out : oid?
  repo : repository?
  length : integer?
  input_array : (cpointer oid?)
Find a merge base given a list of commits

procedure

(git_merge_base_octopus out    
  repo    
  length    
  input_array)  integer?
  out : oid?
  repo : repository?
  length : integer?
  input_array : (cpointer oid?)
Find a merge base in preparation for an octopus merge

procedure

(git_merge_bases out repo one two)  integer?

  out : oidarray?
  repo : repository?
  one : oid?
  two : oid?
Find merge bases between two commits

procedure

(git_merge_bases_many out    
  repo    
  length    
  input_array)  integer?
  out : oidarray?
  repo : repository?
  length : integer?
  input_array : (cpointer oid?)
Find all merge bases given a list of commits

procedure

(git_merge_commits repo    
  our_commit    
  their_commit    
  opts)  index?
  repo : repository?
  our_commit : commit?
  their_commit : commit?
  opts : (or/c git_merge_opts? #f)
Merge two commits, producing a git_index that reflects the result of the merge. The index may be written as-is to the working directory or checked out. If the index is to be converted to a tree, the caller should resolve any conflicts that arose as part of the merge.

The returned index must be freed explicitly with git_index_free.

procedure

(git_merge_file out ancestor ours theirs opts)  integer?

  out : git_merge_file_result?
  ancestor : merge_file_input?
  ours : merge_file_input?
  theirs : merge_file_input?
  opts : (or/c git_merge_file_opts?)
Merge two files as they exist in the in-memory data structures, using the given common ancestor as the baseline, producing a git_merge_file_result that reflects the merge result. The git_merge_file_result must be freed with git_merge_file_result_free.

Note that this function does not reference a repository and any configuration must be passed as git_merge_file_options.

procedure

(git_merge_file_from_index out    
  repo    
  ancestor    
  ours    
  theirs    
  opts)  integer?
  out : merge_file_result?
  repo : repository?
  ancestor : index_entry?
  ours : index_entry?
  theirs : index_entry?
  opts : (or/c git_merge_file_opts? #f)
Merge two files as they exist in the index, using the given common ancestor as the baseline, producing a git_merge_file_result that reflects the merge result. The git_merge_file_result must be freed with git_merge_file_result_free.

procedure

(git_merge_file_init_input opts version)  integer?

  opts : merge_file_input?
  version : integer?
Initializes a git_merge_file_input with default values. Equivalent to creating an instance with GIT_MERGE_FILE_INPUT_INIT.

procedure

(git_merge_file_init_options opts version)  integer?

  opts : merge_file_options?
  version : integer?
Initializes a git_merge_file_options with default values. Equivalent to creating an instance with GIT_MERGE_FILE_OPTIONS_INIT.

procedure

(git_merge_file_result_free result)  void?

  result : merge_file_result?
Frees a git_merge_file_result.

procedure

(git_merge_init_options opts version)  integer?

  opts : git_merge_opts?
  version : integer?
Initializes a git_merge_options with default values. Equivalent to creating an instance with GIT_MERGE_OPTIONS_INIT.

procedure

(git_merge_trees repo    
  ancestor_tree    
  our_tree    
  their_tree    
  opts)  index?
  repo : repository?
  ancestor_tree : tree?
  our_tree : tree?
  their_tree : tree?
  opts : (or/c git_merge_options? #f)
Merge two trees, producing a git_index that reflects the result of the merge. The index may be written as-is to the working directory or checked out. If the index is to be converted to a tree, the caller should resolve any conflicts that arose as part of the merge.

The returned index must be freed explicitly with git_index_free.