blob: 10708d8ddc0040f86b5b1f400bfb14d932dffe8e [file] [log] [blame]
Denton Liub309a972020-04-07 10:28:00 -04001#ifndef RESET_H
2#define RESET_H
3
Elijah Newrend1cbe1e2023-04-22 20:17:20 +00004#include "hash-ll.h"
Denton Liub309a972020-04-07 10:28:00 -04005#include "repository.h"
6
7#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
8
Phillip Wood6ae80862022-01-26 13:05:46 +00009/* Request a detached checkout */
Denton Liub309a972020-04-07 10:28:00 -040010#define RESET_HEAD_DETACH (1<<0)
Phillip Wood6ae80862022-01-26 13:05:46 +000011/* Request a reset rather than a checkout */
Denton Liub309a972020-04-07 10:28:00 -040012#define RESET_HEAD_HARD (1<<1)
Phillip Wood6ae80862022-01-26 13:05:46 +000013/* Run the post-checkout hook */
Denton Liub309a972020-04-07 10:28:00 -040014#define RESET_HEAD_RUN_POST_CHECKOUT_HOOK (1<<2)
Phillip Wood6ae80862022-01-26 13:05:46 +000015/* Only update refs, do not touch the worktree */
Denton Liub309a972020-04-07 10:28:00 -040016#define RESET_HEAD_REFS_ONLY (1<<3)
Phillip Wood6ae80862022-01-26 13:05:46 +000017/* Update ORIG_HEAD as well as HEAD */
Denton Liub309a972020-04-07 10:28:00 -040018#define RESET_ORIG_HEAD (1<<4)
19
Phillip Wood6ae80862022-01-26 13:05:46 +000020struct reset_head_opts {
21 /*
22 * The commit to checkout/reset to. Defaults to HEAD.
23 */
24 const struct object_id *oid;
25 /*
Phillip Woodcd1528e2022-01-26 13:05:48 +000026 * Optional value to set ORIG_HEAD. Defaults to HEAD.
27 */
28 const struct object_id *orig_head;
29 /*
Phillip Wood6ae80862022-01-26 13:05:46 +000030 * Optional branch to switch to.
31 */
32 const char *branch;
33 /*
34 * Flags defined above.
35 */
36 unsigned flags;
37 /*
Phillip Wood7700ab02022-01-26 13:05:47 +000038 * Optional reflog message for branch, defaults to head_msg.
39 */
40 const char *branch_msg;
41 /*
Phillip Wood6ae80862022-01-26 13:05:46 +000042 * Optional reflog message for HEAD, if this omitted but oid or branch
43 * are given then default_reflog_action must be given.
44 */
45 const char *head_msg;
46 /*
47 * Optional reflog message for ORIG_HEAD, if this omitted and flags
48 * contains RESET_ORIG_HEAD then default_reflog_action must be given.
49 */
50 const char *orig_head_msg;
51 /*
52 * Action to use in default reflog messages, only required if a ref is
53 * being updated and the reflog messages above are omitted.
54 */
55 const char *default_reflog_action;
56};
57
58int reset_head(struct repository *r, const struct reset_head_opts *opts);
Denton Liub309a972020-04-07 10:28:00 -040059
60#endif