Skip to content

Commit 3eb9e7e

Browse files
HaraldNordgrengitster
authored andcommitted
sequencer: allow create_autostash to run silently
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. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
1 parent 52c7db5 commit 3eb9e7e

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

sequencer.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,7 +4632,8 @@ static enum todo_command peek_command(struct todo_list *todo_list, int offset)
46324632

46334633
static void create_autostash_internal(struct repository *r,
46344634
const char *path,
4635-
const char *refname)
4635+
const char *refname,
4636+
int silent)
46364637
{
46374638
struct strbuf buf = STRBUF_INIT;
46384639
struct lock_file lock_file = LOCK_INIT;
@@ -4677,7 +4678,8 @@ static void create_autostash_internal(struct repository *r,
46774678
&oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
46784679
}
46794680

4680-
printf(_("Created autostash: %s\n"), buf.buf);
4681+
if (!silent)
4682+
fprintf(stderr, _("Created autostash: %s\n"), buf.buf);
46814683
if (reset_head(r, &ropts) < 0)
46824684
die(_("could not reset --hard"));
46834685
discard_index(r->index);
@@ -4689,12 +4691,17 @@ static void create_autostash_internal(struct repository *r,
46894691

46904692
void create_autostash(struct repository *r, const char *path)
46914693
{
4692-
create_autostash_internal(r, path, NULL);
4694+
create_autostash_internal(r, path, NULL, 0);
46934695
}
46944696

46954697
void create_autostash_ref(struct repository *r, const char *refname)
46964698
{
4697-
create_autostash_internal(r, NULL, refname);
4699+
create_autostash_internal(r, NULL, refname, 0);
4700+
}
4701+
4702+
void create_autostash_ref_silent(struct repository *r, const char *refname)
4703+
{
4704+
create_autostash_internal(r, NULL, refname, 1);
46984705
}
46994706

47004707
static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)

sequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ void commit_post_rewrite(struct repository *r,
227227

228228
void create_autostash(struct repository *r, const char *path);
229229
void create_autostash_ref(struct repository *r, const char *refname);
230+
void create_autostash_ref_silent(struct repository *r, const char *refname);
230231
int save_autostash(const char *path);
231232
int save_autostash_ref(struct repository *r, const char *refname);
232233
int apply_autostash(const char *path);

0 commit comments

Comments
 (0)