From: Phillip Wood Date: Fri, 10 Apr 2026 15:39:27 GMT Subject: Re: [PATCH v8 2/4] sequencer: allow create_autostash to run silently Message-ID: In-Reply-To: <86cf68d0240ef90ce941cc162ada658a5058795b.1775762235.git.gitgitgadget@gmail.com> Hi Harald On 09/04/2026 20:17, Harald Nordgren via GitGitGadget wrote: > From: Harald Nordgren > > 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. Use stderr for > the message when not silent. Why do we want to change where the message is printed? It is not necessarily a bad idea but it would be helpful to explain why we want that particular change. > Signed-off-by: Harald Nordgren > --- > sequencer.c | 15 +++++++++++---- > sequencer.h | 1 + > 2 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index b7d8dca47f..e500a94a59 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -4657,7 +4657,8 @@ 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, > + int silent) This could be a "bool" and the users could pass "true" and "false". Apart from that this looks good. Thanks Phillip > { > struct strbuf buf = STRBUF_INIT; > struct lock_file lock_file = LOCK_INIT; > @@ -4702,7 +4703,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) > + fprintf(stderr, _("Created autostash: %s\n"), buf.buf); > if (reset_head(r, &ropts) < 0) > die(_("could not reset --hard")); > discard_index(r->index); > @@ -4714,12 +4716,17 @@ 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, 0); > } > > void create_autostash_ref(struct repository *r, const char *refname) > { > - create_autostash_internal(r, NULL, refname); > + create_autostash_internal(r, NULL, refname, 0); > +} > + > +void create_autostash_ref_silent(struct repository *r, const char *refname) > +{ > + create_autostash_internal(r, NULL, refname, 1); > } > > static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply) > diff --git a/sequencer.h b/sequencer.h > index a6fa670c7c..570f804457 100644 > --- a/sequencer.h > +++ b/sequencer.h > @@ -230,6 +230,7 @@ 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_silent(struct repository *r, const char *refname); > int save_autostash(const char *path); > int save_autostash_ref(struct repository *r, const char *refname); > int apply_autostash(const char *path);