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 /**
46  * Sets the current head to the specified commit oid and optionally
47  * resets the index and working tree to match.
48  *
49  * SOFT reset means the Head will be moved to the commit.
50  *
51  * MIXED reset will trigger a SOFT reset, plus the index will be replaced
52  * with the content of the commit tree.
53  *
54  * HARD reset will trigger a MIXED reset and the working directory will be
55  * replaced with the content of the index.  (Untracked and ignored files
56  * will be left alone, however.)
57  *
58  * TODO: Implement remaining kinds of resets.
59  *
60  * Params:
61  *      repo = Repository where to perform the reset operation.
62  *      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.
63  *      reset_type = Kind of reset operation to perform.
64  *      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.
65  *
66  * Returns: 0 on success or an error code
67  */
68 //GIT_EXTERN
69 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);
70 
71 /**
72  * Sets the current head to the specified commit oid and optionally
73  * resets the index and working tree to match.
74  *
75  * This behaves like `git_reset()` but takes an annotated commit,
76  * which lets you specify which extended sha syntax string was
77  * specified by a user, allowing for more exact reflog messages.
78  *
79  * See the documentation for `git_reset()`.
80  *
81  * @see git_reset
82  */
83 //GIT_EXTERN
84 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);
85 
86 /**
87  * Updates some entries in the index from the target commit tree.
88  *
89  * The scope of the updated entries is determined by the paths
90  * being passed in the `pathspec` parameters.
91  *
92  * Passing a null `target` will result in removing
93  * entries in the index matching the provided pathspecs.
94  *
95  * Params:
96  *      repo = Repository where to perform the reset operation.
97  *      target = The committish which content will be used to reset the content of the index.
98  *      pathspecs = List of pathspecs to operate on.
99  *
100  * Returns: 0 on success or an error code < 0
101  */
102 //GIT_EXTERN
103 int git_reset_default(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_object)* target, const (libgit2_d.strarray.git_strarray)* pathspecs);
104 
105 /** @} */