Skip to content

Commit 3392b76

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. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1fcc199 commit 3392b76

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sequencer.c

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

46584658
static void create_autostash_internal(struct repository *r,
46594659
const char *path,
4660-
const char *refname)
4660+
const char *refname,
4661+
bool silent)
46614662
{
46624663
struct strbuf buf = STRBUF_INIT;
46634664
struct lock_file lock_file = LOCK_INIT;
@@ -4702,7 +4703,8 @@ static void create_autostash_internal(struct repository *r,
47024703
&oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
47034704
}
47044705

4705-
printf(_("Created autostash: %s\n"), buf.buf);
4706+
if (!silent)
4707+
printf(_("Created autostash: %s\n"), buf.buf);
47064708
if (reset_head(r, &ropts) < 0)
47074709
die(_("could not reset --hard"));
47084710
discard_index(r->index);
@@ -4714,12 +4716,17 @@ static void create_autostash_internal(struct repository *r,
47144716

47154717
void create_autostash(struct repository *r, const char *path)
47164718
{
4717-
create_autostash_internal(r, path, NULL);
4719+
create_autostash_internal(r, path, NULL, false);
47184720
}
47194721

47204722
void create_autostash_ref(struct repository *r, const char *refname)
47214723
{
4722-
create_autostash_internal(r, NULL, refname);
4724+
create_autostash_internal(r, NULL, refname, false);
4725+
}
4726+
4727+
void create_autostash_ref_silent(struct repository *r, const char *refname)
4728+
{
4729+
create_autostash_internal(r, NULL, refname, true);
47234730
}
47244731

47254732
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
@@ -230,6 +230,7 @@ void commit_post_rewrite(struct repository *r,
230230

231231
void create_autostash(struct repository *r, const char *path);
232232
void create_autostash_ref(struct repository *r, const char *refname);
233+
void create_autostash_ref_silent(struct repository *r, const char *refname);
233234
int save_autostash(const char *path);
234235
int save_autostash_ref(struct repository *r, const char *refname);
235236
int apply_autostash(const char *path);

0 commit comments

Comments
 (0)