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.revert; 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/revert.h 16 * @brief Git revert routines 17 * @defgroup git_revert Git revert routines 18 * @ingroup Git 19 * @{ 20 */ 21 extern (C): 22 nothrow @nogc: 23 public: 24 25 /** 26 * Options for revert 27 */ 28 struct git_revert_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_REVERT_OPTIONS_VERSION = 1; 49 50 pragma(inline, true) 51 pure nothrow @safe @nogc 52 .git_revert_options GIT_REVERT_OPTIONS_INIT() 53 54 do 55 { 56 .git_revert_options OUTPUT = 57 { 58 version_: .GIT_REVERT_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_revert_options structure 69 * 70 * Initializes a `git_revert_options` with default values. Equivalent to 71 * creating an instance with `GIT_REVERT_OPTIONS_INIT`. 72 * 73 * Params: 74 * opts = The `git_revert_options` struct to initialize. 75 * version = The struct version; pass `GIT_REVERT_OPTIONS_VERSION`. 76 * 77 * Returns: Zero on success; -1 on failure. 78 */ 79 //GIT_EXTERN 80 int git_revert_options_init(.git_revert_options* opts, uint version_); 81 82 /** 83 * Reverts the given commit against the given "our" commit, producing an 84 * index that reflects the result of the revert. 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 * revert_commit = the commit to revert 92 * our_commit = the commit to revert against (eg, HEAD) 93 * mainline = the parent of the revert 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_revert_commit(libgit2_d.types.git_index** out_, libgit2_d.types.git_repository* repo, libgit2_d.types.git_commit* revert_commit, libgit2_d.types.git_commit* our_commit, uint mainline, const (libgit2_d.merge.git_merge_options)* merge_options); 100 101 /** 102 * Reverts the given commit, producing changes in the index and working 103 * directory. 104 * 105 * Params: 106 * repo = the repository to revert 107 * commit = the commit to revert 108 * given_opts = the revert options (or null for defaults) 109 * 110 * Returns: zero on success, -1 on failure. 111 */ 112 //GIT_EXTERN 113 int git_revert(libgit2_d.types.git_repository* repo, libgit2_d.types.git_commit* commit, const (.git_revert_options)* given_opts); 114 115 /** @} */