]> git.proxmox.com Git - libgit2.git/blob - include/git2/reset.h
New upstream version 1.3.0+dfsg.1
[libgit2.git] / include / git2 / reset.h
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 #ifndef INCLUDE_git_reset_h__
8 #define INCLUDE_git_reset_h__
9
10 #include "common.h"
11 #include "types.h"
12 #include "strarray.h"
13 #include "checkout.h"
14
15 /**
16 * @file git2/reset.h
17 * @brief Git reset management routines
18 * @ingroup Git
19 * @{
20 */
21 GIT_BEGIN_DECL
22
23 /**
24 * Kinds of reset operation
25 */
26 typedef enum {
27 GIT_RESET_SOFT = 1, /**< Move the head to the given commit */
28 GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */
29 GIT_RESET_HARD = 3, /**< MIXED plus changes in working tree discarded */
30 } git_reset_t;
31
32 /**
33 * Sets the current head to the specified commit oid and optionally
34 * resets the index and working tree to match.
35 *
36 * SOFT reset means the Head will be moved to the commit.
37 *
38 * MIXED reset will trigger a SOFT reset, plus the index will be replaced
39 * with the content of the commit tree.
40 *
41 * HARD reset will trigger a MIXED reset and the working directory will be
42 * replaced with the content of the index. (Untracked and ignored files
43 * will be left alone, however.)
44 *
45 * TODO: Implement remaining kinds of resets.
46 *
47 * @param repo Repository where to perform the reset operation.
48 *
49 * @param target Committish to which the Head should be moved to. This object
50 * must belong to the given `repo` and can either be a git_commit or a
51 * git_tag. When a git_tag is being passed, it should be dereferencable
52 * to a git_commit which oid will be used as the target of the branch.
53 *
54 * @param reset_type Kind of reset operation to perform.
55 *
56 * @param checkout_opts Optional checkout options to be used for a HARD reset.
57 * The checkout_strategy field will be overridden (based on reset_type).
58 * This parameter can be used to propagate notify and progress callbacks.
59 *
60 * @return 0 on success or an error code
61 */
62 GIT_EXTERN(int) git_reset(
63 git_repository *repo,
64 const git_object *target,
65 git_reset_t reset_type,
66 const git_checkout_options *checkout_opts);
67
68 /**
69 * Sets the current head to the specified commit oid and optionally
70 * resets the index and working tree to match.
71 *
72 * This behaves like `git_reset()` but takes an annotated commit,
73 * which lets you specify which extended sha syntax string was
74 * specified by a user, allowing for more exact reflog messages.
75 *
76 * See the documentation for `git_reset()`.
77 *
78 * @see git_reset
79 */
80 GIT_EXTERN(int) git_reset_from_annotated(
81 git_repository *repo,
82 const git_annotated_commit *commit,
83 git_reset_t reset_type,
84 const 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 * @param repo Repository where to perform the reset operation.
96 *
97 * @param target The committish which content will be used to reset the content
98 * of the index.
99 *
100 * @param pathspecs List of pathspecs to operate on.
101 *
102 * @return 0 on success or an error code < 0
103 */
104 GIT_EXTERN(int) git_reset_default(
105 git_repository *repo,
106 const git_object *target,
107 const git_strarray* pathspecs);
108
109 /** @} */
110 GIT_END_DECL
111 #endif