-
Notifications
You must be signed in to change notification settings - Fork 26.8k
stash: show correct entries count #2067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: maint
Are you sure you want to change the base?
Conversation
Welcome to GitGitGadgetHi @its-miroma, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that either:
You can CC potential reviewers by adding a footer to the PR description with the following syntax:
NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description, Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):
To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
/allow |
User its-miroma is now allowed to use GitGitGadget. WARNING: its-miroma has no public email address set on GitHub; GitGitGadget needs an email address to Cc: you on your contribution, so that you receive any feedback on the Git mailing list. Go to https://github.com/settings/profile to make your preferred email public to let GitGitGadget know which email address to use. |
This comment was marked as resolved.
This comment was marked as resolved.
Preview email sent as pull.2067.git.git.1759749683549.gitgitgadget@gmail.com |
a3428a5
to
32a45cf
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Preview email sent as pull.2067.git.git.1759750135340.gitgitgadget@gmail.com |
/submit |
Submitted as pull.2067.git.git.1759750539721.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Karthik Nayak wrote (reply to this): "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? |
User |
On the Git mailing list, Junio C Hamano wrote (reply to this): 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. |
On the Git mailing list, Miroma wrote (reply to this): "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
``` |
5a695df
to
4e149bb
Compare
4e149bb
to
6f05470
Compare
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>
6f05470
to
1118bd6
Compare
/preview |
Preview email sent as pull.2067.v2.git.git.1760005760216.gitgitgadget@gmail.com |
/submit |
Submitted as pull.2067.v2.git.git.1760007783388.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
cc: Karthik Nayak karthik.188@gmail.com