Thread (21 messages) flat view 21 messages, 9 authors, 2016-06-15

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

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:44:00

Possibly related (same subject, not in this thread)

Hi,

On Wed, 19 Dec 2007, Martin Langhoff wrote:
On Dec 19, 2007 8:33 PM, Wincent Colaiuta [off-list ref] wrote:
quoted
El 19/12/2007, a las 0:41, Martin Langhoff escribi?:
quoted
On Dec 19, 2007 4:42 AM, J?rg Sommer [off-list ref] wrote:
quoted
I vote for stash print the list, because I dropped in the pitfall.
I've dropped there myself, and work with a large team where we are 
both fans of stash, and scarred by it. Any newcomer to git that 
"discovers" stash gets hit by it a dozen times, this is completely 
unnecesary.
I may be missing something here, but what's the danger here? An
Surprise. Your working directory has *just* changed under your feet. 
Maybe you have an editor with further unsaved changes that is about to 
act confused whether you undo the stash or not.
The funny thing: why do you call stash with unsaved changes anyway?  I 
mean, come on, even if you were planning to see the usage of stash (which 
you would get with -h), you undoubtedly wanted to either stash or unstash 
some changes.  Otherwise you would not _need_ to see the usage to begin 
with.
quoted
unexpected stash is incredibly easy to revert, unless I'm missing
Once you know about it, yes it is. Once you know about the reflog, you
can sing and dance and never be worried. But for starting users, it's
a dangerous command.
No.

Reflogs have nothing to do with it.

If you want to stash changes, you _got_ to know how to unstash those 
changes.  Otherwise "git reset --hard" would have been your friend.

And so, I cannot help but believe that all users of stash -- even the new 
ones -- know about the fundamental concept of stashing/unstashing, and 
therefore it is more something like this:

	$ git stash
	[no usage?  What the heck... Oh, it stashed the changes.  I did 
	 not want to stash them just yet.  Okay:]
	$ git unstash
	No such command
	[Oh, maybe I should have read the man page.  Oh, well, the usage 
	 should do...]
	$ git stash -h
	...

Yes, if you start "git stash" blindly, believing that it does what "git 
stash -h" does, you will be bitten by it once.

But as I said, you will be bitten by a plenty commands if you are not 
familiar with the concept that "-h" shows the synopsis, "--help" the man 
page, and that there is a default action where possible.

But stash really is about things like

	$ git stash
	$ git pull
	$ git stash apply

I do not _want_ to see the stash list in _most_ cases, because I do not 
stash away million dirty changes.

And that workflow was what "git stash" was designed for.
quoted
And nobody commented on the idea I posted earlier which seems to 
address the concerns about newbies not knowing what "git stash" with 
no params does:
I agree with making stash more verbose -- if the unlucky new user is
paying close attention, they'll have instructions on to how to get out
of trouble. But I agree more with making it "just verbose, no action"
by default. There are two strong hints:

 - all other state-changing commands take parameters
What about "git commit", "git reset", "git fetch"?  These definitely 
change state of the repository.
 - quite a few people in this list have gotten burned with it
Okay, let's have a little calculation: IIRC 3 people (let's make it 10, to 
be conservative) have said that they had this problem.  I must assume that 
all other people did not have the problem, or at least saw why the default 
action of "git stash" is what it is.

That said, if you _have_ to have the default changed, then I'll probably 
implement a "git push" and "git pop" alias here, so that I cannot get 
annoyed by stash's "new and improved" behaviour.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help