* Bug: "git stash create" ignores "message" argument
@ 2025-07-06 1:28 José Miguel Armijo Fidalgo
2025-07-06 3:25 ` Jeff King
2025-07-06 3:36 ` Darren Rambaud
0 siblings, 2 replies; 8+ messages in thread
From: José Miguel Armijo Fidalgo @ 2025-07-06 1:28 UTC (permalink / raw)
To: git
What did you do before the bug happened? (Steps to reproduce your issue)
$ git stash create "example message"
1e9b483d1f9477de5c99a708f4aa512ba
$ git stash store 1e9b483d1f9477de5c99a708f4aa512ba
$ git stash list
What did you expect to happen? (Expected behavior)
stash@{0}: example message
What happened instead? (Actual behavior)
stash@{0}: Created via "git stash store".
What's different between what you expected and what actually happened?
The documentation does not explain what the message "argument" is used for.
I would have expected that the message would be used by the store command.
Anything else you want to add:
If the message argument is not used at all, I would expect to
remove the argument, or
alternatively, that the documentation explains why the argument
exists and what it does/doesn't do.
Please review the rest of the bug report below.
You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.50.0
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
libcurl: 8.7.1
zlib: 1.2.12
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
uname: Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:33
PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8122 arm64
compiler info: clang: 17.0.0 (clang-1700.0.13.3)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Bug: "git stash create" ignores "message" argument 2025-07-06 1:28 Bug: "git stash create" ignores "message" argument José Miguel Armijo Fidalgo @ 2025-07-06 3:25 ` Jeff King 2025-07-08 17:13 ` Junio C Hamano 2025-07-06 3:36 ` Darren Rambaud 1 sibling, 1 reply; 8+ messages in thread From: Jeff King @ 2025-07-06 3:25 UTC (permalink / raw) To: José Miguel Armijo Fidalgo; +Cc: git On Sun, Jul 06, 2025 at 11:28:46AM +1000, José Miguel Armijo Fidalgo wrote: > What did you do before the bug happened? (Steps to reproduce your issue) > $ git stash create "example message" > 1e9b483d1f9477de5c99a708f4aa512ba > $ git stash store 1e9b483d1f9477de5c99a708f4aa512ba > $ git stash list > > What did you expect to happen? (Expected behavior) > stash@{0}: example message > > What happened instead? (Actual behavior) > stash@{0}: Created via "git stash store". Hmm. Is it "stash create" that is the problem, or "stash store"? If I do this: git init echo foo >file git add file git commit -m foo echo bar >file commit=$(git stash create "example message") and then look at the resulting commit: git cat-file commit $commit then it has the expected commit message "On main: example message". But when we "git stash store" it, the matching reflog message is the generic "created via git stash store" one. And that reflog message is what is shown by "stash list" (because it is essentially just a reflog walk of the stash ref). So (just guessing) the intended usage is probably: commit=$(git stash create "$msg") git stash store -m "$msg" $commit Which is a bit awkward, but then the point of these sub-commands is for scripted use (I did not even know we had them until seeing this thread). So perhaps we'd want one or both of: 1. A documentation fix to make it clear that if you want to behave the same as "stash push" you should feed the message to both "create" and "store". 2. Possibly "stash store" could pull the default message from the commit, rather than using the generic one. -Peff ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-06 3:25 ` Jeff King @ 2025-07-08 17:13 ` Junio C Hamano 2025-07-08 22:50 ` Jeff King 0 siblings, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2025-07-08 17:13 UTC (permalink / raw) To: Jeff King; +Cc: José Miguel Armijo Fidalgo, git Jeff King <peff@peff•net> writes: > 2. Possibly "stash store" could pull the default message from the > commit, rather than using the generic one. This might be a good compromise. Even we discourage the use of "store" and "create" combo to interactive users, we do care about ergonomics for script writers. Those who use "create" to write a detailed log message (which may later be reused for a real commit that is created out of the stashed changes) would end up with a huge and unpleasant stash entries if they use "store" without any message, which may be a negative experinece for them, though. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-08 17:13 ` Junio C Hamano @ 2025-07-08 22:50 ` Jeff King 2025-07-09 12:45 ` José Miguel Armijo Fidalgo 0 siblings, 1 reply; 8+ messages in thread From: Jeff King @ 2025-07-08 22:50 UTC (permalink / raw) To: Junio C Hamano; +Cc: José Miguel Armijo Fidalgo, git On Tue, Jul 08, 2025 at 10:13:07AM -0700, Junio C Hamano wrote: > Jeff King <peff@peff•net> writes: > > > 2. Possibly "stash store" could pull the default message from the > > commit, rather than using the generic one. > > This might be a good compromise. Even we discourage the use of > "store" and "create" combo to interactive users, we do care about > ergonomics for script writers. > > Those who use "create" to write a detailed log message (which may > later be reused for a real commit that is created out of the stashed > changes) would end up with a huge and unpleasant stash entries if > they use "store" without any message, which may be a negative > experinece for them, though. I'd feel a bit better about tweaking the ergonomics of "stash store" if I thought it was generally useful to script writers. But it appears to have been created solely as an implementation detail of rebase.autostash, and I do not recall ever hearing of anybody using it in the 12 years since. I.e., without understanding why somebody would want to use it in the first place, I don't know what potential we have to disrupt them by switching the behavior (and nor am I all that excited to spend time working on it. ;) ). Maybe José can tell us a bit more about his use case. -Peff ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-08 22:50 ` Jeff King @ 2025-07-09 12:45 ` José Miguel Armijo Fidalgo 0 siblings, 0 replies; 8+ messages in thread From: José Miguel Armijo Fidalgo @ 2025-07-09 12:45 UTC (permalink / raw) To: git Hi all, Thank you for taking the time to look at this issue. I don’t have a specific use case for these commands yet. I was simply trying to learn more about Git and naturally turned to the documentation. However, it didn’t provide many answers for these commands. I understood that a use case is to create a commit object and then store it in the stash reference. And as I kept experimenting, I noticed I could pass a message to the create command, but it wasn’t clear what the command does with it. From the perspective of someone trying to become more proficient with Git, the documentation didn’t help in this case. I wasn’t sure if this was a bug in the code, a documentation issue, or both. After reading your answers, this seems to be mostly a documentation issue: if the command and options are there, they should provide enough clarity to understand their basic purpose and functionality, right? It also makes me wonder if these commands aren’t commonly used because their use case and concrete usage steps are unclear (chicken-egg problem?) For example, my understanding was that commit objects created with git stash create could only be used to add them to the stash. But your comments have let me see that this is incorrect, and that these commit objects can actually be used to create new branches, perform a cherry-pick, and so on. tbh, I find it odd that a command of the "stash" family can create a commit object that can be used for other things. I can understand that this is legacy and can live with that, but it’d still be great to have it documented so people can learn about these commands. Looking forward to hearing more from your insights. Cheers, José Miguel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-06 1:28 Bug: "git stash create" ignores "message" argument José Miguel Armijo Fidalgo 2025-07-06 3:25 ` Jeff King @ 2025-07-06 3:36 ` Darren Rambaud 2025-07-08 6:26 ` José Miguel Armijo Fidalgo 1 sibling, 1 reply; 8+ messages in thread From: Darren Rambaud @ 2025-07-06 3:36 UTC (permalink / raw) To: José Miguel Armijo Fidalgo, git You won't see the custom message in `git stash list`, you will see it in `git log` while in detached HEAD state. $ git stash create "changes to readme" 0a28354847baf90f2c7377a262f35e62c461a95e $ git stash store 0a28354847baf90f2c7377a262f35e62c461a95e $ git checkout 0a28354847baf90f2c7377a262f35e62c461a95e $ git log commit 0a28354847baf90f2c7377a262f35e62c461a95e (HEAD) Merge: 323920c 46c4b6a Author: git stash <git@stash> Date: Sat Jul 5 22:18:58 2025 -0500 On main: changes to readme commit 46c4b6a5d22df525da70c1bbfc6d3a36c4ba25e3 Author: git stash <git@stash> Date: Sat Jul 5 22:18:58 2025 -0500 index on main: 323920c docs: add readme ... Darren On 2025-07-05 20:28, José Miguel Armijo Fidalgo wrote: > What did you do before the bug happened? (Steps to reproduce your issue) > $ git stash create "example message" > 1e9b483d1f9477de5c99a708f4aa512ba > $ git stash store 1e9b483d1f9477de5c99a708f4aa512ba > $ git stash list > > What did you expect to happen? (Expected behavior) > stash@{0}: example message > > What happened instead? (Actual behavior) > stash@{0}: Created via "git stash store". > > What's different between what you expected and what actually happened? > The documentation does not explain what the message "argument" is used for. > I would have expected that the message would be used by the store command. > > Anything else you want to add: > If the message argument is not used at all, I would expect to > remove the argument, or > alternatively, that the documentation explains why the argument > exists and what it does/doesn't do. > > Please review the rest of the bug report below. > You can delete any lines you don't wish to share. > > [System Info] > git version: > git version 2.50.0 > cpu: arm64 > no commit associated with this build > sizeof-long: 8 > sizeof-size_t: 8 > shell-path: /bin/sh > feature: fsmonitor--daemon > libcurl: 8.7.1 > zlib: 1.2.12 > SHA-1: SHA1_DC > SHA-256: SHA256_BLK > uname: Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:33 > PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8122 arm64 > compiler info: clang: 17.0.0 (clang-1700.0.13.3) > libc info: no libc information available > $SHELL (typically, interactive shell): /bin/zsh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-06 3:36 ` Darren Rambaud @ 2025-07-08 6:26 ` José Miguel Armijo Fidalgo 2025-07-08 16:00 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: José Miguel Armijo Fidalgo @ 2025-07-08 6:26 UTC (permalink / raw) To: git > You won't see the custom message in `git stash list` If this is working as expected, maybe this is a documentation bug? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug: "git stash create" ignores "message" argument 2025-07-08 6:26 ` José Miguel Armijo Fidalgo @ 2025-07-08 16:00 ` Junio C Hamano 0 siblings, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2025-07-08 16:00 UTC (permalink / raw) To: José Miguel Armijo Fidalgo; +Cc: git José Miguel Armijo Fidalgo <jm.armijo.f@gmail•com> writes: >> You won't see the custom message in `git stash list` > If this is working as expected, maybe this is a documentation bug? The documentation says "a short description of the commit the entry was based on", which dates back to pretty much the day one of the stash command 09ccdb63 (Document git-stash, 2007-07-01), and hasn't been updated or enhanced at all ever since. Back then, the world was simpler. The command has a single very focused purpose: I am in the middle of doing something, my boss descends on me, I say "git stash" to clear away everything I am doing so that I can start working on a totally different thing and I want to do so as quickly as possible---without even wasting any time to write any "commit log message". So "a short description" was just that. Automatically generated identifier to let you identify the stash entry, so that you can get back to the state immediately before that emergency. As long as what is shown serves that purpose, I would say it is working as expected, as you are not even supposed to _care_ what that message exactly say ;-) Readers may compare today's documentation and the original at 09ccdb63 and they will notice that, even the explanation of the `list` subcommand hasn't changed much, the accompanying example has. That comes from the code change made at ec96e0f6 (Document "git stash message...", 2007-07-17) when the command learned "git stash [save] <message>" to quickly leave a custom note. The description for the command overall was updated to say that by default we say "WIP on ..." but a custom message can be used, but the commit did not update the description for `list`, so the wording "the commit the entry was based on" was left behind, which may be a documentation bug. It is also a bit unfortunate that "git stash create <message>" is exposed without enough documentation. The only reason that subcommand exists is to allow scripts to reimplement "git stash save/push -m <message>", which internally (1) creates a commit that is to be used as a stash entry and (2) stores it as a stash entry in the refs/stash. Since both of these suboperations need some message, "git stash save/push" take a single message and use that for both. Anybody who is emulating save/push by using create followed by store can do the same, i.e. use the same message, but that is not documented clearly. We may want to update the documentation to say something like the attached patch. Documentation/git-stash.adoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git c/Documentation/git-stash.adoc w/Documentation/git-stash.adoc index e5e6c9d37f..e7a9165b71 100644 --- c/Documentation/git-stash.adoc +++ w/Documentation/git-stash.adoc @@ -38,9 +38,9 @@ The modifications stashed away by this command can be listed with `git stash list`, inspected with `git stash show`, and restored (potentially on top of a different commit) with `git stash apply`. Calling `git stash` without any arguments is equivalent to `git stash push`. -A stash is by default listed as "WIP on 'branchname' ...", but -you can give a more descriptive message on the command line when -you create one. +A stash is by default given "WIP on 'branchname' ..." as its message, but +you can give a more descriptive message on the command line when you run +"git stash push", "git stash save", or "git stash store". The latest stash you created is stored in `refs/stash`; older stashes are found in the reflog of this reference and can be named using @@ -76,7 +76,8 @@ list [<log-options>]:: List the stash entries that you currently have. Each 'stash entry' is listed with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is - the one before, etc.), the name of the branch that was current when the + the one before, etc.), and the message given to the entry with `save`, + `push`, or `store` when the entry was made, and a short description of the commit the entry was based on. + @@ -146,8 +147,11 @@ create:: Create a stash entry (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace. - This is intended to be useful for scripts. It is probably not - the command you want to use; see "push" above. + This is intended to be useful for scripts. It actually takes + a _<message>_ argument, but that is for the sole consumption + for internal use by `push` and `save` command, so it is not + documented here. This is probably not the command you want + to use; see "push" above. store:: ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-09 12:45 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-06 1:28 Bug: "git stash create" ignores "message" argument José Miguel Armijo Fidalgo 2025-07-06 3:25 ` Jeff King 2025-07-08 17:13 ` Junio C Hamano 2025-07-08 22:50 ` Jeff King 2025-07-09 12:45 ` José Miguel Armijo Fidalgo 2025-07-06 3:36 ` Darren Rambaud 2025-07-08 6:26 ` José Miguel Armijo Fidalgo 2025-07-08 16:00 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox