| 1 | #ifndef RESET_H |
| 2 | #define RESET_H |
| 3 | |
| 4 | #include "hash.h" |
| 5 | #include "repository.h" |
| 6 | |
| 7 | #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION" |
| 8 | |
| 9 | enum reset_working_tree_flags { |
| 10 | /* Request a detached checkout */ |
| 11 | RESET_WORKING_TREE_DETACH = (1 << 0), |
| 12 | |
| 13 | /* Request a reset rather than a checkout */ |
| 14 | RESET_WORKING_TREE_HARD = (1 << 1), |
| 15 | |
| 16 | /* Run the post-checkout hook */ |
| 17 | RESET_WORKING_TREE_RUN_POST_CHECKOUT_HOOK = (1 << 2), |
| 18 | |
| 19 | /* Only update refs, do not touch the worktree */ |
| 20 | RESET_WORKING_TREE_REFS_ONLY = (1 << 3), |
| 21 | |
| 22 | /* Update HEAD */ |
| 23 | RESET_WORKING_TREE_UPDATE_HEAD = (1 << 4), |
| 24 | |
| 25 | /* Update ORIG_HEAD */ |
| 26 | RESET_WORKING_TREE_UPDATE_ORIG_HEAD = (1 << 5), |
| 27 | |
| 28 | /* |
| 29 | * Perform a dry-run by performing the operation without updating |
| 30 | * any user-visible state. |
| 31 | */ |
| 32 | RESET_WORKING_TREE_DRY_RUN = (1 << 6), |
| 33 | }; |
| 34 | |
| 35 | struct reset_working_tree_options { |
| 36 | /* |
| 37 | * The commit to checkout/reset to. Defaults to HEAD. |
| 38 | */ |
| 39 | const struct object_id *oid; |
| 40 | /* |
| 41 | * The commit to checkout/reset from when doing a two-way merge. This |
| 42 | * is used as one of the sides to merge. |
| 43 | */ |
| 44 | const struct object_id *oid_from; |
| 45 | /* |
| 46 | * Optional value to set ORIG_HEAD. Defaults to HEAD. |
| 47 | */ |
| 48 | const struct object_id *orig_head; |
| 49 | /* |
| 50 | * Optional branch to switch to. |
| 51 | */ |
| 52 | const char *branch; |
| 53 | /* |
| 54 | * Flags defined above. |
| 55 | */ |
| 56 | enum reset_working_tree_flags flags; |
| 57 | /* |
| 58 | * Optional reflog message for branch, defaults to head_msg. |
| 59 | */ |
| 60 | const char *branch_msg; |
| 61 | /* |
| 62 | * Optional reflog message for HEAD, if this omitted but oid or branch |
| 63 | * are given then default_reflog_action must be given. |
| 64 | */ |
| 65 | const char *head_msg; |
| 66 | /* |
| 67 | * Optional reflog message for ORIG_HEAD, if this omitted and flags |
| 68 | * contains RESET_WORKING_TREE_UPDATE_ORIG_HEAD then |
| 69 | * default_reflog_action must be given. |
| 70 | */ |
| 71 | const char *orig_head_msg; |
| 72 | /* |
| 73 | * Action to use in default reflog messages, only required if a ref is |
| 74 | * being updated and the reflog messages above are omitted. |
| 75 | */ |
| 76 | const char *default_reflog_action; |
| 77 | }; |
| 78 | |
| 79 | int reset_working_tree(struct repository *r, const struct reset_working_tree_options *opts); |
| 80 | |
| 81 | #endif |