Blame include/git2/reset.h

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