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>
Harald Nordgren committed
Apr 28, 2026 at 18:39 UTC
93177db652ce15533494033b1379b4e434cff364
3 files changed
+17
-9
builtin/merge.c
+4
-2
@@ -1672,7 +1672,8 @@ int cmd_merge(int argc,
1672
}
1673
1674
if (autostash)
1675
- create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1675
+ create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1676
+ NULL, false);
1677
if (checkout_fast_forward(the_repository,
1678
&head_commit->object.oid,
1679
&commit->object.oid,
@@ -1764,7 +1765,8 @@ int cmd_merge(int argc,
1765
die_ff_impossible();
1766
1767
if (autostash)
1767
- create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1768
+ create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1769
+ NULL, false);
1770
1771
/* We are going to make a new commit. */
1772
git_committer_info(IDENT_STRICT);
sequencer.c
+11
-6
@@ -4657,7 +4657,9 @@ static enum todo_command peek_command(struct todo_list *todo_list, int offset)
4657
4658
static void create_autostash_internal(struct repository *r,
4659
const char *path,
4660
- const char *refname)
4660
+ const char *refname,
4661
+ const char *message,
4662
+ bool silent)
4663
{
4664
struct strbuf buf = STRBUF_INIT;
4665
struct lock_file lock_file = LOCK_INIT;
@@ -4679,7 +4681,8 @@ static void create_autostash_internal(struct repository *r,
4681
struct object_id oid;
4682
4683
strvec_pushl(&stash.args,
4682
- "stash", "create", "autostash", NULL);
4684
+ "stash", "create",
4685
+ message ? message : "autostash", NULL);
4686
stash.git_cmd = 1;
4687
stash.no_stdin = 1;
4688
strbuf_reset(&buf);
@@ -4702,7 +4705,8 @@ static void create_autostash_internal(struct repository *r,
4705
&oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
4706
}
4707
4705
- printf(_("Created autostash: %s\n"), buf.buf);
4708
+ if (!silent)
4709
+ printf(_("Created autostash: %s\n"), buf.buf);
4710
if (reset_head(r, &ropts) < 0)
4711
die(_("could not reset --hard"));
4712
discard_index(r->index);
@@ -4714,12 +4718,13 @@ static void create_autostash_internal(struct repository *r,
4718
4719
void create_autostash(struct repository *r, const char *path)
4720
{
4717
- create_autostash_internal(r, path, NULL);
4721
+ create_autostash_internal(r, path, NULL, NULL, false);
4722
}
4723
4720
-void create_autostash_ref(struct repository *r, const char *refname)
4724
+void create_autostash_ref(struct repository *r, const char *refname,
4725
+ const char *message, bool silent)
4726
{
4722
- create_autostash_internal(r, NULL, refname);
4727
+ create_autostash_internal(r, NULL, refname, message, silent);
4728
}
4729
4730
static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
sequencer.h
+2
-1
@@ -229,7 +229,8 @@ void commit_post_rewrite(struct repository *r,
229
const struct object_id *new_head);
230
231
void create_autostash(struct repository *r, const char *path);
232
-void create_autostash_ref(struct repository *r, const char *refname);
232
+void create_autostash_ref(struct repository *r, const char *refname,
233
+ const char *message, bool silent);
234
int save_autostash(const char *path);
235
int save_autostash_ref(struct repository *r, const char *refname);
236
int apply_autostash(const char *path);