Blame include/git2/reset.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_reset_h__
Packit Service 20376f
#define INCLUDE_git_reset_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "strarray.h"
Packit Service 20376f
#include "checkout.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/reset.h
Packit Service 20376f
 * @brief Git reset management routines
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Kinds of reset operation
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	GIT_RESET_SOFT  = 1, /**< Move the head to the given commit */
Packit Service 20376f
	GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */
Packit Service 20376f
	GIT_RESET_HARD  = 3, /**< MIXED plus changes in working tree discarded */
Packit Service 20376f
} git_reset_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Sets the current head to the specified commit oid and optionally
Packit Service 20376f
 * resets the index and working tree to match.
Packit Service 20376f
 *
Packit Service 20376f
 * SOFT reset means the Head will be moved to the commit.
Packit Service 20376f
 *
Packit Service 20376f
 * MIXED reset will trigger a SOFT reset, plus the index will be replaced
Packit Service 20376f
 * with the content of the commit tree.
Packit Service 20376f
 *
Packit Service 20376f
 * HARD reset will trigger a MIXED reset and the working directory will be
Packit Service 20376f
 * replaced with the content of the index.  (Untracked and ignored files
Packit Service 20376f
 * will be left alone, however.)
Packit Service 20376f
 *
Packit Service 20376f
 * TODO: Implement remaining kinds of resets.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where to perform the reset operation.
Packit Service 20376f
 *
Packit Service 20376f
 * @param target Committish to which the Head should be moved to. This object
Packit Service 20376f
 * must belong to the given `repo` and can either be a git_commit or a
Packit Service 20376f
 * git_tag. When a git_tag is being passed, it should be dereferencable
Packit Service 20376f
 * to a git_commit which oid will be used as the target of the branch.
Packit Service 20376f
 *
Packit Service 20376f
 * @param reset_type Kind of reset operation to perform.
Packit Service 20376f
 *
Packit Service 20376f
 * @param checkout_opts Optional checkout options to be used for a HARD reset.
Packit Service 20376f
 * The checkout_strategy field will be overridden (based on reset_type).
Packit Service 20376f
 * This parameter can be used to propagate notify and progress callbacks.
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_reset(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_object *target,
Packit Service 20376f
	git_reset_t reset_type,
Packit Service 20376f
	const git_checkout_options *checkout_opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Sets the current head to the specified commit oid and optionally
Packit Service 20376f
 * resets the index and working tree to match.
Packit Service 20376f
 *
Packit Service 20376f
 * This behaves like `git_reset()` but takes an annotated commit,
Packit Service 20376f
 * which lets you specify which extended sha syntax string was
Packit Service 20376f
 * specified by a user, allowing for more exact reflog messages.
Packit Service 20376f
 *
Packit Service 20376f
 * See the documentation for `git_reset()`.
Packit Service 20376f
 *
Packit Service 20376f
 * @see git_reset
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_reset_from_annotated(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_annotated_commit *commit,
Packit Service 20376f
	git_reset_t reset_type,
Packit Service 20376f
	const git_checkout_options *checkout_opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Updates some entries in the index from the target commit tree.
Packit Service 20376f
 *
Packit Service 20376f
 * The scope of the updated entries is determined by the paths
Packit Service 20376f
 * being passed in the `pathspec` parameters.
Packit Service 20376f
 *
Packit Service 20376f
 * Passing a NULL `target` will result in removing
Packit Service 20376f
 * entries in the index matching the provided pathspecs.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where to perform the reset operation.
Packit Service 20376f
 *
Packit Service 20376f
 * @param target The committish which content will be used to reset the content
Packit Service 20376f
 * of the index.
Packit Service 20376f
 *
Packit Service 20376f
 * @param pathspecs List of pathspecs to operate on.
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success or an error code < 0
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_reset_default(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_object *target,
Packit Service 20376f
	git_strarray* pathspecs);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif