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