summaryrefslogtreecommitdiff
path: root/sequencer.c
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 /sequencer.c
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 'sequencer.c')
-rw-r--r--sequencer.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c
index 119564f..55ed074 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4115,6 +4115,7 @@ void create_autostash(struct repository *r, const char *path)
if (has_unstaged_changes(r, 1) ||
has_uncommitted_changes(r, 1)) {
struct child_process stash = CHILD_PROCESS_INIT;
+ struct reset_head_opts ropts = { .flags = RESET_HEAD_HARD };
struct object_id oid;
strvec_pushl(&stash.args,
@@ -4136,10 +4137,8 @@ void create_autostash(struct repository *r, const char *path)
path);
write_file(path, "%s", oid_to_hex(&oid));
printf(_("Created autostash: %s\n"), buf.buf);
- if (reset_head(r, NULL, NULL, RESET_HEAD_HARD, NULL, NULL,
- NULL) < 0)
+ if (reset_head(r, &ropts) < 0)
die(_("could not reset --hard"));
-
if (discard_index(r->index) < 0 ||
repo_read_index(r) < 0)
die(_("could not read index"));