Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:37

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_git_cherrypick_h__
0008 #define INCLUDE_git_cherrypick_h__
0009 
0010 #include "common.h"
0011 #include "types.h"
0012 #include "merge.h"
0013 
0014 /**
0015  * @file git2/cherrypick.h
0016  * @brief Git cherry-pick routines
0017  * @defgroup git_cherrypick Git cherry-pick routines
0018  * @ingroup Git
0019  * @{
0020  */
0021 GIT_BEGIN_DECL
0022 
0023 /**
0024  * Cherry-pick options
0025  */
0026 typedef struct {
0027     unsigned int version;
0028 
0029     /** For merge commits, the "mainline" is treated as the parent. */
0030     unsigned int mainline;
0031 
0032     git_merge_options merge_opts; /**< Options for the merging */
0033     git_checkout_options checkout_opts; /**< Options for the checkout */
0034 } git_cherrypick_options;
0035 
0036 #define GIT_CHERRYPICK_OPTIONS_VERSION 1
0037 #define GIT_CHERRYPICK_OPTIONS_INIT {GIT_CHERRYPICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
0038 
0039 /**
0040  * Initialize git_cherrypick_options structure
0041  *
0042  * Initializes a `git_cherrypick_options` with default values. Equivalent to creating
0043  * an instance with GIT_CHERRYPICK_OPTIONS_INIT.
0044  *
0045  * @param opts The `git_cherrypick_options` struct to initialize.
0046  * @param version The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`.
0047  * @return Zero on success; -1 on failure.
0048  */
0049 GIT_EXTERN(int) git_cherrypick_options_init(
0050     git_cherrypick_options *opts,
0051     unsigned int version);
0052 
0053 /**
0054  * Cherry-picks the given commit against the given "our" commit, producing an
0055  * index that reflects the result of the cherry-pick.
0056  *
0057  * The returned index must be freed explicitly with `git_index_free`.
0058  *
0059  * @param out pointer to store the index result in
0060  * @param repo the repository that contains the given commits
0061  * @param cherrypick_commit the commit to cherry-pick
0062  * @param our_commit the commit to cherry-pick against (eg, HEAD)
0063  * @param mainline the parent of the `cherrypick_commit`, if it is a merge
0064  * @param merge_options the merge options (or null for defaults)
0065  * @return zero on success, -1 on failure.
0066  */
0067 GIT_EXTERN(int) git_cherrypick_commit(
0068     git_index **out,
0069     git_repository *repo,
0070     git_commit *cherrypick_commit,
0071     git_commit *our_commit,
0072     unsigned int mainline,
0073     const git_merge_options *merge_options);
0074 
0075 /**
0076  * Cherry-pick the given commit, producing changes in the index and working directory.
0077  *
0078  * @param repo the repository to cherry-pick
0079  * @param commit the commit to cherry-pick
0080  * @param cherrypick_options the cherry-pick options (or null for defaults)
0081  * @return zero on success, -1 on failure.
0082  */
0083 GIT_EXTERN(int) git_cherrypick(
0084     git_repository *repo,
0085     git_commit *commit,
0086     const git_cherrypick_options *cherrypick_options);
0087 
0088 /** @} */
0089 GIT_END_DECL
0090 
0091 #endif
0092