summaryrefslogtreecommitdiff
path: root/reset.h
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-01-26 13:05:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-01-26 20:08:53 (GMT)
commit6ae8086161d81a707ff36dfdc07f57e4f473e0fd (patch)
treec8ae915a87b20a34794f3a56e4d496af46c8d35e /reset.h
parentee464c4e37c7f34c4e5ba2fce35df4149083e5ea (diff)
downloadgit-6ae8086161d81a707ff36dfdc07f57e4f473e0fd.zip
git-6ae8086161d81a707ff36dfdc07f57e4f473e0fd.tar.gz
git-6ae8086161d81a707ff36dfdc07f57e4f473e0fd.tar.bz2
reset_head(): take struct rebase_head_opts
This function takes a confusingly large number of parameters which makes it difficult to remember which order to pass them in. The following commits will add a couple more parameters which makes the problem worse. To address this change the function to take a struct of options. Using a struct means that it is no longer necessary to remember which order to pass the parameters in and anyone reading the code can easily see which value is passed to each parameter. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reset.h')
-rw-r--r--reset.h40
1 files changed, 36 insertions, 4 deletions
diff --git a/reset.h b/reset.h
index 2daec80..a205be2 100644
--- a/reset.h
+++ b/reset.h
@@ -6,15 +6,47 @@
#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
+/* Request a detached checkout */
#define RESET_HEAD_DETACH (1<<0)
+/* Request a reset rather than a checkout */
#define RESET_HEAD_HARD (1<<1)
+/* Run the post-checkout hook */
#define RESET_HEAD_RUN_POST_CHECKOUT_HOOK (1<<2)
+/* Only update refs, do not touch the worktree */
#define RESET_HEAD_REFS_ONLY (1<<3)
+/* Update ORIG_HEAD as well as HEAD */
#define RESET_ORIG_HEAD (1<<4)
-int reset_head(struct repository *r, struct object_id *oid,
- const char *switch_to_branch, unsigned flags,
- const char *reflog_orig_head, const char *reflog_head,
- const char *default_reflog_action);
+struct reset_head_opts {
+ /*
+ * The commit to checkout/reset to. Defaults to HEAD.
+ */
+ const struct object_id *oid;
+ /*
+ * Optional branch to switch to.
+ */
+ const char *branch;
+ /*
+ * Flags defined above.
+ */
+ unsigned flags;
+ /*
+ * 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_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