Skip to content

Commit 464927c

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 97658d4 commit 464927c

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

builtin/merge.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,8 @@ int cmd_merge(int argc,
16721672
}
16731673

16741674
if (autostash)
1675-
create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1675+
create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1676+
NULL, false);
16761677
if (checkout_fast_forward(the_repository,
16771678
&head_commit->object.oid,
16781679
&commit->object.oid,
@@ -1764,7 +1765,8 @@ int cmd_merge(int argc,
17641765
die_ff_impossible();
17651766

17661767
if (autostash)
1767-
create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1768+
create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1769+
NULL, false);
17681770

17691771
/* We are going to make a new commit. */
17701772
git_committer_info(IDENT_STRICT);

sequencer.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,7 +4657,9 @@ 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+
const char *message,
4662+
bool silent)
46614663
{
46624664
struct strbuf buf = STRBUF_INIT;
46634665
struct lock_file lock_file = LOCK_INIT;
@@ -4679,7 +4681,8 @@ static void create_autostash_internal(struct repository *r,
46794681
struct object_id oid;
46804682

46814683
strvec_pushl(&stash.args,
4682-
"stash", "create", "autostash", NULL);
4684+
"stash", "create",
4685+
message ? message : "autostash", NULL);
46834686
stash.git_cmd = 1;
46844687
stash.no_stdin = 1;
46854688
strbuf_reset(&buf);
@@ -4702,7 +4705,8 @@ static void create_autostash_internal(struct repository *r,
47024705
&oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
47034706
}
47044707

4705-
printf(_("Created autostash: %s\n"), buf.buf);
4708+
if (!silent)
4709+
printf(_("Created autostash: %s\n"), buf.buf);
47064710
if (reset_head(r, &ropts) < 0)
47074711
die(_("could not reset --hard"));
47084712
discard_index(r->index);
@@ -4714,12 +4718,13 @@ static void create_autostash_internal(struct repository *r,
47144718

47154719
void create_autostash(struct repository *r, const char *path)
47164720
{
4717-
create_autostash_internal(r, path, NULL);
4721+
create_autostash_internal(r, path, NULL, NULL, false);
47184722
}
47194723

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)
47214726
{
4722-
create_autostash_internal(r, NULL, refname);
4727+
create_autostash_internal(r, NULL, refname, message, silent);
47234728
}
47244729

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

sequencer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ void commit_post_rewrite(struct repository *r,
229229
const struct object_id *new_head);
230230

231231
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);
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)