Blame include/git2/cherrypick.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_cherrypick_h__
Packit Service 20376f
#define INCLUDE_git_cherrypick_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "merge.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/cherrypick.h
Packit Service 20376f
 * @brief Git cherry-pick routines
Packit Service 20376f
 * @defgroup git_cherrypick Git cherry-pick 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
 * Cherry-pick options
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	/** For merge commits, the "mainline" is treated as the parent. */
Packit Service 20376f
	unsigned int mainline;
Packit Service 20376f
Packit Service 20376f
	git_merge_options merge_opts; /**< Options for the merging */
Packit Service 20376f
	git_checkout_options checkout_opts; /**< Options for the checkout */
Packit Service 20376f
} git_cherrypick_options;
Packit Service 20376f
Packit Service 20376f
#define GIT_CHERRYPICK_OPTIONS_VERSION 1
Packit Service 20376f
#define GIT_CHERRYPICK_OPTIONS_INIT {GIT_CHERRYPICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Initializes a `git_cherrypick_options` with default values. Equivalent to
Packit Service 20376f
 * creating an instance with GIT_CHERRYPICK_OPTIONS_INIT.
Packit Service 20376f
 *
Packit Service 20376f
 * @param opts the `git_cherrypick_options` struct to initialize
Packit Service 20376f
 * @param version Version of struct; pass `GIT_CHERRYPICK_OPTIONS_VERSION`
Packit Service 20376f
 * @return Zero on success; -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_cherrypick_init_options(
Packit Service 20376f
	git_cherrypick_options *opts,
Packit Service 20376f
	unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Cherry-picks the given commit against the given "our" commit, producing an
Packit Service 20376f
 * index that reflects the result of the cherry-pick.
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 the repository that contains the given commits
Packit Service 20376f
 * @param cherrypick_commit the commit to cherry-pick
Packit Service 20376f
 * @param our_commit the commit to revert against (eg, HEAD)
Packit Service 20376f
 * @param mainline the parent of the revert commit, if it is a merge
Packit Service 20376f
 * @param merge_options the merge options (or null for defaults)
Packit Service 20376f
 * @return zero on success, -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_cherrypick_commit(
Packit Service 20376f
	git_index **out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_commit *cherrypick_commit,
Packit Service 20376f
	git_commit *our_commit,
Packit Service 20376f
	unsigned int mainline,
Packit Service 20376f
	const git_merge_options *merge_options);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Cherry-pick the given commit, producing changes in the index and working directory.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo the repository to cherry-pick
Packit Service 20376f
 * @param commit the commit to cherry-pick
Packit Service 20376f
 * @param cherrypick_options the cherry-pick options (or null for defaults)
Packit Service 20376f
 * @return zero on success, -1 on failure.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_cherrypick(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_commit *commit,
Packit Service 20376f
	const git_cherrypick_options *cherrypick_options);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
Packit Service 20376f
#endif
Packit Service 20376f