Re: [PATCH v12 2/4] sequencer: allow create_autostash to run silently
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Apr 14, 2026, 14:06 UTC
- Message-ID
- <e651e491-e59f-462a-9e81-35546112ce57@gmail.com>
- In-Reply-To
- <e11a622bdf4752273dc2de26f3108d329abb04b3.1776171585.git.gitgitgadget@gmail.com>
Hi Harald
On 14/04/2026 13:59, Harald Nordgren via GitGitGadget wrote:
Show 7 quoted lines
> From: Harald Nordgren <haraldnordgren@gmail.com> > > Add a silent parameter to create_autostash_internal and introduce > create_autostash_ref_silent so that callers can create an autostash > without printing the "Created autostash" message. > > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
I wonder if we should just update the two callers of create_autostash_ref() instead of adding a new function but the implementation looks sensible
Thanks
Phillip
Show 73 quoted lines
> sequencer.c | 20 +++++++++++++++-----
> sequencer.h | 2 ++
> 2 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index b7d8dca47f..780628aab4 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4657,7 +4657,9 @@ static enum todo_command peek_command(struct todo_list *todo_list, int offset)
>
> static void create_autostash_internal(struct repository *r,
> const char *path,
> - const char *refname)
> + const char *refname,
> + const char *message,
> + bool silent)
> {
> struct strbuf buf = STRBUF_INIT;
> struct lock_file lock_file = LOCK_INIT;
> @@ -4679,7 +4681,8 @@ static void create_autostash_internal(struct repository *r,
> struct object_id oid;
>
> strvec_pushl(&stash.args,
> - "stash", "create", "autostash", NULL);
> + "stash", "create",
> + message ? message : "autostash", NULL);
> stash.git_cmd = 1;
> stash.no_stdin = 1;
> strbuf_reset(&buf);
> @@ -4702,7 +4705,8 @@ static void create_autostash_internal(struct repository *r,
> &oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
> }
>
> - printf(_("Created autostash: %s\n"), buf.buf);
> + if (!silent)
> + printf(_("Created autostash: %s\n"), buf.buf);
> if (reset_head(r, &ropts) < 0)
> die(_("could not reset --hard"));
> discard_index(r->index);
> @@ -4714,12 +4718,18 @@ static void create_autostash_internal(struct repository *r,
>
> void create_autostash(struct repository *r, const char *path)
> {
> - create_autostash_internal(r, path, NULL);
> + create_autostash_internal(r, path, NULL, NULL, false);
> }
>
> void create_autostash_ref(struct repository *r, const char *refname)
> {
> - create_autostash_internal(r, NULL, refname);
> + create_autostash_internal(r, NULL, refname, NULL, false);
> +}
> +
> +void create_autostash_ref_with_msg_silent(struct repository *r, const char *refname,
> + const char *message)
> +{
> + create_autostash_internal(r, NULL, refname, message, true);
> }
>
> static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
> diff --git a/sequencer.h b/sequencer.h
> index a6fa670c7c..5d3bc83314 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -230,6 +230,8 @@ void commit_post_rewrite(struct repository *r,
>
> void create_autostash(struct repository *r, const char *path);
> void create_autostash_ref(struct repository *r, const char *refname);
> +void create_autostash_ref_with_msg_silent(struct repository *r, const char *refname,
> + const char *message);
> int save_autostash(const char *path);
> int save_autostash_ref(struct repository *r, const char *refname);
> int apply_autostash(const char *path);