mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-05 11:30:01 -05:00
When calling `reset_head()` we automatically derive the commit that the callers wants to move from by reading the HEAD commit. Some callers may already have resolved it, or they may want to move from a different commit that doesn't match HEAD. Introduce a new `oid_from` option that lets the caller specify the commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
81 lines
2.0 KiB
C
81 lines
2.0 KiB
C
#ifndef RESET_H
|
|
#define RESET_H
|
|
|
|
#include "hash.h"
|
|
#include "repository.h"
|
|
|
|
#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
|
|
|
|
enum reset_head_flags {
|
|
/* Request a detached checkout */
|
|
RESET_HEAD_DETACH = (1 << 0),
|
|
|
|
/* Request a reset rather than a checkout */
|
|
RESET_HEAD_HARD = (1 << 1),
|
|
|
|
/* Run the post-checkout hook */
|
|
RESET_HEAD_RUN_POST_CHECKOUT_HOOK = (1 << 2),
|
|
|
|
/* Only update refs, do not touch the worktree */
|
|
RESET_HEAD_REFS_ONLY = (1 << 3),
|
|
|
|
/* Update ORIG_HEAD as well as HEAD */
|
|
RESET_HEAD_ORIG_HEAD = (1 << 4),
|
|
|
|
/*
|
|
* Perform a dry-run by performing the operation without updating
|
|
* any user-visible state.
|
|
*/
|
|
RESET_HEAD_DRY_RUN = (1 << 5),
|
|
|
|
/* Skip updating any references, only update the worktree and index. */
|
|
RESET_HEAD_SKIP_REF_UPDATES = (1 << 6),
|
|
};
|
|
|
|
struct reset_head_opts {
|
|
/*
|
|
* The commit to checkout/reset to. Defaults to HEAD.
|
|
*/
|
|
const struct object_id *oid;
|
|
/*
|
|
* The commit to checkout/reset from when doing a two-way merge. This
|
|
* is used as one of the sides to merge.
|
|
*/
|
|
const struct object_id *oid_from;
|
|
/*
|
|
* Optional value to set ORIG_HEAD. Defaults to HEAD.
|
|
*/
|
|
const struct object_id *orig_head;
|
|
/*
|
|
* Optional branch to switch to.
|
|
*/
|
|
const char *branch;
|
|
/*
|
|
* Flags defined above.
|
|
*/
|
|
enum reset_head_flags flags;
|
|
/*
|
|
* Optional reflog message for branch, defaults to head_msg.
|
|
*/
|
|
const char *branch_msg;
|
|
/*
|
|
* Optional reflog message for HEAD, if this omitted but oid or branch
|
|
* are given then default_reflog_action must be given.
|
|
*/
|
|
const char *head_msg;
|
|
/*
|
|
* Optional reflog message for ORIG_HEAD, if this omitted and flags
|
|
* contains RESET_HEAD_ORIG_HEAD then default_reflog_action must be given.
|
|
*/
|
|
const char *orig_head_msg;
|
|
/*
|
|
* Action to use in default reflog messages, only required if a ref is
|
|
* being updated and the reflog messages above are omitted.
|
|
*/
|
|
const char *default_reflog_action;
|
|
};
|
|
|
|
int reset_head(struct repository *r, const struct reset_head_opts *opts);
|
|
|
|
#endif
|