git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug report: git-stash doesn't return correct status code

From
VTVromen, Tomer <tomer.vromen@intel.com>
Date
Mar 7, 2018, 12:16 UTC
Message-ID
<8ED425DE0F8BEC45AADD477A8872875788FB691C@hasmsx109.ger.corp.intel.com>
Hi all,
I often use this one-liner:
> git stash && git checkout -b new-feature-branch && git stash pop

This is useful when I realize that I want to open a new branch for my changes (that I haven't committed yet). However, I might have forgotten to save my changes in the editor, so git-stash will give this error:

No local changes to save

Despite the error, the command returns status code 0, and so the branch is created and the stash is popped, which was not my intention. I think that git-stash should return a non-zero status code if it didn't push a new stash.

git version: 2.8.4

Thank you, Tomer Vromen

--------------------------------------------------------------------- Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Next: Junio C Hamano
Message 1 of 4 in “Bug report: git-stash doesn't return correct status code”
  1. Vromen, TomerMar 7, 2018
  2. Junio C HamanoMar 7, 2018
  3. Junio C HamanoMar 7, 2018
  4. Vromen, TomerMar 8, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.