]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: allow create_autostash to run silently
authorHarald Nordgren <haraldnordgren@gmail.com>
Tue, 28 Apr 2026 18:39:09 +0000 (18:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2026 12:46:02 +0000 (21:46 +0900)
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>
builtin/merge.c
sequencer.c
sequencer.h

index 2cbce56f8da9f7027cc95ad98540084b0ee98111..3ebe190ef1e21924ad844db4c3523c362cc4078d 100644 (file)
@@ -1672,7 +1672,8 @@ int cmd_merge(int argc,
                }
 
                if (autostash)
-                       create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
+                       create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
+                                            NULL, false);
                if (checkout_fast_forward(the_repository,
                                          &head_commit->object.oid,
                                          &commit->object.oid,
@@ -1764,7 +1765,8 @@ int cmd_merge(int argc,
                die_ff_impossible();
 
        if (autostash)
-               create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
+               create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
+                                    NULL, false);
 
        /* We are going to make a new commit. */
        git_committer_info(IDENT_STRICT);
index b7d8dca47f4a58a7b67340dabea99a0f3ace86d0..ff5258f48125e7d8f6624771706eb2d60b6c1c54 100644 (file)
@@ -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,13 @@ 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)
+void create_autostash_ref(struct repository *r, const char *refname,
+                         const char *message, bool silent)
 {
-       create_autostash_internal(r, NULL, refname);
+       create_autostash_internal(r, NULL, refname, message, silent);
 }
 
 static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
index a6fa670c7c1f99a8bcd68f58540ee793b67894bc..02d2d9db065dca83e37e7a0594a408aac95630e7 100644 (file)
@@ -229,7 +229,8 @@ void commit_post_rewrite(struct repository *r,
                         const struct object_id *new_head);
 
 void create_autostash(struct repository *r, const char *path);
-void create_autostash_ref(struct repository *r, const char *refname);
+void create_autostash_ref(struct repository *r, const char *refname,
+                         const char *message, bool silent);
 int save_autostash(const char *path);
 int save_autostash_ref(struct repository *r, const char *refname);
 int apply_autostash(const char *path);