]>
git.proxmox.com Git - libgit2.git/blob - include/git2/reset.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_reset_h__
8 #define INCLUDE_git_reset_h__
17 * @brief Git reset management routines
24 * Kinds of reset operation
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 */
33 * Sets the current head to the specified commit oid and optionally
34 * resets the index and working tree to match.
36 * SOFT reset means the Head will be moved to the commit.
38 * MIXED reset will trigger a SOFT reset, plus the index will be replaced
39 * with the content of the commit tree.
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.)
45 * TODO: Implement remaining kinds of resets.
47 * @param repo Repository where to perform the reset operation.
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.
54 * @param reset_type Kind of reset operation to perform.
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.
60 * @return 0 on success or an error code
62 GIT_EXTERN(int) git_reset(
64 const git_object
*target
,
65 git_reset_t reset_type
,
66 const git_checkout_options
*checkout_opts
);
69 * Sets the current head to the specified commit oid and optionally
70 * resets the index and working tree to match.
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.
76 * See the documentation for `git_reset()`.
80 GIT_EXTERN(int) git_reset_from_annotated(
82 const git_annotated_commit
*commit
,
83 git_reset_t reset_type
,
84 const git_checkout_options
*checkout_opts
);
87 * Updates some entries in the index from the target commit tree.
89 * The scope of the updated entries is determined by the paths
90 * being passed in the `pathspec` parameters.
92 * Passing a NULL `target` will result in removing
93 * entries in the index matching the provided pathspecs.
95 * @param repo Repository where to perform the reset operation.
97 * @param target The committish which content will be used to reset the content
100 * @param pathspecs List of pathspecs to operate on.
102 * @return 0 on success or an error code < 0
104 GIT_EXTERN(int) git_reset_default(
105 git_repository
*repo
,
106 const git_object
*target
,
107 const git_strarray
* pathspecs
);