* [PATCH] stash: don't show irrelevant entry count in status
@ 2025-10-06 11:35 Miroma via GitGitGadget
2025-10-06 14:43 ` Karthik Nayak
2025-10-09 11:03 ` [PATCH v2] stash: show correct entries count Miroma via GitGitGadget
0 siblings, 2 replies; 6+ messages in thread
From: Miroma via GitGitGadget @ 2025-10-06 11:35 UTC (permalink / raw)
To: git; +Cc: Miroma, Miroma
From: Miroma <its.miroma@proton.me>
Currently, when status.showStash is set, 'stash pop' shows the
following, confusing, output:
...
Your stash currently has 1 entry
Dropped refs/stash@{0} (abc123...)
Signed-off-by: Miroma <its.miroma@proton.me>
---
stash: don't show irrelevant entry count in status
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v1
Pull-Request: https://github.com/git/git/pull/2067
builtin/stash.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/builtin/stash.c b/builtin/stash.c
index 1977e50df2..2bd4b7d753 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -705,6 +705,9 @@ restore_untracked:
absolute_path(repo_get_work_tree(the_repository)));
strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
absolute_path(repo_get_git_dir(the_repository)));
+ strvec_push(&cp.env, "GIT_CONFIG_COUNT=1");
+ strvec_push(&cp.env, "GIT_CONFIG_KEY_0=status.showStash");
+ strvec_push(&cp.env, "GIT_CONFIG_VALUE_0=false");
strvec_push(&cp.args, "status");
run_command(&cp);
}
base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0
--
gitgitgadget
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] stash: don't show irrelevant entry count in status
2025-10-06 11:35 [PATCH] stash: don't show irrelevant entry count in status Miroma via GitGitGadget
@ 2025-10-06 14:43 ` Karthik Nayak
2025-10-06 17:21 ` Junio C Hamano
2025-10-09 11:03 ` [PATCH v2] stash: show correct entries count Miroma via GitGitGadget
1 sibling, 1 reply; 6+ messages in thread
From: Karthik Nayak @ 2025-10-06 14:43 UTC (permalink / raw)
To: Miroma via GitGitGadget, git; +Cc: Miroma
[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]
"Miroma via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Miroma <its.miroma@proton.me>
>
> Currently, when status.showStash is set, 'stash pop' shows the
> following, confusing, output:
>
> ...
> Your stash currently has 1 entry
> Dropped refs/stash@{0} (abc123...)
>
Right, so your proposal is to not print stash related status information
when already running a stash command. It would be nice to note that
here, along why you think so.
Personally, I think it is important to keep this as is, because it tells
the user the entries left in the stash post the stash operation.
> Signed-off-by: Miroma <its.miroma@proton.me>
> ---
> stash: don't show irrelevant entry count in status
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v1
> Pull-Request: https://github.com/git/git/pull/2067
>
> builtin/stash.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/builtin/stash.c b/builtin/stash.c
> index 1977e50df2..2bd4b7d753 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -705,6 +705,9 @@ restore_untracked:
> absolute_path(repo_get_work_tree(the_repository)));
> strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
> absolute_path(repo_get_git_dir(the_repository)));
> + strvec_push(&cp.env, "GIT_CONFIG_COUNT=1");
> + strvec_push(&cp.env, "GIT_CONFIG_KEY_0=status.showStash");
> + strvec_push(&cp.env, "GIT_CONFIG_VALUE_0=false");
> strvec_push(&cp.args, "status");
> run_command(&cp);
>
So this block is run to print the status, unless the '--quiet' option is
used. So it makes sense to do this here.
Small nit: Shouldn't we add a test to validate this change in behavior?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] stash: don't show irrelevant entry count in status
2025-10-06 14:43 ` Karthik Nayak
@ 2025-10-06 17:21 ` Junio C Hamano
2025-10-06 18:24 ` Miroma
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2025-10-06 17:21 UTC (permalink / raw)
To: Karthik Nayak; +Cc: Miroma via GitGitGadget, git, Miroma
Karthik Nayak <karthik.188@gmail.com> writes:
> "Miroma via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> From: Miroma <its.miroma@proton.me>
>>
>> Currently, when status.showStash is set, 'stash pop' shows the
>> following, confusing, output:
>>
>> ...
>> Your stash currently has 1 entry
>> Dropped refs/stash@{0} (abc123...)
>>
>
> Right, so your proposal is to not print stash related status information
> when already running a stash command. It would be nice to note that
> here, along why you think so.
>
> Personally, I think it is important to keep this as is, because it tells
> the user the entries left in the stash post the stash operation.
When pop sees a conflict, it keeps the stash entry, and whe it does
not, it discards the stash entry it used just now. So I agree with
you that the number of remaining entries may be something the user
would want to see, but in do_apply_stash(), I think we are getting
the number before popping, as dropping the entry seems to be the
responsibility of the caller of do_apply_stash(), if I am reading
pop_stash() correctly. So, I suspect the current output may need
adjustment if we want to keep the message and want it to be useful.
>> @@ -705,6 +705,9 @@ restore_untracked:
>> absolute_path(repo_get_work_tree(the_repository)));
>> strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
>> absolute_path(repo_get_git_dir(the_repository)));
>> + strvec_push(&cp.env, "GIT_CONFIG_COUNT=1");
>> + strvec_push(&cp.env, "GIT_CONFIG_KEY_0=status.showStash");
>> + strvec_push(&cp.env, "GIT_CONFIG_VALUE_0=false");
>> strvec_push(&cp.args, "status");
>> run_command(&cp);
>>
>
> So this block is run to print the status, unless the '--quiet' option is
> used. So it makes sense to do this here.
Does it? What happens in existing GIT_CONFIG_{COUNT,KEY,VALUE}*
environment variables passed by the script that invoked us?
If we are spawning "git status" here, can't we do a much simpler and
more obvious thing, i.e. "git -c status.showstash=false status"?
> Small nit: Shouldn't we add a test to validate this change in behavior?
Yes. I am not yet sure what the right output should be, though.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] stash: don't show irrelevant entry count in status
2025-10-06 17:21 ` Junio C Hamano
@ 2025-10-06 18:24 ` Miroma
0 siblings, 0 replies; 6+ messages in thread
From: Miroma @ 2025-10-06 18:24 UTC (permalink / raw)
To: Karthik Nayak, Junio C Hamano; +Cc: Miroma via GitGitGadget, git
[-- Attachment #1.1: Type: text/plain, Size: 3144 bytes --]
"Karthik Nayak" <karthik.188@gmail.com> writes:
> "Miroma via GitGitGadget" gitgitgadget@gmail.com writes:
>
> > From: Miroma its.miroma@proton.me
> >
> > Currently, when status.showStash is set, 'stash pop' shows the
> > following, confusing, output:
> >
> > ...
> > Your stash currently has 1 entry
> > Dropped refs/stash@{0} (abc123...)
>
>
> Right, so your proposal is to not print stash related status information
> when already running a stash command. It would be nice to note that
> here, along why you think so.
I'll update the commit message. Briefly: I think the stash count shown by
'status' when called by 'stash' internally is confusing, especially in the
cited example of 'stash pop', because the count is immediately rendered
obsolete as the pop drops it by one:
```sh
$ git stash pop
...
Your stash currently has 1 entry
Dropped refs/stash@{0} (abc123...)
$
$ git status --show-stash
...
<no stashes>
```
> Personally, I think it is important to keep this as is, because it tells
> the user the entries left in the stash post the stash operation.
The issue is that the number shown is *not* post the stash operation, rather
before; I called the output in the original message "confusing" because it
claimed 1 entry, then immediately dropped it. The real count after the stash
drop is 0.
"Junio C Hamano" gitster@pobox.com writes:
> When pop sees a conflict, it keeps the stash entry, and whe it does
> not, it discards the stash entry it used just now. So I agree with
> you that the number of remaining entries may be something the user
> would want to see, but in do_apply_stash(), I think we are getting
> the number before popping, as dropping the entry seems to be the
> responsibility of the caller of do_apply_stash(), if I am reading
> pop_stash() correctly. So, I suspect the current output may need
> adjustment if we want to keep the message and want it to be useful.
Yes, currently 'status' shows the stash count, then 'stash pop' calls it
before the stash is dropped.
A possible solution would be calling wt_longstatus_print_stash_summary()
from 'wt-status.c' here, once 'stash' is ready to show the count.
> > So this block is run to print the status, unless the '--quiet' option is
> > used. So it makes sense to do this here.
>
>
> Does it? What happens in existing GIT_CONFIG_{COUNT,KEY,VALUE}*
> environment variables passed by the script that invoked us?
Good point, I missed that... But find a solution below
> If we are spawning "git status" here, can't we do a much simpler and
> more obvious thing, i.e. "git -c status.showstash=false status"?
I found that 'status' knows of the '--no-show-stash' option; I'll use that.
> > Small nit: Shouldn't we add a test to validate this change in behavior?
>
>
> Yes. I am not yet sure what the right output should be, though.
I suggest the last line of the output of 'stash' commands be the count:
```sh
# assuming there are two stashes
$ git stash pop
...
Dropped refs/stash@{0} (abc123...)
Your stash currently has 1 entry
```
[-- Attachment #1.2: publickey - its.miroma@proton.me - 0x433A3299.asc --]
[-- Type: application/pgp-keys, Size: 649 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 343 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] stash: show correct entries count
2025-10-06 11:35 [PATCH] stash: don't show irrelevant entry count in status Miroma via GitGitGadget
2025-10-06 14:43 ` Karthik Nayak
@ 2025-10-09 11:03 ` Miroma via GitGitGadget
2025-10-12 16:45 ` Miroma
1 sibling, 1 reply; 6+ messages in thread
From: Miroma via GitGitGadget @ 2025-10-09 11:03 UTC (permalink / raw)
To: git; +Cc: Karthik Nayak, Miroma, Miroma
From: Miroma <its.miroma@proton.me>
Currently, 'stash apply' internally calls 'status' to show a summary of
what the command did. This also happens with 'stash pop', which roughly
corresponds to 'apply' + 'drop'.
When the configuration 'status.showStash' is set, 'status' shows a count
of stashed entries. This leads to the following, confusing, output:
```sh
$ # assuming there are two stashed entries
$ git stash pop
...
Your stash currently has 2 entries
Dropped refs/stash@{0} (abc123...)
$ # when actually...
$ git status --show-stash
...
Your stash currently has 1 entry
```
This patch changes the output format to the following, no matter the
value of 'status.showStash':
```sh
$ # assuming there's a stashed entry
$ git stash pop
...
Dropped refs/stash@{0} (abc123...)
Your stash now has 0 entries
```
This new output is only shown if the stash count has changed, which can
happen with the following subcommands:
'drop', 'pop', 'branch', 'store', 'push', 'save'.
Helped-by: Karthik Nayak <karthik.188@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Miroma <its.miroma@proton.me>
---
stash: show correct entries count
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2067%2Fits-miroma%2Fstash-no-status-showStash-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2067/its-miroma/stash-no-status-showStash-v2
Pull-Request: https://github.com/git/git/pull/2067
Range-diff vs v1:
1: 32a45cf3d2 < -: ---------- stash: don't show irrelevant entry count in status
-: ---------- > 1: 1118bd68ac stash: show correct entries count
builtin/stash.c | 31 ++++++++++++++++++--
t/t3903-stash.sh | 75 ++++++++++++++++++++++++++++--------------------
wt-status.c | 2 +-
wt-status.h | 1 +
4 files changed, 75 insertions(+), 34 deletions(-)
diff --git a/builtin/stash.c b/builtin/stash.c
index 1977e50df2..1bee391fb2 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -32,6 +32,7 @@
#include "add-interactive.h"
#include "oid-array.h"
#include "commit.h"
+#include "wt-status.h"
#define INCLUDE_ALL_FILES 2
@@ -585,6 +586,20 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
die(_("could not write index"));
}
+static int previous_stash_count = -1;
+
+static void print_stash_status(bool quiet)
+{
+ int stash_count;
+ stash_count = count_stash_entries();
+
+ if (quiet || stash_count == previous_stash_count || previous_stash_count == -1)
+ return;
+
+ printf_ln(Q_("Your stash now has %d entry",
+ "Your stash now has %d entries", stash_count), stash_count);
+}
+
static int do_apply_stash(const char *prefix, struct stash_info *info,
int index, int quiet)
{
@@ -705,7 +720,7 @@ restore_untracked:
absolute_path(repo_get_work_tree(the_repository)));
strvec_pushf(&cp.env, GIT_DIR_ENVIRONMENT"=%s",
absolute_path(repo_get_git_dir(the_repository)));
- strvec_push(&cp.args, "status");
+ strvec_pushl(&cp.args, "status", "--no-show-stash", NULL);
run_command(&cp);
}
@@ -756,6 +771,8 @@ static int reflog_is_empty(const char *refname)
static int do_drop_stash(struct stash_info *info, int quiet)
{
+ previous_stash_count = count_stash_entries();
+
if (!reflog_delete(info->revision.buf,
EXPIRE_REFLOGS_REWRITE | EXPIRE_REFLOGS_UPDATE_REF,
0)) {
@@ -805,6 +822,8 @@ static int drop_stash(int argc, const char **argv, const char *prefix,
goto cleanup;
ret = do_drop_stash(&info, quiet);
+ print_stash_status(quiet);
+
cleanup:
free_stash_info(&info);
return ret;
@@ -836,6 +855,8 @@ static int pop_stash(int argc, const char **argv, const char *prefix,
else
ret = do_drop_stash(&info, quiet);
+ print_stash_status(quiet);
+
cleanup:
free_stash_info(&info);
return ret;
@@ -875,6 +896,8 @@ static int branch_stash(int argc, const char **argv, const char *prefix,
if (!ret && info.is_stash_ref)
ret = do_drop_stash(&info, 0);
+ print_stash_status(0);
+
cleanup:
free_stash_info(&info);
return ret;
@@ -1062,6 +1085,7 @@ static int do_store_stash(const struct object_id *w_commit, const char *stash_ms
struct stash_info info;
char revision[GIT_MAX_HEXSZ];
+ previous_stash_count = count_stash_entries();
oid_to_hex_r(revision, w_commit);
assert_stash_like(&info, revision);
@@ -1119,6 +1143,7 @@ static int store_stash(int argc, const char **argv, const char *prefix,
}
ret = do_store_stash(&obj, stash_msg, quiet);
+ print_stash_status(quiet);
out:
object_context_release(&dummy);
@@ -1914,6 +1939,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,
ret = do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode,
&add_p_opt, include_untracked, only_staged);
+ print_stash_status(quiet);
clear_pathspec(&ps);
free(pathspec_from_file);
@@ -1982,6 +2008,7 @@ static int save_stash(int argc, const char **argv, const char *prefix,
ret = do_push_stash(&ps, stash_msg, quiet, keep_index,
patch_mode, &add_p_opt, include_untracked,
only_staged);
+ print_stash_status(quiet);
strbuf_release(&stash_msg_buf);
return ret;
@@ -2291,7 +2318,7 @@ static int do_export_stash(struct repository *r,
.r = r, .items = iter,
};
if (refs_for_each_reflog_ent_reverse(get_main_ref_store(r),
- "refs/stash",
+ ref_stash,
collect_stash_entries,
&cb_data) && cb_data.count)
goto out;
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 0bb4648e36..d3af50e404 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -49,7 +49,7 @@ diff_cmp () {
rm -f "$1.compare" "$2.compare"
}
-setup_stash() {
+setup_stash () {
echo 1 >file &&
git add file &&
echo unrelated >other-file &&
@@ -60,13 +60,15 @@ setup_stash() {
git add file &&
echo 3 >file &&
test_tick &&
- git stash &&
+ git stash | tail -n 1 >actual &&
git diff-files --quiet &&
git diff-index --cached --quiet HEAD
}
-test_expect_success 'stash some dirty working directory' '
- setup_stash
+test_expect_success 'stash reports stash count' '
+ setup_stash &&
+ echo "Your stash now has 1 entry" >expect &&
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -145,12 +147,14 @@ test_expect_success 'stash drop complains of extra options' '
test_expect_success 'drop top stash' '
git reset --hard &&
- git stash list >expected &&
+ git stash list >expect &&
echo 7 >file &&
git stash &&
- git stash drop &&
+ git stash drop | tail -n 1 >msg-actual &&
+ echo "Your stash now has 1 entry" >msg-expect &&
+ test_cmp msg-expect msg-actual &&
git stash list >actual &&
- test_cmp expected actual &&
+ test_cmp expect actual &&
git stash apply &&
test 3 = $(cat file) &&
test 1 = $(git show :file) &&
@@ -236,14 +240,18 @@ test_expect_success 'drop stash reflog updates refs/stash with rewrite' '
test_expect_success 'stash pop' '
git reset --hard &&
- git stash pop &&
+ git stash pop | tail -n 1 >actual &&
+ echo "Your stash now has 0 entries" >expect &&
+ test_cmp expect actual &&
test 3 = $(cat file) &&
test 1 = $(git show :file) &&
test 1 = $(git show HEAD:file) &&
test 0 = $(git stash list | wc -l)
'
-cat >expect <<EOF
+echo "Your stash now has 0 entries" >expect
+
+cat >expect1 <<EOF
diff --git a/file2 b/file2
new file mode 100644
index 0000000..1fe912c
@@ -253,7 +261,7 @@ index 0000000..1fe912c
+bar2
EOF
-cat >expect1 <<EOF
+cat >expect2 <<EOF
diff --git a/file b/file
index 257cc56..5716ca5 100644
--- a/file
@@ -263,7 +271,7 @@ index 257cc56..5716ca5 100644
+bar
EOF
-cat >expect2 <<EOF
+cat >expect3 <<EOF
diff --git a/file b/file
index 7601807..5716ca5 100644
--- a/file
@@ -289,17 +297,18 @@ test_expect_success 'stash branch' '
git stash &&
echo baz >file &&
git commit file -m second &&
- git stash branch stashbranch &&
+ git stash branch stashbranch | tail -n 1 >actual &&
+ test_cmp expect actual &&
test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
test $(git rev-parse HEAD) = $(git rev-parse main^) &&
git diff --cached >output &&
- diff_cmp expect output &&
- git diff >output &&
diff_cmp expect1 output &&
+ git diff >output &&
+ diff_cmp expect2 output &&
git add file &&
git commit -m alternate\ second &&
git diff main..stashbranch >output &&
- diff_cmp output expect2 &&
+ diff_cmp output expect3 &&
test 0 = $(git stash list | wc -l)
'
@@ -427,7 +436,9 @@ test_expect_success 'stash an added file' '
git reset --hard &&
echo new >file3 &&
git add file3 &&
- git stash save "added file" &&
+ git stash save "added file" | tail -n 1 >actual &&
+ echo "Your stash now has 6 entries" >expect &&
+ test_cmp expect actual &&
! test -r file3 &&
git stash apply &&
test new = "$(cat file3)"
@@ -683,12 +694,12 @@ test_expect_success 'stash show format defaults to --stat' '
echo bar >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- cat >expected <<-EOF &&
+ cat >expect <<-EOF &&
file | 1 +
1 file changed, 1 insertion(+)
EOF
git stash show ${STASH_ID} >actual &&
- test_cmp expected actual
+ test_cmp expect actual
'
test_expect_success 'stash show - stashes on stack, stash-like argument' '
@@ -701,9 +712,9 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
echo bar >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- echo "1 0 file" >expected &&
+ echo "1 0 file" >expect &&
git stash show --numstat ${STASH_ID} >actual &&
- test_cmp expected actual
+ test_cmp expect actual
'
test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
@@ -716,7 +727,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
echo bar >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- cat >expected <<-EOF &&
+ cat >expect <<-EOF &&
diff --git a/file b/file
index 7601807..935fbd3 100644
--- a/file
@@ -726,7 +737,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
+bar
EOF
git stash show -p ${STASH_ID} >actual &&
- diff_cmp expected actual
+ diff_cmp expect actual
'
test_expect_success 'stash show - no stashes on stack, stash-like argument' '
@@ -736,9 +747,9 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
echo foo >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- echo "1 0 file" >expected &&
+ echo "1 0 file" >expect &&
git stash show --numstat ${STASH_ID} >actual &&
- test_cmp expected actual
+ test_cmp expect actual
'
test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
@@ -748,7 +759,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
echo foo >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- cat >expected <<-EOF &&
+ cat >expect <<-EOF &&
diff --git a/file b/file
index 7601807..71b52c4 100644
--- a/file
@@ -758,7 +769,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
+foo
EOF
git stash show -p ${STASH_ID} >actual &&
- diff_cmp expected actual
+ diff_cmp expect actual
'
test_expect_success 'stash show --patience shows diff' '
@@ -766,7 +777,7 @@ test_expect_success 'stash show --patience shows diff' '
echo foo >>file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- cat >expected <<-EOF &&
+ cat >expect <<-EOF &&
diff --git a/file b/file
index 7601807..71b52c4 100644
--- a/file
@@ -776,7 +787,7 @@ test_expect_success 'stash show --patience shows diff' '
+foo
EOF
git stash show --patience ${STASH_ID} >actual &&
- diff_cmp expected actual
+ diff_cmp expect actual
'
test_expect_success 'drop: fail early if specified stash is not a stash ref' '
@@ -915,7 +926,7 @@ test_expect_success 'apply: show same status as git status (relative to ./)' '
sane_unset GIT_MERGE_VERBOSITY &&
git stash apply
) |
- sed -e 1d >actual && # drop "Saved..."
+ sed -e 1,2d >actual && # drop "Your stash now has 1 entry" and "Saved..."
test_cmp expect actual
'
@@ -959,9 +970,11 @@ test_expect_success 'store updates stash ref and reflog' '
STASH_ID=$(git stash create) &&
git reset --hard &&
test_path_is_missing bazzy &&
- git stash store -m quuxery $STASH_ID &&
+ git stash store -m quuxery $STASH_ID | tail -n 1 >actual &&
+ echo "Your stash now has 1 entry" >expect &&
+ test_cmp expect actual &&
test $(git rev-parse stash) = $STASH_ID &&
- git reflog --format=%H stash| grep $STASH_ID &&
+ git reflog --format=%H stash | grep $STASH_ID &&
git stash pop &&
grep quux bazzy
'
diff --git a/wt-status.c b/wt-status.c
index 454601afa1..6bdf71efee 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -983,7 +983,7 @@ static int stash_count_refs(struct object_id *ooid UNUSED,
return 0;
}
-static int count_stash_entries(void)
+int count_stash_entries(void)
{
int n = 0;
refs_for_each_reflog_ent(get_main_ref_store(the_repository),
diff --git a/wt-status.h b/wt-status.h
index 4e377ce62b..daccde0b6e 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -151,6 +151,7 @@ size_t wt_status_locate_end(const char *s, size_t len);
void wt_status_append_cut_line(struct strbuf *buf);
void wt_status_add_cut_line(struct wt_status *s);
void wt_status_prepare(struct repository *r, struct wt_status *s);
+int count_stash_entries(void);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
/*
base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0
--
gitgitgadget
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] stash: show correct entries count
2025-10-09 11:03 ` [PATCH v2] stash: show correct entries count Miroma via GitGitGadget
@ 2025-10-12 16:45 ` Miroma
0 siblings, 0 replies; 6+ messages in thread
From: Miroma @ 2025-10-12 16:45 UTC (permalink / raw)
To: Miroma via GitGitGadget; +Cc: git, Karthik Nayak
[-- Attachment #1.1: Type: text/plain, Size: 373 bytes --]
I have a few questions I'd appreciate an input on:
- Should 'stash clear' also print "Your stash now has 0 entries"?
- Why does 'do_push_stack' pass quiet=0 to 'do_store_stash' (line 1695)?
- Why do the following subcommands not support '--quiet'?
'branch', 'import', 'export', 'create', 'clear'
- Is exporting 'count_stash_entries' in "wt-status" a good idea?
[-- Attachment #1.2: publickey - its.miroma@proton.me - 0x433A3299.asc --]
[-- Type: application/pgp-keys, Size: 649 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 343 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-12 16:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06 11:35 [PATCH] stash: don't show irrelevant entry count in status Miroma via GitGitGadget
2025-10-06 14:43 ` Karthik Nayak
2025-10-06 17:21 ` Junio C Hamano
2025-10-06 18:24 ` Miroma
2025-10-09 11:03 ` [PATCH v2] stash: show correct entries count Miroma via GitGitGadget
2025-10-12 16:45 ` Miroma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).