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.reset; 8 9 10 private static import libgit2_d.checkout; 11 private static import libgit2_d.strarray; 12 private static import libgit2_d.types; 13 14 /** 15 * @file git2/reset.h 16 * @brief Git reset management routines 17 * @ingroup Git 18 * @{ 19 */ 20 extern (C): 21 nothrow @nogc: 22 public: 23 24 /** 25 * Kinds of reset operation 26 */ 27 enum git_reset_t 28 { 29 /** 30 * Move the head to the given commit 31 */ 32 GIT_RESET_SOFT = 1, 33 34 /** 35 * SOFT plus reset index to the commit 36 */ 37 GIT_RESET_MIXED = 2, 38 39 /** 40 * MIXED plus changes in working tree discarded 41 */ 42 GIT_RESET_HARD = 3, 43 } 44 45 //Declaration name in C language 46 enum 47 { 48 GIT_RESET_SOFT = .git_reset_t.GIT_RESET_SOFT, 49 GIT_RESET_MIXED = .git_reset_t.GIT_RESET_MIXED, 50 GIT_RESET_HARD = .git_reset_t.GIT_RESET_HARD, 51 } 52 53 /** 54 * Sets the current head to the specified commit oid and optionally 55 * resets the index and working tree to match. 56 * 57 * SOFT reset means the Head will be moved to the commit. 58 * 59 * MIXED reset will trigger a SOFT reset, plus the index will be replaced 60 * with the content of the commit tree. 61 * 62 * HARD reset will trigger a MIXED reset and the working directory will be 63 * replaced with the content of the index. (Untracked and ignored files 64 * will be left alone, however.) 65 * 66 * TODO: Implement remaining kinds of resets. 67 * 68 * Params: 69 * repo = Repository where to perform the reset operation. 70 * target = Committish to which the Head should be moved to. This object must belong to the given `repo` and can either be a git_commit or a git_tag. When a git_tag is being passed, it should be dereferencable to a git_commit which oid will be used as the target of the branch. 71 * reset_type = Kind of reset operation to perform. 72 * checkout_opts = Optional checkout options to be used for a HARD reset. The checkout_strategy field will be overridden (based on reset_type). This parameter can be used to propagate notify and progress callbacks. 73 * 74 * Returns: 0 on success or an error code 75 */ 76 //GIT_EXTERN 77 int git_reset(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_object)* target, .git_reset_t reset_type, const (libgit2_d.checkout.git_checkout_options)* checkout_opts); 78 79 /** 80 * Sets the current head to the specified commit oid and optionally 81 * resets the index and working tree to match. 82 * 83 * This behaves like `git_reset()` but takes an annotated commit, 84 * which lets you specify which extended sha syntax string was 85 * specified by a user, allowing for more exact reflog messages. 86 * 87 * See the documentation for `git_reset()`. 88 * 89 * @see git_reset 90 */ 91 //GIT_EXTERN 92 int git_reset_from_annotated(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_annotated_commit)* commit, .git_reset_t reset_type, const (libgit2_d.checkout.git_checkout_options)* checkout_opts); 93 94 /** 95 * Updates some entries in the index from the target commit tree. 96 * 97 * The scope of the updated entries is determined by the paths 98 * being passed in the `pathspec` parameters. 99 * 100 * Passing a null `target` will result in removing 101 * entries in the index matching the provided pathspecs. 102 * 103 * Params: 104 * repo = Repository where to perform the reset operation. 105 * target = The committish which content will be used to reset the content of the index. 106 * pathspecs = List of pathspecs to operate on. 107 * 108 * Returns: 0 on success or an error code < 0 109 */ 110 //GIT_EXTERN 111 int git_reset_default(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_object)* target, const (libgit2_d.strarray.git_strarray)* pathspecs); 112 113 /** @} */