{"thread":{"id":"64256","subject":"[PATCH] stash: don't show irrelevant entry count in status","startedAt":"2025-10-06T11:35:41Z","lastAt":"2025-10-12T16:45:47Z","messageCount":6,"participants":["Miroma via GitGitGadget","Karthik Nayak","Junio C Hamano","Miroma"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"527974","messageId":"pull.2067.git.git.1759750539721.gitgitgadget@gmail.com","threadId":"64256","inReplyTo":null,"subject":"[PATCH] stash: don't show irrelevant entry count in status","fromName":"Miroma via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-06T11:35:39Z","receivedAt":"2025-10-06T11:35:41Z","isPatch":true,"sender":{"key":"its.miroma@proton.me","avatar":null},"body":"From: Miroma <its.miroma@proton.me>\n\nCurrently, when status.showStash is set, 'stash pop' shows the\nfollowing, confusing, output:\n\n    ...\n    Your stash currently has 1 entry\n    Dropped refs/stash@{0} (abc123...)\n\nSigned-off-by: Miroma <its.miroma@proton.me>\n---\n    stash: don't show irrelevant entry count in status\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v1\nPull-Request: https://github.com/git/git/pull/2067\n\n builtin/stash.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 1977e50df2..2bd4b7d753 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -705,6 +705,9 @@ restore_untracked:\n \t\t\t     absolute_path(repo_get_work_tree(the_repository)));\n \t\tstrvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT\"=%s\",\n \t\t\t     absolute_path(repo_get_git_dir(the_repository)));\n+\t\tstrvec_push(&cp.env, \"GIT_CONFIG_COUNT=1\");\n+\t\tstrvec_push(&cp.env, \"GIT_CONFIG_KEY_0=status.showStash\");\n+\t\tstrvec_push(&cp.env, \"GIT_CONFIG_VALUE_0=false\");\n \t\tstrvec_push(&cp.args, \"status\");\n \t\trun_command(&cp);\n \t}\n\nbase-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0\n-- \ngitgitgadget\n"},{"id":"527988","messageId":"CAOLa=ZQVZMNXjZzSDCc9SXxRuAhRbo7hc-F9RmhYap=ABWVxzw@mail.gmail.com","threadId":"64256","inReplyTo":"pull.2067.git.git.1759750539721.gitgitgadget@gmail.com","subject":"Re: [PATCH] stash: don't show irrelevant entry count in status","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-10-06T14:43:36Z","receivedAt":"2025-10-06T14:43:38Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"\"Miroma via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Miroma <its.miroma@proton.me>\n>\n> Currently, when status.showStash is set, 'stash pop' shows the\n> following, confusing, output:\n>\n>     ...\n>     Your stash currently has 1 entry\n>     Dropped refs/stash@{0} (abc123...)\n>\n\nRight, so your proposal is to not print stash related status information\nwhen already running a stash command. It would be nice to note that\nhere, along why you think so.\n\nPersonally, I think it is important to keep this as is, because it tells\nthe user the entries left in the stash post the stash operation.\n\n> Signed-off-by: Miroma <its.miroma@proton.me>\n> ---\n>     stash: don't show irrelevant entry count in status\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v1\n> Pull-Request: https://github.com/git/git/pull/2067\n>\n>  builtin/stash.c | 3 +++\n>  1 file changed, 3 insertions(+)\n>\n> diff --git a/builtin/stash.c b/builtin/stash.c\n> index 1977e50df2..2bd4b7d753 100644\n> --- a/builtin/stash.c\n> +++ b/builtin/stash.c\n> @@ -705,6 +705,9 @@ restore_untracked:\n>  \t\t\t     absolute_path(repo_get_work_tree(the_repository)));\n>  \t\tstrvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT\"=%s\",\n>  \t\t\t     absolute_path(repo_get_git_dir(the_repository)));\n> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_COUNT=1\");\n> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_KEY_0=status.showStash\");\n> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_VALUE_0=false\");\n>  \t\tstrvec_push(&cp.args, \"status\");\n>  \t\trun_command(&cp);\n>\n\nSo this block is run to print the status, unless the '--quiet' option is\nused. So it makes sense to do this here.\n\nSmall nit: Shouldn't we add a test to validate this change in behavior?\n"},{"id":"528003","messageId":"xmqqtt0cosiu.fsf@gitster.g","threadId":"64256","inReplyTo":"CAOLa=ZQVZMNXjZzSDCc9SXxRuAhRbo7hc-F9RmhYap=ABWVxzw@mail.gmail.com","subject":"Re: [PATCH] stash: don't show irrelevant entry count in status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-06T17:21:29Z","receivedAt":"2025-10-06T17:21:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> \"Miroma via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n>> From: Miroma <its.miroma@proton.me>\n>>\n>> Currently, when status.showStash is set, 'stash pop' shows the\n>> following, confusing, output:\n>>\n>>     ...\n>>     Your stash currently has 1 entry\n>>     Dropped refs/stash@{0} (abc123...)\n>>\n>\n> Right, so your proposal is to not print stash related status information\n> when already running a stash command. It would be nice to note that\n> here, along why you think so.\n>\n> Personally, I think it is important to keep this as is, because it tells\n> the user the entries left in the stash post the stash operation.\n\nWhen pop sees a conflict, it keeps the stash entry, and whe it does\nnot, it discards the stash entry it used just now.  So I agree with\nyou that the number of remaining entries may be something the user\nwould want to see, but in do_apply_stash(), I think we are getting\nthe number before popping, as dropping the entry seems to be the\nresponsibility of the caller of do_apply_stash(), if I am reading\npop_stash() correctly.  So, I suspect the current output may need\nadjustment if we want to keep the message and want it to be useful.\n\n>> @@ -705,6 +705,9 @@ restore_untracked:\n>>  \t\t\t     absolute_path(repo_get_work_tree(the_repository)));\n>>  \t\tstrvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT\"=%s\",\n>>  \t\t\t     absolute_path(repo_get_git_dir(the_repository)));\n>> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_COUNT=1\");\n>> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_KEY_0=status.showStash\");\n>> +\t\tstrvec_push(&cp.env, \"GIT_CONFIG_VALUE_0=false\");\n>>  \t\tstrvec_push(&cp.args, \"status\");\n>>  \t\trun_command(&cp);\n>>\n>\n> So this block is run to print the status, unless the '--quiet' option is\n> used. So it makes sense to do this here.\n\nDoes it?  What happens in existing GIT_CONFIG_{COUNT,KEY,VALUE}*\nenvironment variables passed by the script that invoked us?\n\nIf we are spawning \"git status\" here, can't we do a much simpler and\nmore obvious thing, i.e. \"git -c status.showstash=false status\"?\n\n> Small nit: Shouldn't we add a test to validate this change in behavior?\n\nYes.  I am not yet sure what the right output should be, though.\n"},{"id":"528013","messageId":"yrvfy1J5dHVBqevuewPCrDR2ukgdZpMmXCwmKlk0jWBdLwzHpUrgNSh7e03ZMeIxnnN4aAFmpfvac_iDoR8lCTPFF-vk85Esir1zTp0eElk=@proton.me","threadId":"64256","inReplyTo":"xmqqtt0cosiu.fsf@gitster.g","subject":"Re: [PATCH] stash: don't show irrelevant entry count in status","fromName":"Miroma","fromEmail":"its.miroma@proton.me","sentAt":"2025-10-06T18:24:27Z","receivedAt":"2025-10-06T18:24:40Z","isPatch":true,"sender":{"key":"its.miroma@proton.me","avatar":null},"body":"\"Karthik Nayak\" <karthik.188@gmail.com> writes:\n\n> \"Miroma via GitGitGadget\" gitgitgadget@gmail.com writes:\n> \n\n> > From: Miroma its.miroma@proton.me\n> > \n\n> > Currently, when status.showStash is set, 'stash pop' shows the\n> > following, confusing, output:\n> > \n\n> > ...\n> > Your stash currently has 1 entry\n> > Dropped refs/stash@{0} (abc123...)\n> \n\n> \n\n> Right, so your proposal is to not print stash related status information\n> when already running a stash command. It would be nice to note that\n> here, along why you think so.\n\nI'll update the commit message.  Briefly: I think the stash count shown by\n'status' when called by 'stash' internally is confusing, especially in the\ncited example of 'stash pop', because the count is immediately rendered\nobsolete as the pop drops it by one:\n\n```sh\n$ git stash pop\n...\nYour stash currently has 1 entry\nDropped refs/stash@{0} (abc123...)\n$\n$ git status --show-stash\n...\n<no stashes>\n```\n\n> Personally, I think it is important to keep this as is, because it tells\n> the user the entries left in the stash post the stash operation.\n\nThe issue is that the number shown is *not* post the stash operation, rather\nbefore; I called the output in the original message \"confusing\" because it\nclaimed 1 entry, then immediately dropped it.  The real count after the stash\ndrop is 0.\n\n\n\"Junio C Hamano\" gitster@pobox.com writes:\n\n> When pop sees a conflict, it keeps the stash entry, and whe it does\n> not, it discards the stash entry it used just now. So I agree with\n> you that the number of remaining entries may be something the user\n> would want to see, but in do_apply_stash(), I think we are getting\n> the number before popping, as dropping the entry seems to be the\n> responsibility of the caller of do_apply_stash(), if I am reading\n> pop_stash() correctly. So, I suspect the current output may need\n> adjustment if we want to keep the message and want it to be useful.\n\nYes, currently 'status' shows the stash count, then 'stash pop' calls it\nbefore the stash is dropped.\n\nA possible solution would be calling wt_longstatus_print_stash_summary()\nfrom 'wt-status.c' here, once 'stash' is ready to show the count.\n\n> > So this block is run to print the status, unless the '--quiet' option is\n> > used. So it makes sense to do this here.\n> \n\n> \n\n> Does it? What happens in existing GIT_CONFIG_{COUNT,KEY,VALUE}*\n> environment variables passed by the script that invoked us?\n\nGood point, I missed that...  But find a solution below\n\n> If we are spawning \"git status\" here, can't we do a much simpler and\n> more obvious thing, i.e. \"git -c status.showstash=false status\"?\n\nI found that 'status' knows of the '--no-show-stash' option; I'll use that.\n\n> > Small nit: Shouldn't we add a test to validate this change in behavior?\n> \n\n> \n\n> Yes. I am not yet sure what the right output should be, though.\n\nI suggest the last line of the output of 'stash' commands be the count:\n\n```sh\n# assuming there are two stashes\n$ git stash pop\n...\nDropped refs/stash@{0} (abc123...)\nYour stash currently has 1 entry\n```\n"},{"id":"528380","messageId":"pull.2067.v2.git.git.1760007783388.gitgitgadget@gmail.com","threadId":"64256","inReplyTo":"pull.2067.git.git.1759750539721.gitgitgadget@gmail.com","subject":"[PATCH v2] stash: show correct entries count","fromName":"Miroma via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-09T11:03:03Z","receivedAt":"2025-10-09T11:03:06Z","isPatch":true,"sender":{"key":"its.miroma@proton.me","avatar":null},"body":"From: Miroma <its.miroma@proton.me>\n\nCurrently, 'stash apply' internally calls 'status' to show a summary of\nwhat the command did. This also happens with 'stash pop', which roughly\ncorresponds to 'apply' + 'drop'.\n\nWhen the configuration 'status.showStash' is set, 'status' shows a count\nof stashed entries. This leads to the following, confusing, output:\n\n```sh\n$ # assuming there are two stashed entries\n$ git stash pop\n...\nYour stash currently has 2 entries\nDropped refs/stash@{0} (abc123...)\n$ # when actually...\n$ git status --show-stash\n...\nYour stash currently has 1 entry\n```\n\nThis patch changes the output format to the following, no matter the\nvalue of 'status.showStash':\n\n```sh\n$ # assuming there's a stashed entry\n$ git stash pop\n...\nDropped refs/stash@{0} (abc123...)\nYour stash now has 0 entries\n```\n\nThis new output is only shown if the stash count has changed, which can\nhappen with the following subcommands:\n'drop', 'pop', 'branch', 'store', 'push', 'save'.\n\nHelped-by: Karthik Nayak <karthik.188@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Miroma <its.miroma@proton.me>\n---\n    stash: show correct entries count\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v2\nPull-Request: https://github.com/git/git/pull/2067\n\nRange-diff vs v1:\n\n 1:  32a45cf3d2 < -:  ---------- stash: don't show irrelevant entry count in status\n -:  ---------- > 1:  1118bd68ac stash: show correct entries count\n\n\n builtin/stash.c  | 31 ++++++++++++++++++--\n t/t3903-stash.sh | 75 ++++++++++++++++++++++++++++--------------------\n wt-status.c      |  2 +-\n wt-status.h      |  1 +\n 4 files changed, 75 insertions(+), 34 deletions(-)\n\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 1977e50df2..1bee391fb2 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -32,6 +32,7 @@\n #include \"add-interactive.h\"\n #include \"oid-array.h\"\n #include \"commit.h\"\n+#include \"wt-status.h\"\n \n #define INCLUDE_ALL_FILES 2\n \n@@ -585,6 +586,20 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)\n \t\tdie(_(\"could not write index\"));\n }\n \n+static int previous_stash_count = -1;\n+\n+static void print_stash_status(bool quiet)\n+{\n+\tint stash_count;\n+\tstash_count = count_stash_entries();\n+\n+\tif (quiet || stash_count == previous_stash_count || previous_stash_count == -1)\n+\t\treturn;\n+\n+\tprintf_ln(Q_(\"Your stash now has %d entry\",\n+\t\t\"Your stash now has %d entries\", stash_count), stash_count);\n+}\n+\n static int do_apply_stash(const char *prefix, struct stash_info *info,\n \t\t\t  int index, int quiet)\n {\n@@ -705,7 +720,7 @@ restore_untracked:\n \t\t\t     absolute_path(repo_get_work_tree(the_repository)));\n \t\tstrvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT\"=%s\",\n \t\t\t     absolute_path(repo_get_git_dir(the_repository)));\n-\t\tstrvec_push(&cp.args, \"status\");\n+\t\tstrvec_pushl(&cp.args, \"status\", \"--no-show-stash\", NULL);\n \t\trun_command(&cp);\n \t}\n \n@@ -756,6 +771,8 @@ static int reflog_is_empty(const char *refname)\n \n static int do_drop_stash(struct stash_info *info, int quiet)\n {\n+\tprevious_stash_count = count_stash_entries();\n+\n \tif (!reflog_delete(info->revision.buf,\n \t\t\t   EXPIRE_REFLOGS_REWRITE | EXPIRE_REFLOGS_UPDATE_REF,\n \t\t\t   0)) {\n@@ -805,6 +822,8 @@ static int drop_stash(int argc, const char **argv, const char *prefix,\n \t\tgoto cleanup;\n \n \tret = do_drop_stash(&info, quiet);\n+\tprint_stash_status(quiet);\n+\n cleanup:\n \tfree_stash_info(&info);\n \treturn ret;\n@@ -836,6 +855,8 @@ static int pop_stash(int argc, const char **argv, const char *prefix,\n \telse\n \t\tret = do_drop_stash(&info, quiet);\n \n+\tprint_stash_status(quiet);\n+\n cleanup:\n \tfree_stash_info(&info);\n \treturn ret;\n@@ -875,6 +896,8 @@ static int branch_stash(int argc, const char **argv, const char *prefix,\n \tif (!ret && info.is_stash_ref)\n \t\tret = do_drop_stash(&info, 0);\n \n+\tprint_stash_status(0);\n+\n cleanup:\n \tfree_stash_info(&info);\n \treturn ret;\n@@ -1062,6 +1085,7 @@ static int do_store_stash(const struct object_id *w_commit, const char *stash_ms\n \tstruct stash_info info;\n \tchar revision[GIT_MAX_HEXSZ];\n \n+\tprevious_stash_count = count_stash_entries();\n \toid_to_hex_r(revision, w_commit);\n \tassert_stash_like(&info, revision);\n \n@@ -1119,6 +1143,7 @@ static int store_stash(int argc, const char **argv, const char *prefix,\n \t}\n \n \tret = do_store_stash(&obj, stash_msg, quiet);\n+\tprint_stash_status(quiet);\n \n out:\n \tobject_context_release(&dummy);\n@@ -1914,6 +1939,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,\n \n \tret = do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode,\n \t\t\t    &add_p_opt, include_untracked, only_staged);\n+\tprint_stash_status(quiet);\n \n \tclear_pathspec(&ps);\n \tfree(pathspec_from_file);\n@@ -1982,6 +2008,7 @@ static int save_stash(int argc, const char **argv, const char *prefix,\n \tret = do_push_stash(&ps, stash_msg, quiet, keep_index,\n \t\t\t    patch_mode, &add_p_opt, include_untracked,\n \t\t\t    only_staged);\n+\tprint_stash_status(quiet);\n \n \tstrbuf_release(&stash_msg_buf);\n \treturn ret;\n@@ -2291,7 +2318,7 @@ static int do_export_stash(struct repository *r,\n \t\t\t.r = r, .items = iter,\n \t\t};\n \t\tif (refs_for_each_reflog_ent_reverse(get_main_ref_store(r),\n-\t\t\t\t\t\t     \"refs/stash\",\n+\t\t\t\t\t\t     ref_stash,\n \t\t\t\t\t\t     collect_stash_entries,\n \t\t\t\t\t\t     &cb_data) && cb_data.count)\n \t\t\tgoto out;\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 0bb4648e36..d3af50e404 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -49,7 +49,7 @@ diff_cmp () {\n \trm -f \"$1.compare\" \"$2.compare\"\n }\n \n-setup_stash() {\n+setup_stash () {\n \techo 1 >file &&\n \tgit add file &&\n \techo unrelated >other-file &&\n@@ -60,13 +60,15 @@ setup_stash() {\n \tgit add file &&\n \techo 3 >file &&\n \ttest_tick &&\n-\tgit stash &&\n+\tgit stash | tail -n 1 >actual &&\n \tgit diff-files --quiet &&\n \tgit diff-index --cached --quiet HEAD\n }\n \n-test_expect_success 'stash some dirty working directory' '\n-\tsetup_stash\n+test_expect_success 'stash reports stash count' '\n+\tsetup_stash &&\n+\techo \"Your stash now has 1 entry\" >expect &&\n+\ttest_cmp expect actual\n '\n \n cat >expect <<EOF\n@@ -145,12 +147,14 @@ test_expect_success 'stash drop complains of extra options' '\n \n test_expect_success 'drop top stash' '\n \tgit reset --hard &&\n-\tgit stash list >expected &&\n+\tgit stash list >expect &&\n \techo 7 >file &&\n \tgit stash &&\n-\tgit stash drop &&\n+\tgit stash drop | tail -n 1 >msg-actual &&\n+\techo \"Your stash now has 1 entry\" >msg-expect &&\n+\ttest_cmp msg-expect msg-actual &&\n \tgit stash list >actual &&\n-\ttest_cmp expected actual &&\n+\ttest_cmp expect actual &&\n \tgit stash apply &&\n \ttest 3 = $(cat file) &&\n \ttest 1 = $(git show :file) &&\n@@ -236,14 +240,18 @@ test_expect_success 'drop stash reflog updates refs/stash with rewrite' '\n \n test_expect_success 'stash pop' '\n \tgit reset --hard &&\n-\tgit stash pop &&\n+\tgit stash pop | tail -n 1 >actual &&\n+\techo \"Your stash now has 0 entries\" >expect &&\n+\ttest_cmp expect actual &&\n \ttest 3 = $(cat file) &&\n \ttest 1 = $(git show :file) &&\n \ttest 1 = $(git show HEAD:file) &&\n \ttest 0 = $(git stash list | wc -l)\n '\n \n-cat >expect <<EOF\n+echo \"Your stash now has 0 entries\" >expect\n+\n+cat >expect1 <<EOF\n diff --git a/file2 b/file2\n new file mode 100644\n index 0000000..1fe912c\n@@ -253,7 +261,7 @@ index 0000000..1fe912c\n +bar2\n EOF\n \n-cat >expect1 <<EOF\n+cat >expect2 <<EOF\n diff --git a/file b/file\n index 257cc56..5716ca5 100644\n --- a/file\n@@ -263,7 +271,7 @@ index 257cc56..5716ca5 100644\n +bar\n EOF\n \n-cat >expect2 <<EOF\n+cat >expect3 <<EOF\n diff --git a/file b/file\n index 7601807..5716ca5 100644\n --- a/file\n@@ -289,17 +297,18 @@ test_expect_success 'stash branch' '\n \tgit stash &&\n \techo baz >file &&\n \tgit commit file -m second &&\n-\tgit stash branch stashbranch &&\n+\tgit stash branch stashbranch | tail -n 1 >actual &&\n+\ttest_cmp expect actual &&\n \ttest refs/heads/stashbranch = $(git symbolic-ref HEAD) &&\n \ttest $(git rev-parse HEAD) = $(git rev-parse main^) &&\n \tgit diff --cached >output &&\n-\tdiff_cmp expect output &&\n-\tgit diff >output &&\n \tdiff_cmp expect1 output &&\n+\tgit diff >output &&\n+\tdiff_cmp expect2 output &&\n \tgit add file &&\n \tgit commit -m alternate\\ second &&\n \tgit diff main..stashbranch >output &&\n-\tdiff_cmp output expect2 &&\n+\tdiff_cmp output expect3 &&\n \ttest 0 = $(git stash list | wc -l)\n '\n \n@@ -427,7 +436,9 @@ test_expect_success 'stash an added file' '\n \tgit reset --hard &&\n \techo new >file3 &&\n \tgit add file3 &&\n-\tgit stash save \"added file\" &&\n+\tgit stash save \"added file\" | tail -n 1 >actual &&\n+\techo \"Your stash now has 6 entries\" >expect &&\n+\ttest_cmp expect actual &&\n \t! test -r file3 &&\n \tgit stash apply &&\n \ttest new = \"$(cat file3)\"\n@@ -683,12 +694,12 @@ test_expect_success 'stash show format defaults to --stat' '\n \techo bar >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tcat >expected <<-EOF &&\n+\tcat >expect <<-EOF &&\n \t file | 1 +\n \t 1 file changed, 1 insertion(+)\n \tEOF\n \tgit stash show ${STASH_ID} >actual &&\n-\ttest_cmp expected actual\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'stash show - stashes on stack, stash-like argument' '\n@@ -701,9 +712,9 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '\n \techo bar >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\techo \"1\t0\tfile\" >expected &&\n+\techo \"1\t0\tfile\" >expect &&\n \tgit stash show --numstat ${STASH_ID} >actual &&\n-\ttest_cmp expected actual\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n@@ -716,7 +727,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n \techo bar >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tcat >expected <<-EOF &&\n+\tcat >expect <<-EOF &&\n \tdiff --git a/file b/file\n \tindex 7601807..935fbd3 100644\n \t--- a/file\n@@ -726,7 +737,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n \t+bar\n \tEOF\n \tgit stash show -p ${STASH_ID} >actual &&\n-\tdiff_cmp expected actual\n+\tdiff_cmp expect actual\n '\n \n test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n@@ -736,9 +747,9 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n \techo foo >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\techo \"1\t0\tfile\" >expected &&\n+\techo \"1\t0\tfile\" >expect &&\n \tgit stash show --numstat ${STASH_ID} >actual &&\n-\ttest_cmp expected actual\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n@@ -748,7 +759,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n \techo foo >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tcat >expected <<-EOF &&\n+\tcat >expect <<-EOF &&\n \tdiff --git a/file b/file\n \tindex 7601807..71b52c4 100644\n \t--- a/file\n@@ -758,7 +769,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n \t+foo\n \tEOF\n \tgit stash show -p ${STASH_ID} >actual &&\n-\tdiff_cmp expected actual\n+\tdiff_cmp expect actual\n '\n \n test_expect_success 'stash show --patience shows diff' '\n@@ -766,7 +777,7 @@ test_expect_success 'stash show --patience shows diff' '\n \techo foo >>file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tcat >expected <<-EOF &&\n+\tcat >expect <<-EOF &&\n \tdiff --git a/file b/file\n \tindex 7601807..71b52c4 100644\n \t--- a/file\n@@ -776,7 +787,7 @@ test_expect_success 'stash show --patience shows diff' '\n \t+foo\n \tEOF\n \tgit stash show --patience ${STASH_ID} >actual &&\n-\tdiff_cmp expected actual\n+\tdiff_cmp expect actual\n '\n \n test_expect_success 'drop: fail early if specified stash is not a stash ref' '\n@@ -915,7 +926,7 @@ test_expect_success 'apply: show same status as git status (relative to ./)' '\n \t\tsane_unset GIT_MERGE_VERBOSITY &&\n \t\tgit stash apply\n \t) |\n-\tsed -e 1d >actual && # drop \"Saved...\"\n+\tsed -e 1,2d >actual && # drop \"Your stash now has 1 entry\" and \"Saved...\"\n \ttest_cmp expect actual\n '\n \n@@ -959,9 +970,11 @@ test_expect_success 'store updates stash ref and reflog' '\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n \ttest_path_is_missing bazzy &&\n-\tgit stash store -m quuxery $STASH_ID &&\n+\tgit stash store -m quuxery $STASH_ID | tail -n 1 >actual &&\n+\techo \"Your stash now has 1 entry\" >expect &&\n+\ttest_cmp expect actual &&\n \ttest $(git rev-parse stash) = $STASH_ID &&\n-\tgit reflog --format=%H stash| grep $STASH_ID &&\n+\tgit reflog --format=%H stash | grep $STASH_ID &&\n \tgit stash pop &&\n \tgrep quux bazzy\n '\ndiff --git a/wt-status.c b/wt-status.c\nindex 454601afa1..6bdf71efee 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -983,7 +983,7 @@ static int stash_count_refs(struct object_id *ooid UNUSED,\n \treturn 0;\n }\n \n-static int count_stash_entries(void)\n+int count_stash_entries(void)\n {\n \tint n = 0;\n \trefs_for_each_reflog_ent(get_main_ref_store(the_repository),\ndiff --git a/wt-status.h b/wt-status.h\nindex 4e377ce62b..daccde0b6e 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -151,6 +151,7 @@ size_t wt_status_locate_end(const char *s, size_t len);\n void wt_status_append_cut_line(struct strbuf *buf);\n void wt_status_add_cut_line(struct wt_status *s);\n void wt_status_prepare(struct repository *r, struct wt_status *s);\n+int count_stash_entries(void);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n /*\n\nbase-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0\n-- \ngitgitgadget\n"},{"id":"528585","messageId":"-H8VS7fJi6Nie2ovTiryLWwggMWohoJybAfjf7QjUTBZPojsBZtOnl93jq5cOX8cDRiiNLkHLQQQOGehXLqcOG9fC_V7UUVHfHmY1doks84=@proton.me","threadId":"64256","inReplyTo":"pull.2067.v2.git.git.1760007783388.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] stash: show correct entries count","fromName":"Miroma","fromEmail":"its.miroma@proton.me","sentAt":"2025-10-12T16:45:34Z","receivedAt":"2025-10-12T16:45:47Z","isPatch":true,"sender":{"key":"its.miroma@proton.me","avatar":null},"body":"I have a few questions I'd appreciate an input on:\n\n- Should 'stash clear' also print \"Your stash now has 0 entries\"?\n- Why does 'do_push_stack' pass quiet=0 to 'do_store_stash' (line 1695)?\n- Why do the following subcommands not support '--quiet'?\n    'branch', 'import', 'export', 'create', 'clear'\n- Is exporting 'count_stash_entries' in \"wt-status\" a good idea?\n"}]}