{"thread":{"id":"63747","subject":"Bug: \"git stash create\" ignores \"message\" argument","startedAt":"2025-07-06T01:29:18Z","lastAt":"2025-07-09T12:45:37Z","messageCount":8,"participants":["José Miguel Armijo Fidalgo","Jeff King","Darren Rambaud","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"521351","messageId":"CAKMuBmSeFh63212_GhBHfOTbW5VaqvQjo7jz4aowm8bntCXkVw@mail.gmail.com","threadId":"63747","inReplyTo":null,"subject":"Bug: \"git stash create\" ignores \"message\" argument","fromName":"José Miguel Armijo Fidalgo","fromEmail":"jm.armijo.f@gmail.com","sentAt":"2025-07-06T01:28:46Z","receivedAt":"2025-07-06T01:29:18Z","isPatch":false,"sender":{"key":"jm.armijo.f@gmail.com","avatar":"https://gravatar.com/avatar/ffc3f6e9f39dc570ec49d3ee269711a6b826142dcdf4c3157e7b34e4ffa964d5?d=mp&s=160"},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n    $ git stash create \"example message\"\n    1e9b483d1f9477de5c99a708f4aa512ba\n    $ git stash store 1e9b483d1f9477de5c99a708f4aa512ba\n    $ git stash list\n\nWhat did you expect to happen? (Expected behavior)\n     stash@{0}: example message\n\nWhat happened instead? (Actual behavior)\n     stash@{0}: Created via \"git stash store\".\n\nWhat's different between what you expected and what actually happened?\n    The documentation does not explain what the message \"argument\" is used for.\n    I would have expected that the message would be used by the store command.\n\nAnything else you want to add:\n    If the message argument is not used at all, I would expect to\nremove the argument, or\n    alternatively, that the documentation explains why the argument\nexists and what it does/doesn't do.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n[System Info]\ngit version:\ngit version 2.50.0\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nlibcurl: 8.7.1\nzlib: 1.2.12\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\nuname: Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:33\nPDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8122 arm64\ncompiler info: clang: 17.0.0 (clang-1700.0.13.3)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n"},{"id":"521353","messageId":"20250706032512.GB3041790@coredump.intra.peff.net","threadId":"63747","inReplyTo":"CAKMuBmSeFh63212_GhBHfOTbW5VaqvQjo7jz4aowm8bntCXkVw@mail.gmail.com","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-07-06T03:25:12Z","receivedAt":"2025-07-06T03:25:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jul 06, 2025 at 11:28:46AM +1000, José Miguel Armijo Fidalgo wrote:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>     $ git stash create \"example message\"\n>     1e9b483d1f9477de5c99a708f4aa512ba\n>     $ git stash store 1e9b483d1f9477de5c99a708f4aa512ba\n>     $ git stash list\n> \n> What did you expect to happen? (Expected behavior)\n>      stash@{0}: example message\n> \n> What happened instead? (Actual behavior)\n>      stash@{0}: Created via \"git stash store\".\n\nHmm. Is it \"stash create\" that is the problem, or \"stash store\"?\n\nIf I do this:\n\n  git init\n  echo foo >file\n  git add file\n  git commit -m foo\n\n  echo bar >file\n  commit=$(git stash create \"example message\")\n\nand then look at the resulting commit:\n\n  git cat-file commit $commit\n\nthen it has the expected commit message \"On main: example message\".\n\nBut when we \"git stash store\" it, the matching reflog message is the\ngeneric \"created via git stash store\" one. And that reflog message is\nwhat is shown by \"stash list\" (because it is essentially just a reflog\nwalk of the stash ref).\n\nSo (just guessing) the intended usage is probably:\n\n  commit=$(git stash create \"$msg\")\n  git stash store -m \"$msg\" $commit\n\nWhich is a bit awkward, but then the point of these sub-commands is for\nscripted use (I did not even know we had them until seeing this thread).\n\nSo perhaps we'd want one or both of:\n\n  1. A documentation fix to make it clear that if you want to behave the\n     same as \"stash push\" you should feed the message to both \"create\"\n     and \"store\".\n\n  2. Possibly \"stash store\" could pull the default message from the\n     commit, rather than using the generic one.\n\n-Peff\n"},{"id":"521356","messageId":"f9a6c8a1-bdbe-4892-bb71-39a6307a5452@ryz.dev","threadId":"63747","inReplyTo":"CAKMuBmSeFh63212_GhBHfOTbW5VaqvQjo7jz4aowm8bntCXkVw@mail.gmail.com","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"Darren Rambaud","fromEmail":"d.gitscm@ryz.dev","sentAt":"2025-07-06T03:36:14Z","receivedAt":"2025-07-06T03:38:26Z","isPatch":false,"sender":{"key":"d.gitscm@ryz.dev","avatar":null},"body":"You won't see the custom message in `git stash list`, you will see it in \n`git log` while in detached HEAD state.\n\n$ git stash create \"changes to readme\"\n0a28354847baf90f2c7377a262f35e62c461a95e\n$ git stash store 0a28354847baf90f2c7377a262f35e62c461a95e\n$ git checkout 0a28354847baf90f2c7377a262f35e62c461a95e\n$ git log\ncommit 0a28354847baf90f2c7377a262f35e62c461a95e (HEAD)\nMerge: 323920c 46c4b6a\nAuthor: git stash <git@stash>\nDate:   Sat Jul 5 22:18:58 2025 -0500\n\n     On main: changes to readme\n\ncommit 46c4b6a5d22df525da70c1bbfc6d3a36c4ba25e3\nAuthor: git stash <git@stash>\nDate:   Sat Jul 5 22:18:58 2025 -0500\n\n     index on main: 323920c docs: add readme\n...\n\nDarren\n\nOn 2025-07-05 20:28, José Miguel Armijo Fidalgo wrote:\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>      $ git stash create \"example message\"\n>      1e9b483d1f9477de5c99a708f4aa512ba\n>      $ git stash store 1e9b483d1f9477de5c99a708f4aa512ba\n>      $ git stash list\n> \n> What did you expect to happen? (Expected behavior)\n>       stash@{0}: example message\n> \n> What happened instead? (Actual behavior)\n>       stash@{0}: Created via \"git stash store\".\n> \n> What's different between what you expected and what actually happened?\n>      The documentation does not explain what the message \"argument\" is used for.\n>      I would have expected that the message would be used by the store command.\n> \n> Anything else you want to add:\n>      If the message argument is not used at all, I would expect to\n> remove the argument, or\n>      alternatively, that the documentation explains why the argument\n> exists and what it does/doesn't do.\n> \n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n> \n> [System Info]\n> git version:\n> git version 2.50.0\n> cpu: arm64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> feature: fsmonitor--daemon\n> libcurl: 8.7.1\n> zlib: 1.2.12\n> SHA-1: SHA1_DC\n> SHA-256: SHA256_BLK\n> uname: Darwin 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:33\n> PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8122 arm64\n> compiler info: clang: 17.0.0 (clang-1700.0.13.3)\n> libc info: no libc information available\n> $SHELL (typically, interactive shell): /bin/zsh\n\n"},{"id":"521503","messageId":"CAKMuBmQadPerSrOsMmLkJzPChr0TWRH3dy1mRYFx4Hfn6DoBPw@mail.gmail.com","threadId":"63747","inReplyTo":"f9a6c8a1-bdbe-4892-bb71-39a6307a5452@ryz.dev","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"José Miguel Armijo Fidalgo","fromEmail":"jm.armijo.f@gmail.com","sentAt":"2025-07-08T06:26:49Z","receivedAt":"2025-07-08T06:27:16Z","isPatch":false,"sender":{"key":"jm.armijo.f@gmail.com","avatar":"https://gravatar.com/avatar/ffc3f6e9f39dc570ec49d3ee269711a6b826142dcdf4c3157e7b34e4ffa964d5?d=mp&s=160"},"body":"> You won't see the custom message in `git stash list`\nIf this is working as expected, maybe this is a documentation bug?\n"},{"id":"521553","messageId":"xmqqv7o2wu37.fsf@gitster.g","threadId":"63747","inReplyTo":"CAKMuBmQadPerSrOsMmLkJzPChr0TWRH3dy1mRYFx4Hfn6DoBPw@mail.gmail.com","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-08T16:00:44Z","receivedAt":"2025-07-08T16:00:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"José Miguel Armijo Fidalgo <jm.armijo.f@gmail.com> writes:\n\n>> You won't see the custom message in `git stash list`\n> If this is working as expected, maybe this is a documentation bug?\n\nThe documentation says \"a short description of the commit the entry\nwas based on\", which dates back to pretty much the day one of the\nstash command 09ccdb63 (Document git-stash, 2007-07-01), and hasn't\nbeen updated or enhanced at all ever since.\n\nBack then, the world was simpler.  The command has a single very\nfocused purpose: I am in the middle of doing something, my boss\ndescends on me, I say \"git stash\" to clear away everything I am\ndoing so that I can start working on a totally different thing and I\nwant to do so as quickly as possible---without even wasting any time\nto write any \"commit log message\".\n\nSo \"a short description\" was just that.  Automatically generated\nidentifier to let you identify the stash entry, so that you can get\nback to the state immediately before that emergency.  As long as\nwhat is shown serves that purpose, I would say it is working as\nexpected, as you are not even supposed to _care_ what that message\nexactly say ;-)\n\nReaders may compare today's documentation and the original at\n09ccdb63 and they will notice that, even the explanation of the\n`list` subcommand hasn't changed much, the accompanying example has.\nThat comes from the code change made at ec96e0f6 (Document \"git\nstash message...\", 2007-07-17) when the command learned \"git stash\n[save] <message>\" to quickly leave a custom note.  The description\nfor the command overall was updated to say that by default we say\n\"WIP on ...\" but a custom message can be used, but the commit did\nnot update the description for `list`, so the wording \"the commit\nthe entry was based on\" was left behind, which may be a\ndocumentation bug.\n\nIt is also a bit unfortunate that \"git stash create <message>\" is\nexposed without enough documentation.  The only reason that\nsubcommand exists is to allow scripts to reimplement \"git stash\nsave/push -m <message>\", which internally (1) creates a commit that\nis to be used as a stash entry and (2) stores it as a stash entry in\nthe refs/stash.  Since both of these suboperations need some\nmessage, \"git stash save/push\" take a single message and use that\nfor both.  Anybody who is emulating save/push by using create\nfollowed by store can do the same, i.e. use the same message, but\nthat is not documented clearly.\n\nWe may want to update the documentation to say something like the\nattached patch.\n\n Documentation/git-stash.adoc | 16 ++++++++++------\n 1 file changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git c/Documentation/git-stash.adoc w/Documentation/git-stash.adoc\nindex e5e6c9d37f..e7a9165b71 100644\n--- c/Documentation/git-stash.adoc\n+++ w/Documentation/git-stash.adoc\n@@ -38,9 +38,9 @@ The modifications stashed away by this command can be listed with\n `git stash list`, inspected with `git stash show`, and restored\n (potentially on top of a different commit) with `git stash apply`.\n Calling `git stash` without any arguments is equivalent to `git stash push`.\n-A stash is by default listed as \"WIP on 'branchname' ...\", but\n-you can give a more descriptive message on the command line when\n-you create one.\n+A stash is by default given \"WIP on 'branchname' ...\" as its message, but\n+you can give a more descriptive message on the command line when you run\n+\"git stash push\", \"git stash save\", or \"git stash store\".\n \n The latest stash you created is stored in `refs/stash`; older\n stashes are found in the reflog of this reference and can be named using\n@@ -76,7 +76,8 @@ list [<log-options>]::\n \n \tList the stash entries that you currently have.  Each 'stash entry' is\n \tlisted with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is\n-\tthe one before, etc.), the name of the branch that was current when the\n+\tthe one before, etc.), and the message given to the entry with `save`,\n+\t`push`, or `store` when the\n \tentry was made, and a short description of the commit the entry was\n \tbased on.\n +\n@@ -146,8 +147,11 @@ create::\n \tCreate a stash entry (which is a regular commit object) and\n \treturn its object name, without storing it anywhere in the ref\n \tnamespace.\n-\tThis is intended to be useful for scripts.  It is probably not\n-\tthe command you want to use; see \"push\" above.\n+\tThis is intended to be useful for scripts.  It actually takes\n+\ta _<message>_ argument, but that is for the sole consumption\n+\tfor internal use by `push` and `save` command, so it is not \n+\tdocumented here.  This is probably not the command you want\n+\tto use; see \"push\" above.\n \n store::\n \n"},{"id":"521557","messageId":"xmqqv7o2vc64.fsf@gitster.g","threadId":"63747","inReplyTo":"20250706032512.GB3041790@coredump.intra.peff.net","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-08T17:13:07Z","receivedAt":"2025-07-08T17:13:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>   2. Possibly \"stash store\" could pull the default message from the\n>      commit, rather than using the generic one.\n\nThis might be a good compromise.  Even we discourage the use of\n\"store\" and \"create\" combo to interactive users, we do care about\nergonomics for script writers.\n\nThose who use \"create\" to write a detailed log message (which may\nlater be reused for a real commit that is created out of the stashed\nchanges) would end up with a huge and unpleasant stash entries if\nthey use \"store\" without any message, which may be a negative\nexperinece for them, though.\n\n\n\n"},{"id":"521585","messageId":"20250708225007.GA1180568@coredump.intra.peff.net","threadId":"63747","inReplyTo":"xmqqv7o2vc64.fsf@gitster.g","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-07-08T22:50:07Z","receivedAt":"2025-07-08T22:50:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 08, 2025 at 10:13:07AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> >   2. Possibly \"stash store\" could pull the default message from the\n> >      commit, rather than using the generic one.\n> \n> This might be a good compromise.  Even we discourage the use of\n> \"store\" and \"create\" combo to interactive users, we do care about\n> ergonomics for script writers.\n> \n> Those who use \"create\" to write a detailed log message (which may\n> later be reused for a real commit that is created out of the stashed\n> changes) would end up with a huge and unpleasant stash entries if\n> they use \"store\" without any message, which may be a negative\n> experinece for them, though.\n\nI'd feel a bit better about tweaking the ergonomics of \"stash store\" if\nI thought it was generally useful to script writers. But it appears to\nhave been created solely as an implementation detail of\nrebase.autostash, and I do not recall ever hearing of anybody using it\nin the 12 years since.\n\nI.e., without understanding why somebody would want to use it in the\nfirst place, I don't know what potential we have to disrupt them by\nswitching the behavior (and nor am I all that excited to spend time\nworking on it. ;) ).\n\nMaybe José can tell us a bit more about his use case.\n\n-Peff\n"},{"id":"521669","messageId":"CAKMuBmS+jFO61iFP5H7-B0UKsiguZ4ufkqsUg7YpZGoJVMHYaw@mail.gmail.com","threadId":"63747","inReplyTo":"20250708225007.GA1180568@coredump.intra.peff.net","subject":"Re: Bug: \"git stash create\" ignores \"message\" argument","fromName":"José Miguel Armijo Fidalgo","fromEmail":"jm.armijo.f@gmail.com","sentAt":"2025-07-09T12:45:10Z","receivedAt":"2025-07-09T12:45:37Z","isPatch":false,"sender":{"key":"jm.armijo.f@gmail.com","avatar":"https://gravatar.com/avatar/ffc3f6e9f39dc570ec49d3ee269711a6b826142dcdf4c3157e7b34e4ffa964d5?d=mp&s=160"},"body":"Hi all,\n\nThank you for taking the time to look at this issue.\n\nI don’t have a specific use case for these commands yet. I was simply\ntrying to learn more about Git and naturally turned to the\ndocumentation. However, it didn’t provide many answers for these\ncommands. I understood that a use case is to create a commit object\nand then store it in the stash reference. And as I kept experimenting,\nI noticed I could pass a message to the create command, but it wasn’t\nclear what the command does with it.\n\nFrom the perspective of someone trying to become more proficient with\nGit, the documentation didn’t help in this case. I wasn’t sure if this\nwas a bug in the code, a documentation issue, or both. After reading\nyour answers, this seems to be mostly a documentation issue: if the\ncommand and options are there, they should provide enough clarity to\nunderstand their basic purpose and functionality, right? It also makes\nme wonder if these commands aren’t commonly used because their use\ncase and concrete usage steps are unclear (chicken-egg problem?)\n\nFor example, my understanding was that commit objects created with git\nstash create could only be used to add them to the stash. But your\ncomments have let me see that this is incorrect, and that these commit\nobjects can actually be used to create new branches, perform a\ncherry-pick, and so on. tbh, I find it odd that a command of the\n\"stash\" family can create a commit object that can be used for other\nthings. I can understand that this is legacy and can live with that,\nbut it’d still be great to have it documented so people can learn\nabout these commands.\n\nLooking forward to hearing more from your insights.\n\nCheers,\nJosé Miguel\n"}]}