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
8.12

20 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.