Blame include/git2/merge.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_merge_h__
Packit Service 20376f
#define INCLUDE_git_merge_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "oid.h"
Packit Service 20376f
#include "oidarray.h"
Packit Service 20376f
#include "checkout.h"
Packit Service 20376f
#include "index.h"
Packit Service 20376f
#include "annotated_commit.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/merge.h
Packit Service 20376f
 * @brief Git merge routines
Packit Service 20376f
 * @defgroup git_merge Git merge routines
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The file inputs to `git_merge_file`.  Callers should populate the
Packit Service 20376f
 * `git_merge_file_input` structure with descriptions of the files in
Packit Service 20376f
 * each side of the conflict for use in producing the merge file.
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	/** Pointer to the contents of the file. */
Packit Service 20376f
	const char *ptr;
Packit Service 20376f
Packit Service 20376f
	/** Size of the contents pointed to in `ptr`. */
Packit Service 20376f
	size_t size;
Packit Service 20376f
Packit Service 20376f
	/** File name of the conflicted file, or `NULL` to not merge the path. */
Packit Service 20376f
	const char *path;
Packit Service 20376f
Packit Service 20376f
	/** File mode of the conflicted file, or `0` to not merge the mode. */
Packit Service 20376f
	unsigned int mode;
Packit Service 20376f
} git_merge_file_input;
Packit Service 20376f
Packit Service 20376f
#define GIT_MERGE_FILE_INPUT_VERSION 1
Packit Service 20376f
#define GIT_MERGE_FILE_INPUT_INIT {GIT_MERGE_FILE_INPUT_VERSION}
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Initializes a `git_merge_file_input` with default values. Equivalent to
Packit Service 20376f
 * creating an instance with GIT_MERGE_FILE_INPUT_INIT.
Packit Service 20376f
 *
Packit Service 20376f
 * @param opts the `git_merge_file_input` instance to initialize.
Packit Service 20376f
 * @param version the version of the struct; you should pass
Packit Service 20376f
 *        `GIT_MERGE_FILE_INPUT_VERSION` here.
Packit Service 20376f
 * @return Zero on success; -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_file_init_input(
Packit Service 20376f
	git_merge_file_input *opts,
Packit Service 20376f
	unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Flags for `git_merge` options.  A combination of these flags can be
Packit Service 20376f
 * passed in via the `flags` value in the `git_merge_options`.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	/**
Packit Service 20376f
	 * Detect renames that occur between the common ancestor and the "ours"
Packit Service 20376f
	 * side or the common ancestor and the "theirs" side.  This will enable
Packit Service 20376f
	 * the ability to merge between a modified and renamed file.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FIND_RENAMES = (1 << 0),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * If a conflict occurs, exit immediately instead of attempting to
Packit Service 20376f
	 * continue resolving conflicts.  The merge operation will fail with
Packit Service 20376f
	 * GIT_EMERGECONFLICT and no index will be returned.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FAIL_ON_CONFLICT = (1 << 1),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Do not write the REUC extension on the generated index
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_SKIP_REUC = (1 << 2),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * If the commits being merged have multiple merge bases, do not build
Packit Service 20376f
	 * a recursive merge base (by merging the multiple merge bases),
Packit Service 20376f
	 * instead simply use the first base.  This flag provides a similar
Packit Service 20376f
	 * merge base to `git-merge-resolve`.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_NO_RECURSIVE = (1 << 3),
Packit Service 20376f
} git_merge_flag_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merge file favor options for `git_merge_options` instruct the file-level
Packit Service 20376f
 * merging functionality how to deal with conflicting regions of the files.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	/**
Packit Service 20376f
	 * When a region of a file is changed in both branches, a conflict
Packit Service 20376f
	 * will be recorded in the index so that `git_checkout` can produce
Packit Service 20376f
	 * a merge file with conflict markers in the working directory.
Packit Service 20376f
	 * This is the default.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FILE_FAVOR_NORMAL = 0,
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * When a region of a file is changed in both branches, the file
Packit Service 20376f
	 * created in the index will contain the "ours" side of any conflicting
Packit Service 20376f
	 * region.  The index will not record a conflict.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FILE_FAVOR_OURS = 1,
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * When a region of a file is changed in both branches, the file
Packit Service 20376f
	 * created in the index will contain the "theirs" side of any conflicting
Packit Service 20376f
	 * region.  The index will not record a conflict.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FILE_FAVOR_THEIRS = 2,
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * When a region of a file is changed in both branches, the file
Packit Service 20376f
	 * created in the index will contain each unique line from each side,
Packit Service 20376f
	 * which has the result of combining both files.  The index will not
Packit Service 20376f
	 * record a conflict.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_FILE_FAVOR_UNION = 3,
Packit Service 20376f
} git_merge_file_favor_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * File merging flags
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	/** Defaults */
Packit Service 20376f
	GIT_MERGE_FILE_DEFAULT = 0,
Packit Service 20376f
Packit Service 20376f
	/** Create standard conflicted merge files */
Packit Service 20376f
	GIT_MERGE_FILE_STYLE_MERGE = (1 << 0),
Packit Service 20376f
Packit Service 20376f
	/** Create diff3-style files */
Packit Service 20376f
	GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1),
Packit Service 20376f
Packit Service 20376f
	/** Condense non-alphanumeric regions for simplified diff file */
Packit Service 20376f
	GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2),
Packit Service 20376f
Packit Service 20376f
	/** Ignore all whitespace */
Packit Service 20376f
	GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3),
Packit Service 20376f
Packit Service 20376f
	/** Ignore changes in amount of whitespace */
Packit Service 20376f
	GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4),
Packit Service 20376f
Packit Service 20376f
	/** Ignore whitespace at end of line */
Packit Service 20376f
	GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5),
Packit Service 20376f
Packit Service 20376f
	/** Use the "patience diff" algorithm */
Packit Service 20376f
	GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6),
Packit Service 20376f
Packit Service 20376f
	/** Take extra time to find minimal diff */
Packit Service 20376f
	GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
Packit Service 20376f
} git_merge_file_flag_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Options for merging a file
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Label for the ancestor file side of the conflict which will be prepended
Packit Service 20376f
	 * to labels in diff3-format merge files.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *ancestor_label;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Label for our file side of the conflict which will be prepended
Packit Service 20376f
	 * to labels in merge files.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *our_label;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Label for their file side of the conflict which will be prepended
Packit Service 20376f
	 * to labels in merge files.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *their_label;
Packit Service 20376f
Packit Service 20376f
	/** The file to favor in region conflicts. */
Packit Service 20376f
	git_merge_file_favor_t favor;
Packit Service 20376f
Packit Service 20376f
	/** see `git_merge_file_flag_t` above */
Packit Service 20376f
	git_merge_file_flag_t flags;
Packit Service 20376f
} git_merge_file_options;
Packit Service 20376f
Packit Service 20376f
#define GIT_MERGE_FILE_OPTIONS_VERSION 1
Packit Service 20376f
#define GIT_MERGE_FILE_OPTIONS_INIT {GIT_MERGE_FILE_OPTIONS_VERSION}
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Initializes a `git_merge_file_options` with default values. Equivalent to
Packit Service 20376f
 * creating an instance with GIT_MERGE_FILE_OPTIONS_INIT.
Packit Service 20376f
 *
Packit Service 20376f
 * @param opts the `git_merge_file_options` instance to initialize.
Packit Service 20376f
 * @param version the version of the struct; you should pass
Packit Service 20376f
 *        `GIT_MERGE_FILE_OPTIONS_VERSION` here.
Packit Service 20376f
 * @return Zero on success; -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_file_init_options(
Packit Service 20376f
	git_merge_file_options *opts,
Packit Service 20376f
	unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Information about file-level merging
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	/**
Packit Service 20376f
	 * True if the output was automerged, false if the output contains
Packit Service 20376f
	 * conflict markers.
Packit Service 20376f
	 */
Packit Service 20376f
	unsigned int automergeable;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * The path that the resultant merge file should use, or NULL if a
Packit Service 20376f
	 * filename conflict would occur.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *path;
Packit Service 20376f
Packit Service 20376f
	/** The mode that the resultant merge file should use.  */
Packit Service 20376f
	unsigned int mode;
Packit Service 20376f
Packit Service 20376f
	/** The contents of the merge. */
Packit Service 20376f
	const char *ptr;
Packit Service 20376f
Packit Service 20376f
	/** The length of the merge contents. */
Packit Service 20376f
	size_t len;
Packit Service 20376f
} git_merge_file_result;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merging options
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	/** See `git_merge_flag_t` above */
Packit Service 20376f
	git_merge_flag_t flags;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Similarity to consider a file renamed (default 50).  If
Packit Service 20376f
	 * `GIT_MERGE_FIND_RENAMES` is enabled, added files will be compared
Packit Service 20376f
	 * with deleted files to determine their similarity.  Files that are
Packit Service 20376f
	 * more similar than the rename threshold (percentage-wise) will be
Packit Service 20376f
	 * treated as a rename.
Packit Service 20376f
	 */
Packit Service 20376f
	unsigned int rename_threshold;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Maximum similarity sources to examine for renames (default 200).
Packit Service 20376f
	 * If the number of rename candidates (add / delete pairs) is greater
Packit Service 20376f
	 * than this value, inexact rename detection is aborted.
Packit Service 20376f
	 *
Packit Service 20376f
	 * This setting overrides the `merge.renameLimit` configuration value.
Packit Service 20376f
	 */
Packit Service 20376f
	unsigned int target_limit;
Packit Service 20376f
Packit Service 20376f
	/** Pluggable similarity metric; pass NULL to use internal metric */
Packit Service 20376f
	git_diff_similarity_metric *metric;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Maximum number of times to merge common ancestors to build a
Packit Service 20376f
	 * virtual merge base when faced with criss-cross merges.  When this
Packit Service 20376f
	 * limit is reached, the next ancestor will simply be used instead of
Packit Service 20376f
	 * attempting to merge it.  The default is unlimited.
Packit Service 20376f
	 */
Packit Service 20376f
	unsigned int recursion_limit;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Default merge driver to be used when both sides of a merge have
Packit Service 20376f
	 * changed.  The default is the `text` driver.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *default_driver;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Flags for handling conflicting content, to be used with the standard
Packit Service 20376f
	 * (`text`) merge driver.
Packit Service 20376f
	 */
Packit Service 20376f
	git_merge_file_favor_t file_favor;
Packit Service 20376f
Packit Service 20376f
	/** see `git_merge_file_flag_t` above */
Packit Service 20376f
	git_merge_file_flag_t file_flags;
Packit Service 20376f
} git_merge_options;
Packit Service 20376f
Packit Service 20376f
#define GIT_MERGE_OPTIONS_VERSION 1
Packit Service 20376f
#define GIT_MERGE_OPTIONS_INIT { \
Packit Service 20376f
	GIT_MERGE_OPTIONS_VERSION, GIT_MERGE_FIND_RENAMES }
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Initializes a `git_merge_options` with default values. Equivalent to
Packit Service 20376f
 * creating an instance with GIT_MERGE_OPTIONS_INIT.
Packit Service 20376f
 *
Packit Service 20376f
 * @param opts the `git_merge_options` instance to initialize.
Packit Service 20376f
 * @param version the version of the struct; you should pass
Packit Service 20376f
 *        `GIT_MERGE_OPTIONS_VERSION` here.
Packit Service 20376f
 * @return Zero on success; -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_init_options(
Packit Service 20376f
	git_merge_options *opts,
Packit Service 20376f
	unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The results of `git_merge_analysis` indicate the merge opportunities.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	/** No merge is possible.  (Unused.) */
Packit Service 20376f
	GIT_MERGE_ANALYSIS_NONE = 0,
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * A "normal" merge; both HEAD and the given merge input have diverged
Packit Service 20376f
	 * from their common ancestor.  The divergent commits must be merged.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_ANALYSIS_NORMAL = (1 << 0),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * All given merge inputs are reachable from HEAD, meaning the
Packit Service 20376f
	 * repository is up-to-date and no merge needs to be performed.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * The given merge input is a fast-forward from HEAD and no merge
Packit Service 20376f
	 * needs to be performed.  Instead, the client can check out the
Packit Service 20376f
	 * given merge input.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * The HEAD of the current repository is "unborn" and does not point to
Packit Service 20376f
	 * a valid commit.  No merge can be performed, but the caller may wish
Packit Service 20376f
	 * to simply set HEAD to the target commit(s).
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_ANALYSIS_UNBORN = (1 << 3),
Packit Service 20376f
} git_merge_analysis_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * The user's stated preference for merges.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	/**
Packit Service 20376f
	 * No configuration was found that suggests a preferred behavior for
Packit Service 20376f
	 * merge.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_PREFERENCE_NONE = 0,
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * There is a `merge.ff=false` configuration setting, suggesting that
Packit Service 20376f
	 * the user does not want to allow a fast-forward merge.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0),
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * There is a `merge.ff=only` configuration setting, suggesting that
Packit Service 20376f
	 * the user only wants fast-forward merges.
Packit Service 20376f
	 */
Packit Service 20376f
	GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1),
Packit Service 20376f
} git_merge_preference_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Analyzes the given branch(es) and determines the opportunities for
Packit Service 20376f
 * merging them into the HEAD of the repository.
Packit Service 20376f
 *
Packit Service 20376f
 * @param analysis_out analysis enumeration that the result is written into
Packit Service 20376f
 * @param repo the repository to merge
Packit Service 20376f
 * @param their_heads the heads to merge into
Packit Service 20376f
 * @param their_heads_len the number of heads to merge
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_analysis(
Packit Service 20376f
	git_merge_analysis_t *analysis_out,
Packit Service 20376f
	git_merge_preference_t *preference_out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_annotated_commit **their_heads,
Packit Service 20376f
	size_t their_heads_len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Find a merge base between two commits
Packit Service 20376f
 *
Packit Service 20376f
 * @param out the OID of a merge base between 'one' and 'two'
Packit Service 20376f
 * @param repo the repository where the commits exist
Packit Service 20376f
 * @param one one of the commits
Packit Service 20376f
 * @param two the other commit
Packit Service 20376f
 * @return 0 on success, GIT_ENOTFOUND if not found or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_base(
Packit Service 20376f
	git_oid *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_oid *one,
Packit Service 20376f
	const git_oid *two);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Find merge bases between two commits
Packit Service 20376f
 *
Packit Service 20376f
 * @param out array in which to store the resulting ids
Packit Service 20376f
 * @param repo the repository where the commits exist
Packit Service 20376f
 * @param one one of the commits
Packit Service 20376f
 * @param two the other commit
Packit Service 20376f
 * @return 0 on success, GIT_ENOTFOUND if not found or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_bases(
Packit Service 20376f
	git_oidarray *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_oid *one,
Packit Service 20376f
	const git_oid *two);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Find a merge base given a list of commits
Packit Service 20376f
 *
Packit Service 20376f
 * @param out the OID of a merge base considering all the commits
Packit Service 20376f
 * @param repo the repository where the commits exist
Packit Service 20376f
 * @param length The number of commits in the provided `input_array`
Packit Service 20376f
 * @param input_array oids of the commits
Packit Service 20376f
 * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_base_many(
Packit Service 20376f
	git_oid *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	size_t length,
Packit Service 20376f
	const git_oid input_array[]);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Find all merge bases given a list of commits
Packit Service 20376f
 *
Packit Service 20376f
 * @param out array in which to store the resulting ids
Packit Service 20376f
 * @param repo the repository where the commits exist
Packit Service 20376f
 * @param length The number of commits in the provided `input_array`
Packit Service 20376f
 * @param input_array oids of the commits
Packit Service 20376f
 * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_bases_many(
Packit Service 20376f
	git_oidarray *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	size_t length,
Packit Service 20376f
	const git_oid input_array[]);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Find a merge base in preparation for an octopus merge
Packit Service 20376f
 *
Packit Service 20376f
 * @param out the OID of a merge base considering all the commits
Packit Service 20376f
 * @param repo the repository where the commits exist
Packit Service 20376f
 * @param length The number of commits in the provided `input_array`
Packit Service 20376f
 * @param input_array oids of the commits
Packit Service 20376f
 * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_base_octopus(
Packit Service 20376f
	git_oid *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	size_t length,
Packit Service 20376f
	const git_oid input_array[]);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merge two files as they exist in the in-memory data structures, using
Packit Service 20376f
 * the given common ancestor as the baseline, producing a
Packit Service 20376f
 * `git_merge_file_result` that reflects the merge result.  The
Packit Service 20376f
 * `git_merge_file_result` must be freed with `git_merge_file_result_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * Note that this function does not reference a repository and any
Packit Service 20376f
 * configuration must be passed as `git_merge_file_options`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out The git_merge_file_result to be filled in
Packit Service 20376f
 * @param ancestor The contents of the ancestor file
Packit Service 20376f
 * @param ours The contents of the file in "our" side
Packit Service 20376f
 * @param theirs The contents of the file in "their" side
Packit Service 20376f
 * @param opts The merge file options or `NULL` for defaults
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_file(
Packit Service 20376f
	git_merge_file_result *out,
Packit Service 20376f
	const git_merge_file_input *ancestor,
Packit Service 20376f
	const git_merge_file_input *ours,
Packit Service 20376f
	const git_merge_file_input *theirs,
Packit Service 20376f
	const git_merge_file_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merge two files as they exist in the index, using the given common
Packit Service 20376f
 * ancestor as the baseline, producing a `git_merge_file_result` that
Packit Service 20376f
 * reflects the merge result.  The `git_merge_file_result` must be freed with
Packit Service 20376f
 * `git_merge_file_result_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out The git_merge_file_result to be filled in
Packit Service 20376f
 * @param repo The repository
Packit Service 20376f
 * @param ancestor The index entry for the ancestor file (stage level 1)
Packit Service 20376f
 * @param ours The index entry for our file (stage level 2)
Packit Service 20376f
 * @param theirs The index entry for their file (stage level 3)
Packit Service 20376f
 * @param opts The merge file options or NULL
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_file_from_index(
Packit Service 20376f
	git_merge_file_result *out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_index_entry *ancestor,
Packit Service 20376f
	const git_index_entry *ours,
Packit Service 20376f
	const git_index_entry *theirs,
Packit Service 20376f
	const git_merge_file_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Frees a `git_merge_file_result`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param result The result to free or `NULL`
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_merge_file_result_free(git_merge_file_result *result);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merge two trees, producing a `git_index` that reflects the result of
Packit Service 20376f
 * the merge.  The index may be written as-is to the working directory
Packit Service 20376f
 * or checked out.  If the index is to be converted to a tree, the caller
Packit Service 20376f
 * should resolve any conflicts that arose as part of the merge.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned index must be freed explicitly with `git_index_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to store the index result in
Packit Service 20376f
 * @param repo repository that contains the given trees
Packit Service 20376f
 * @param ancestor_tree the common ancestor between the trees (or null if none)
Packit Service 20376f
 * @param our_tree the tree that reflects the destination tree
Packit Service 20376f
 * @param their_tree the tree to merge in to `our_tree`
Packit Service 20376f
 * @param opts the merge tree options (or null for defaults)
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_trees(
Packit Service 20376f
	git_index **out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_tree *ancestor_tree,
Packit Service 20376f
	const git_tree *our_tree,
Packit Service 20376f
	const git_tree *their_tree,
Packit Service 20376f
	const git_merge_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merge two commits, producing a `git_index` that reflects the result of
Packit Service 20376f
 * the merge.  The index may be written as-is to the working directory
Packit Service 20376f
 * or checked out.  If the index is to be converted to a tree, the caller
Packit Service 20376f
 * should resolve any conflicts that arose as part of the merge.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned index must be freed explicitly with `git_index_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to store the index result in
Packit Service 20376f
 * @param repo repository that contains the given trees
Packit Service 20376f
 * @param our_commit the commit that reflects the destination tree
Packit Service 20376f
 * @param their_commit the commit to merge in to `our_commit`
Packit Service 20376f
 * @param opts the merge tree options (or null for defaults)
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge_commits(
Packit Service 20376f
	git_index **out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_commit *our_commit,
Packit Service 20376f
	const git_commit *their_commit,
Packit Service 20376f
	const git_merge_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Merges the given commit(s) into HEAD, writing the results into the working
Packit Service 20376f
 * directory.  Any changes are staged for commit and any conflicts are written
Packit Service 20376f
 * to the index.  Callers should inspect the repository's index after this
Packit Service 20376f
 * completes, resolve any conflicts and prepare a commit.
Packit Service 20376f
 *
Packit Service 20376f
 * For compatibility with git, the repository is put into a merging
Packit Service 20376f
 * state. Once the commit is done (or if the uses wishes to abort),
Packit Service 20376f
 * you should clear this state by calling
Packit Service 20376f
 * `git_repository_state_cleanup()`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo the repository to merge
Packit Service 20376f
 * @param their_heads the heads to merge into
Packit Service 20376f
 * @param their_heads_len the number of heads to merge
Packit Service 20376f
 * @param merge_opts merge options
Packit Service 20376f
 * @param checkout_opts checkout options
Packit Service 20376f
 * @return 0 on success or error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_merge(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const git_annotated_commit **their_heads,
Packit Service 20376f
	size_t their_heads_len,
Packit Service 20376f
	const git_merge_options *merge_opts,
Packit Service 20376f
	const git_checkout_options *checkout_opts);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif