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

Re: git-stash: RFC: Adopt the default behavior to other commands

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 18, 2007, 15:28 UTC
Message-ID
<EA6D22B6-CB49-439C-B31B-AE145B22BB35@wincent.com>
In-Reply-To
<4767D7A2.30703@op5.se>
El 18/12/2007, a las 15:22, Andreas Ericsson escribió:
Show 28 quoted lines
> Johannes Schindelin wrote:
>> Hi,
>> On Tue, 18 Dec 2007, Sebastian Harl wrote:
>>> On Mon, Dec 17, 2007 at 04:31:12PM -0800, Junio C Hamano wrote:
>>>> But the original point by Sebastian hasn't been answered.  He  
>>>> wanted to make the command list the stash without arguments.
>>>>
>>>> This was discussed already in the early days of stash and there  
>>>> indeed was a suggestion to do so (I think I sided with that), but  
>>>> the users did not want it.  IIRC, the argument went like: "when I  
>>>> say 'stash', that is because I want a quick and immediate way to  
>>>> stash, and I do not want a list.  If I do not have to have a  
>>>> quick way, I would create a temporary commit on the current  
>>>> branch, or switch to a temporary branch and commit there."
>>> Well, "git stash save" is just five characters more - I really  
>>> don't see why this would be less comfortable (and for the really  
>>> lazy people there are still aliases...). On the other hand (if  
>>> "list" is the default), we'd get a more consistent interface which  
>>> imho is imho more important than typing five characters less.
>> It's more about what you're used to.  I had an alias named 'stash'  
>> long before it became a git command.  And now guess how _annoying_  
>> it would be to type "git stash<Return><Curse out loud at my  
>> mouse>git stash save<Return>".
>
> Not nearly as annoying as losing work because of it, and you obviously
> *know* what to do when you're done cursing, while clueless-newbie-X  
> just
> hops away and uses subversion.

There's not really any peril of losing work here, seeing as this should be a lossless round trip:

git stash # oops! didn't mean to save git stash apply

We could help clueless-newbie-X here by augmenting the save output:
   Saved "WIP on master: 8ed8a26... s"
   HEAD is now at 8ed8a26... s
As follows (or similar):
   Saved working directory and index state "WIP on master: 8ed8a26... s"
   (To restore them type "git stash apply")
   HEAD is now at 8ed8a26... s

ie. we explicitly tell them what was saved (their working directory and index state), and also how to get it back immediately if that's not what they meant to do. Something like this (no doubt will be whitespace-mangled because I'm pasting this into my email client, but it's just to demo the idea):

diff --git a/git-stash.sh b/git-stash.sh
index f16fd9c..a2f3723 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -99,7 +99,8 @@ save_stash () {

         git update-ref -m "$stash_msg" $ref_stash $w_commit ||
                 die "Cannot save the current status"
-       printf >&2 'Saved "%s"\n' "$stash_msg"
+       printf >&2 'Saved working directory and index state "%s"\n'  
"$stash_msg"
+       echo >&2 '(To restore them type "git stash apply")'
  }

  have_stash () {

Cheers,
Wincent
Previous: Martin LanghoffNext: Jörg Sommer
Message 19 of 33 in “git-stash: RFC: Adopt the default behavior to other commands”
  1. Sebastian HarlDec 17, 2007
  2. Benoit SigoureDec 17, 2007
  3. Junio C HamanoDec 17, 2007
  4. Benoit SigoureDec 17, 2007
  5. Junio C HamanoDec 18, 2007
  6. Sebastian HarlDec 18, 2007
  7. Johannes SchindelinDec 18, 2007
  8. Andreas EricssonDec 18, 2007
  9. Johannes SchindelinDec 18, 2007
  10. Andreas EricssonDec 18, 2007
  11. Johannes SchindelinDec 18, 2007
  12. Andreas EricssonDec 18, 2007
  13. Jakub NarebskiDec 18, 2007
  14. Andreas EricssonDec 18, 2007
  15. Johannes SchindelinDec 18, 2007
  16. Sergei OrganovDec 18, 2007
  17. Johannes SchindelinDec 18, 2007
  18. Martin LanghoffDec 18, 2007
  19. Wincent ColaiutaDec 18, 2007
  20. Jörg SommerDec 18, 2007
  21. Johannes SchindelinDec 18, 2007
  22. Junio C HamanoDec 18, 2007
  23. しらいしななこDec 20, 2007
  24. Junio C HamanoDec 20, 2007
  25. Wincent ColaiutaDec 21, 2007
  26. しらいしななこDec 21, 2007
  27. André Goddard RosaDec 18, 2007
  28. Martin LanghoffDec 18, 2007
  29. Wincent ColaiutaDec 19, 2007
  30. Martin LanghoffDec 19, 2007
  31. Andreas EricssonDec 19, 2007
  32. Johannes SchindelinDec 19, 2007
  33. Wincent ColaiutaDec 19, 2007

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.