1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 /** 8 * License: GPL-2.0(Linking Exception) 9 */ 10 module libgit2.cherrypick; 11 12 13 private static import libgit2.checkout; 14 private static import libgit2.merge; 15 private static import libgit2.types; 16 private import libgit2.common: GIT_EXTERN; 17 18 /* 19 * @file git2/cherrypick.h 20 * @brief Git cherry-pick routines 21 * @defgroup git_cherrypick Git cherry-pick routines 22 * @ingroup Git 23 * @{ 24 */ 25 extern (C): 26 nothrow @nogc: 27 public: 28 29 /** 30 * Cherry-pick options 31 */ 32 struct git_cherrypick_options 33 { 34 uint version_; 35 36 /** 37 * For merge commits, the "mainline" is treated as the parent. 38 */ 39 uint mainline; 40 41 /** 42 * Options for the merging 43 */ 44 libgit2.merge.git_merge_options merge_opts; 45 46 /** 47 * Options for the checkout 48 */ 49 libgit2.checkout.git_checkout_options checkout_opts; 50 } 51 52 enum GIT_CHERRYPICK_OPTIONS_VERSION = 1; 53 54 pragma(inline, true) 55 pure nothrow @safe @nogc @live 56 .git_cherrypick_options GIT_CHERRYPICK_OPTIONS_INIT() 57 58 do 59 { 60 .git_cherrypick_options OUTPUT = 61 { 62 version_: .GIT_CHERRYPICK_OPTIONS_VERSION, 63 mainline: 0, 64 merge_opts: libgit2.merge.GIT_MERGE_OPTIONS_INIT(), 65 checkout_opts: libgit2.checkout.GIT_CHECKOUT_OPTIONS_INIT(), 66 }; 67 68 return OUTPUT; 69 } 70 71 /** 72 * Initialize git_cherrypick_options structure 73 * 74 * Initializes a `git_cherrypick_options` with default values. Equivalent to creating 75 * an instance with GIT_CHERRYPICK_OPTIONS_INIT. 76 * 77 * Params: 78 * opts = The `git_cherrypick_options` struct to initialize. 79 * version_ = The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`. 80 * 81 * Returns: Zero on success; -1 on failure. 82 */ 83 @GIT_EXTERN 84 int git_cherrypick_options_init(.git_cherrypick_options* opts, uint version_); 85 86 /** 87 * Cherry-picks the given commit against the given "our" commit, producing an 88 * index that reflects the result of the cherry-pick. 89 * 90 * The returned index must be freed explicitly with `git_index_free`. 91 * 92 * Params: 93 * out_ = pointer to store the index result in 94 * repo = the repository that contains the given commits 95 * cherrypick_commit = the commit to cherry-pick 96 * our_commit = the commit to cherry-pick against (eg, HEAD) 97 * mainline = the parent of the `cherrypick_commit`, if it is a merge 98 * merge_options = the merge options (or null for defaults) 99 * 100 * Returns: zero on success, -1 on failure. 101 */ 102 @GIT_EXTERN 103 int git_cherrypick_commit(libgit2.types.git_index** out_, libgit2.types.git_repository* repo, libgit2.types.git_commit* cherrypick_commit, libgit2.types.git_commit* our_commit, uint mainline, const (libgit2.merge.git_merge_options)* merge_options); 104 105 /** 106 * Cherry-pick the given commit, producing changes in the index and working 107 * directory. 108 * 109 * Params: 110 * repo = the repository to cherry-pick 111 * commit = the commit to cherry-pick 112 * cherrypick_options = the cherry-pick options (or null for defaults) 113 * 114 * Returns: zero on success, -1 on failure. 115 */ 116 @GIT_EXTERN 117 int git_cherrypick(libgit2.types.git_repository* repo, libgit2.types.git_commit* commit, const (.git_cherrypick_options)* cherrypick_options); 118 119 /* @} */