Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:38

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_git_reset_h__
0008 #define INCLUDE_git_reset_h__
0009 
0010 #include "common.h"
0011 #include "types.h"
0012 #include "strarray.h"
0013 #include "checkout.h"
0014 
0015 /**
0016  * @file git2/reset.h
0017  * @brief Git reset management routines
0018  * @ingroup Git
0019  * @{
0020  */
0021 GIT_BEGIN_DECL
0022 
0023 /**
0024  * Kinds of reset operation
0025  */
0026 typedef enum {
0027     GIT_RESET_SOFT  = 1, /**< Move the head to the given commit */
0028     GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */
0029     GIT_RESET_HARD  = 3  /**< MIXED plus changes in working tree discarded */
0030 } git_reset_t;
0031 
0032 /**
0033  * Sets the current head to the specified commit oid and optionally
0034  * resets the index and working tree to match.
0035  *
0036  * SOFT reset means the Head will be moved to the commit.
0037  *
0038  * MIXED reset will trigger a SOFT reset, plus the index will be replaced
0039  * with the content of the commit tree.
0040  *
0041  * HARD reset will trigger a MIXED reset and the working directory will be
0042  * replaced with the content of the index.  (Untracked and ignored files
0043  * will be left alone, however.)
0044  *
0045  * TODO: Implement remaining kinds of resets.
0046  *
0047  * @param repo Repository where to perform the reset operation.
0048  *
0049  * @param target Committish to which the Head should be moved to. This object
0050  * must belong to the given `repo` and can either be a git_commit or a
0051  * git_tag. When a git_tag is being passed, it should be dereferenceable
0052  * to a git_commit which oid will be used as the target of the branch.
0053  *
0054  * @param reset_type Kind of reset operation to perform.
0055  *
0056  * @param checkout_opts Optional checkout options to be used for a HARD reset.
0057  * The checkout_strategy field will be overridden (based on reset_type).
0058  * This parameter can be used to propagate notify and progress callbacks.
0059  *
0060  * @return 0 on success or an error code
0061  */
0062 GIT_EXTERN(int) git_reset(
0063     git_repository *repo,
0064     const git_object *target,
0065     git_reset_t reset_type,
0066     const git_checkout_options *checkout_opts);
0067 
0068 /**
0069  * Sets the current head to the specified commit oid and optionally
0070  * resets the index and working tree to match.
0071  *
0072  * This behaves like `git_reset()` but takes an annotated commit,
0073  * which lets you specify which extended sha syntax string was
0074  * specified by a user, allowing for more exact reflog messages.
0075  *
0076  * See the documentation for `git_reset()`.
0077  *
0078  * @see git_reset
0079  */
0080 GIT_EXTERN(int) git_reset_from_annotated(
0081     git_repository *repo,
0082     const git_annotated_commit *commit,
0083     git_reset_t reset_type,
0084     const git_checkout_options *checkout_opts);
0085 
0086 /**
0087  * Updates some entries in the index from the target commit tree.
0088  *
0089  * The scope of the updated entries is determined by the paths
0090  * being passed in the `pathspec` parameters.
0091  *
0092  * Passing a NULL `target` will result in removing
0093  * entries in the index matching the provided pathspecs.
0094  *
0095  * @param repo Repository where to perform the reset operation.
0096  *
0097  * @param target The committish which content will be used to reset the content
0098  * of the index.
0099  *
0100  * @param pathspecs List of pathspecs to operate on.
0101  *
0102  * @return 0 on success or an error code < 0
0103  */
0104 GIT_EXTERN(int) git_reset_default(
0105     git_repository *repo,
0106     const git_object *target,
0107     const git_strarray* pathspecs);
0108 
0109 /** @} */
0110 GIT_END_DECL
0111 #endif