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