Re: [PATCH v2 07/14] create_autostash(): remove unneeded parameter
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 9, 2021, 19:17 UTC
- Message-ID
- <xmqqpmq5r3j9.fsf@gitster.g>
- In-Reply-To
- <341fe183c18ee28b459ba26f2c8c369d9367c328.1638975482.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk> > > The default_reflog parameter of create_autostash() is passed to > reset_head(). However as creating a stash does not involve updating > any refs the parameter is not used by reset_head(). Removing the > parameter from create_autostash() simplifies the callers.
It does make the callers of create_autostash() easier to reason about, but ...
Show 6 quoted lines
> @@ -4132,7 +4131,7 @@ void create_autostash(struct repository *r, const char *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,
> - default_reflog_action) < 0)
> + "") < 0)... makes the reader wonder what the empty string is doing here. The fact that reset_head() does not care about the last parameter when not given oid or switch_to_branch parameters feels like too much implementation detail to expect the callers to know about.
Unless it is documented in reset.[ch] before the beginning of the "int reset_head(...)" definition/declaration, that is.
Show 17 quoted lines
> die(_("could not reset --hard"));
>
> if (discard_index(r->index) < 0 ||
> diff --git a/sequencer.h b/sequencer.h
> index 05a7d2ba6b3..da64473636b 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -197,8 +197,7 @@ void commit_post_rewrite(struct repository *r,
> const struct commit *current_head,
> const struct object_id *new_head);
>
> -void create_autostash(struct repository *r, const char *path,
> - const char *default_reflog_action);
> +void create_autostash(struct repository *r, const char *path);
> int save_autostash(const char *path);
> int apply_autostash(const char *path);
> int apply_autostash_oid(const char *stash_oid);