From 666ae6eea852012f60be6e50a2f2ef879367ade6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 11 Mar 2019 16:36:15 +0100 Subject: [PATCH] fixup! stash: make push -q quiet In preparation for a newer patch series. Signed-off-by: Johannes Schindelin --- builtin/stash--helper.c | 56 +++++++++++++++-------------------------- t/t3903-stash.sh | 23 ----------------- 2 files changed, 20 insertions(+), 59 deletions(-) diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c index 228e7411de..31ee9c816b 100644 --- a/builtin/stash--helper.c +++ b/builtin/stash--helper.c @@ -973,7 +973,7 @@ done: } static int stash_patch(struct stash_info *info, struct pathspec ps, - struct strbuf *out_patch, int quiet) + struct strbuf *out_patch) { int ret = 0; struct strbuf out = STRBUF_INIT; @@ -1026,8 +1026,7 @@ static int stash_patch(struct stash_info *info, struct pathspec ps, } if (!out_patch->len) { - if (!quiet) - fprintf_ln(stderr, _("No changes selected")); + fprintf_ln(stderr, _("No changes selected")); ret = 1; } @@ -1105,8 +1104,7 @@ done: static int do_create_stash(struct pathspec ps, struct strbuf *stash_msg_buf, int include_untracked, int patch_mode, - struct stash_info *info, struct strbuf *patch, - int quiet) + struct stash_info *info, struct strbuf *patch) { int ret = 0; int flags = 0; @@ -1126,9 +1124,7 @@ static int do_create_stash(struct pathspec ps, struct strbuf *stash_msg_buf, refresh_cache(REFRESH_QUIET); if (get_oid("HEAD", &info->b_commit)) { - if (!quiet) - fprintf_ln(stderr, _("You do not have " - "the initial commit yet")); + fprintf_ln(stderr, _("You do not have the initial commit yet")); ret = -1; goto done; } else { @@ -1153,9 +1149,7 @@ static int do_create_stash(struct pathspec ps, struct strbuf *stash_msg_buf, if (write_cache_as_tree(&info->i_tree, 0, NULL) || commit_tree(commit_tree_label.buf, commit_tree_label.len, &info->i_tree, parents, &info->i_commit, NULL, NULL)) { - if (!quiet) - fprintf_ln(stderr, _("Cannot save the current " - "index state")); + fprintf_ln(stderr, _("Cannot save the current index state")); ret = -1; goto done; } @@ -1163,29 +1157,26 @@ static int do_create_stash(struct pathspec ps, struct strbuf *stash_msg_buf, if (include_untracked && get_untracked_files(ps, include_untracked, &untracked_files)) { if (save_untracked_files(info, &msg, untracked_files)) { - if (!quiet) - fprintf_ln(stderr, _("Cannot save " - "the untracked files")); + fprintf_ln(stderr, _("Cannot save " + "the untracked files")); ret = -1; goto done; } untracked_commit_option = 1; } if (patch_mode) { - ret = stash_patch(info, ps, patch, quiet); + ret = stash_patch(info, ps, patch); if (ret < 0) { - if (!quiet) - fprintf_ln(stderr, _("Cannot save the current " - "worktree state")); + fprintf_ln(stderr, _("Cannot save the current " + "worktree state")); goto done; } else if (ret > 0) { goto done; } } else { if (stash_working_tree(info, ps)) { - if (!quiet) - fprintf_ln(stderr, _("Cannot save the current " - "worktree state")); + fprintf_ln(stderr, _("Cannot save the current " + "worktree state")); ret = -1; goto done; } @@ -1211,9 +1202,7 @@ static int do_create_stash(struct pathspec ps, struct strbuf *stash_msg_buf, if (commit_tree(stash_msg_buf->buf, stash_msg_buf->len, &info->w_tree, parents, &info->w_commit, NULL, NULL)) { - if (!quiet) - fprintf_ln(stderr, _("Cannot record " - "working tree state")); + fprintf_ln(stderr, _("Cannot record working tree state")); ret = -1; goto done; } @@ -1248,7 +1237,7 @@ static int create_stash(int argc, const char **argv, const char *prefix) memset(&ps, 0, sizeof(ps)); strbuf_addstr(&stash_msg_buf, stash_msg); ret = do_create_stash(ps, &stash_msg_buf, include_untracked, 0, &info, - NULL, 0); + NULL); if (!ret) printf_ln("%s", oid_to_hex(&info.w_commit)); @@ -1311,29 +1300,26 @@ static int do_push_stash(struct pathspec ps, const char *stash_msg, int quiet, if (!reflog_exists(ref_stash) && do_clear_stash()) { ret = -1; - if (!quiet) - fprintf_ln(stderr, _("Cannot initialize stash")); + fprintf_ln(stderr, _("Cannot initialize stash")); goto done; } if (stash_msg) strbuf_addstr(&stash_msg_buf, stash_msg); if (do_create_stash(ps, &stash_msg_buf, include_untracked, patch_mode, - &info, &patch, quiet)) { + &info, &patch)) { ret = -1; goto done; } if (do_store_stash(&info.w_commit, stash_msg_buf.buf, 1)) { ret = -1; - if (!quiet) - fprintf_ln(stderr, _("Cannot save the current status")); + fprintf_ln(stderr, _("Cannot save the current status")); goto done; } - if (!quiet) - printf_ln(_("Saved working directory and index state %s"), - stash_msg_buf.buf); + printf_ln(_("Saved working directory and index state %s"), + stash_msg_buf.buf); if (!patch_mode) { if (include_untracked && !ps.nr) { @@ -1434,9 +1420,7 @@ static int do_push_stash(struct pathspec ps, const char *stash_msg, int quiet, argv_array_pushl(&cp.args, "apply", "-R", NULL); if (pipe_command(&cp, patch.buf, patch.len, NULL, 0, NULL, 0)) { - if (!quiet) - fprintf_ln(stderr, _("Cannot remove " - "worktree changes")); + fprintf_ln(stderr, _("Cannot remove worktree changes")); ret = -1; goto done; } diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index b67d7a1120..98c25a671c 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1064,29 +1064,6 @@ test_expect_success 'push: not in the repository errors out' ' test_path_is_file untracked ' -test_expect_success 'push: -q is quiet with changes' ' - >foo && - git add foo && - git stash push -q >output 2>&1 && - test_must_be_empty output -' - -test_expect_success 'push: -q is quiet with no changes' ' - git stash push -q >output 2>&1 && - test_must_be_empty output -' - -test_expect_success 'push: -q is quiet even if there is no initial commit' ' - git init foo_dir && - test_when_finished rm -rf foo_dir && - ( - cd foo_dir && - >bar && - test_must_fail git stash push -q >output 2>&1 && - test_must_be_empty output - ) -' - test_expect_success 'untracked files are left in place when -u is not given' ' >file && git add file &&