All of lore.kernel.org
 help / color / mirror / Atom feed
* `git stash pop` UX Problem
@ 2014-02-24  8:32 Omar Othman
  2014-02-24 16:04 ` Brandon McCaig
  0 siblings, 1 reply; 48+ messages in thread
From: Omar Othman @ 2014-02-24  8:32 UTC (permalink / raw)
  To: git

Hi there,

I'm fairly new to git and I wanted to ask about a certain behavior that 
I want to fix myself (if you agree with me that it is a misbehavior)... 
since I've never contributed to open source and it'll be an important 
step for me to start and get something done.

In general, whenever something a user "should" do, git always tells. So, 
for example, when things go wrong with a merge, you have the option to 
abort. When you are doing a rebase, git tells you to do git commit 
--amend, and then git rebase --continue... and so on.

The point is: Because of this, git is expected to always instruct you on 
what to do next in a multilevel operation, or instructing you what to do 
when an operation has gone wrong.

Now comes the problem. When you do a git stash pop, and a merge conflict 
happens, git correctly tells you to fix the problems and then git add to 
resolve the conflict. But once that happens, and the internal status of 
git tells you that there are no more problems (I have a prompt that 
tells me git's internal status), the operation is not culminated by 
dropping the stash reference, which what normally happens automatically 
after a git stash pop. This has actually confused me for a lot of time, 
till I ran into a git committer and asked him, and only then were I 100% 
confident that I did nothing wrong and it is indeed a UX problem. I 
wasted a lot of time to know why the operation is not completed as 
expected (since I trusted that git just does the right thing), and it 
turned out that it is git's fault.

If this is accepted, please reply to this email and tell me to start 
working on it. I've read the Documenation/SubmittingPatches guidelines, 
but I'll appreciate also telling me where to base my change. My guess is 
maint, since it's a "bug" in the sense of UX.

Thanks and sorry for the long email.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-24  8:32 `git stash pop` UX Problem Omar Othman
@ 2014-02-24 16:04 ` Brandon McCaig
  2014-02-24 16:21   ` Matthieu Moy
  2014-02-25 13:06   ` Omar Othman
  0 siblings, 2 replies; 48+ messages in thread
From: Brandon McCaig @ 2014-02-24 16:04 UTC (permalink / raw)
  To: Omar Othman; +Cc: git

Omar:

On Mon, Feb 24, 2014 at 3:32 AM, Omar Othman <omar.othman@booking.com> wrote:
> In general, whenever something a user "should" do, git always tells. So, for
> example, when things go wrong with a merge, you have the option to abort.
> When you are doing a rebase, git tells you to do git commit --amend, and
> then git rebase --continue... and so on.
>
> The point is: Because of this, git is expected to always instruct you on
> what to do next in a multilevel operation, or instructing you what to do
> when an operation has gone wrong.
>
> Now comes the problem. When you do a git stash pop, and a merge conflict
> happens, git correctly tells you to fix the problems and then git add to
> resolve the conflict. But once that happens, and the internal status of git
> tells you that there are no more problems (I have a prompt that tells me
> git's internal status), the operation is not culminated by dropping the
> stash reference, which what normally happens automatically after a git stash
> pop. This has actually confused me for a lot of time, till I ran into a git
> committer and asked him, and only then were I 100% confident that I did
> nothing wrong and it is indeed a UX problem. I wasted a lot of time to know
> why the operation is not completed as expected (since I trusted that git
> just does the right thing), and it turned out that it is git's fault.
>
> If this is accepted, please reply to this email and tell me to start working
> on it. I've read the Documenation/SubmittingPatches guidelines, but I'll
> appreciate also telling me where to base my change. My guess is maint, since
> it's a "bug" in the sense of UX.

Unlike a merge, when you pop a stash that history is lost. If you
screw up the merge and the stash is dropped then there's generally no
reliable way to get it back. I think that it's correct behavior for
the stash to not be dropped if the merge conflicts. The user is
expected to manually drop the stash when they're done with it. It's
been a while since I've relied much on the stash (commits and branches
are more powerful to work with) so I'm not really familiar with what
help the UI gives when a conflict occurs now. Git's UI never really
expects the user to be negligent. It does help to hint to you what is
needed, but for the most part it still expects you to know what you're
doing and does what you say, not what you mean.

If there's any change that should be made it should be purely
providing more detailed instructions to the user about how to deal
with it. Either resolve the merge conflicts and git-add the
conflicting files, or use git-reset to either reset the index
(unstaging files nad clear) or reset index and working tree back to
HEAD. In general, I almost always git-reset after a git-stash pop
because I'm probably not ready to commit those changes yet and
generally want to still see those changes with git diff (without
--staged). Or perhaps just direct them to the appropriate sections of
the man pages.

I'm not really in favor of "dumbing down" Git in any way and I think
that any step in that direction would be for the worst... Software
should do what you say, not what you mean, because it's impossible to
reliably guess what you meant. When a git-stash pop operation fails
that might make the user rethink popping that stash. That's why it
becomes a manual operation to drop it if still desired. And unlike
git-reset --continue, which is explicitly the user saying "it is fixed
and I accept the consequences, let's move on", there is no such option
to git-stash to acknowledge that the merge conflicts have been
resolved and you no longer need that stash (aside from git-stash drop,
of course). It's not a UI problem. It's maybe a documentation problem,
but again I'm not familiar with the current state of that.

/not a git dev...yet

Regards,


-- 
Brandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-24 16:04 ` Brandon McCaig
@ 2014-02-24 16:21   ` Matthieu Moy
  2014-02-25 12:14     ` Holger Hellmuth
  2014-02-26  0:39     ` Simon Ruderich
  2014-02-25 13:06   ` Omar Othman
  1 sibling, 2 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-24 16:21 UTC (permalink / raw)
  To: Brandon McCaig; +Cc: Omar Othman, git

Brandon McCaig <bamccaig@gmail.com> writes:

> Unlike a merge, when you pop a stash that history is lost. If you
> screw up the merge and the stash is dropped then there's generally no
> reliable way to get it back. I think that it's correct behavior for
> the stash to not be dropped if the merge conflicts.

Agreed.

> If there's any change that should be made it should be purely
> providing more detailed instructions to the user about how to deal
> with it.

Yes, there may be room for improvement, but that does not seem so easy.
Today, we have:

$ git stash pop
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt

$ git status
On branch master
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:      foo.txt

=> The advices shown here are OK. Then:

$ git add foo.txt 
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   foo.txt

=> here, "git status" could have hinted the user "you may now run 'git
stash drop' if you are satisfied with your merge".

An obvious issue is that at this point Git has no way to know that you
just did a "git stash pop". But that could be solved by leaving a file
around like .git/stash-pop-ongoing.

Now, the real question is: when would Git stop showing this advice. I
don't see a real way to answer this, and I'd rather avoid doing just a
guess.

One easy thing to do OTOH would be to show a hint at the end of "git
stash pop"'s output, like

$ git stash pop
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
'stash pop' failed. Please, resolve the conflicts manually. The stash
was not dropped in case you need to restart the operation. When you are
done resolving the merge, you may run the following to drop the stash:

  git stash drop


or so (I couldn't find a concise yet accurate wording).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-24 16:21   ` Matthieu Moy
@ 2014-02-25 12:14     ` Holger Hellmuth
  2014-02-25 12:33       ` Matthieu Moy
  2014-02-26  7:34       ` Omar Othman
  2014-02-26  0:39     ` Simon Ruderich
  1 sibling, 2 replies; 48+ messages in thread
From: Holger Hellmuth @ 2014-02-25 12:14 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Brandon McCaig, Omar Othman, git

Am 24.02.2014 17:21, schrieb Matthieu Moy:
> $ git add foo.txt
> $ git status
> On branch master
> Changes to be committed:
>    (use "git reset HEAD <file>..." to unstage)
>
>          modified:   foo.txt

Maybe status should display a stash count if that count is > 0, as this 
is part of the state of the repo.

$ git status
On branch master
Stashes: 1                         <----------
Changes to be committed:
     (use "git reset HEAD <file>..." to unstage)

           modified:   foo.txt

It would be in Omars example case a clear message that git kept the 
stash. And generally a reminder that there is still a stash around that 
might or might not be obsolete.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 12:14     ` Holger Hellmuth
@ 2014-02-25 12:33       ` Matthieu Moy
  2014-02-25 13:02         ` Omar Othman
                           ` (2 more replies)
  2014-02-26  7:34       ` Omar Othman
  1 sibling, 3 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-25 12:33 UTC (permalink / raw)
  To: Holger Hellmuth; +Cc: Brandon McCaig, Omar Othman, git

Holger Hellmuth <hellmuth@ira.uka.de> writes:

> Am 24.02.2014 17:21, schrieb Matthieu Moy:
>> $ git add foo.txt
>> $ git status
>> On branch master
>> Changes to be committed:
>>    (use "git reset HEAD <file>..." to unstage)
>>
>>          modified:   foo.txt
>
> Maybe status should display a stash count if that count is > 0, as
> this is part of the state of the repo.

Maybe it would help some users, but not me for example. My main use of
"git stash" is a safe replacement for "git reset --hard": when I want to
discard changes, but keep them safe just in case.

So, my stash count is almost always >0, and I don't want to hear about
it.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 12:33       ` Matthieu Moy
@ 2014-02-25 13:02         ` Omar Othman
  2014-02-25 19:12         ` Junio C Hamano
  2014-02-25 23:50         ` brian m. carlson
  2 siblings, 0 replies; 48+ messages in thread
From: Omar Othman @ 2014-02-25 13:02 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Holger Hellmuth, Brandon McCaig, git

Well, it's called `git stash` and not `git trash`... :-D

That's your own usage of it, but its main usage is different.

This is not a solution, but it's better than nothing and I second it.

On 25-02-14 13:33, Matthieu Moy wrote:
> Holger Hellmuth <hellmuth@ira.uka.de> writes:
>
>> Am 24.02.2014 17:21, schrieb Matthieu Moy:
>>> $ git add foo.txt
>>> $ git status
>>> On branch master
>>> Changes to be committed:
>>>     (use "git reset HEAD <file>..." to unstage)
>>>
>>>           modified:   foo.txt
>> Maybe status should display a stash count if that count is > 0, as
>> this is part of the state of the repo.
> Maybe it would help some users, but not me for example. My main use of
> "git stash" is a safe replacement for "git reset --hard": when I want to
> discard changes, but keep them safe just in case.
>
> So, my stash count is almost always >0, and I don't want to hear about
> it.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-24 16:04 ` Brandon McCaig
  2014-02-24 16:21   ` Matthieu Moy
@ 2014-02-25 13:06   ` Omar Othman
  2014-02-25 13:15     ` Matthieu Moy
  1 sibling, 1 reply; 48+ messages in thread
From: Omar Othman @ 2014-02-25 13:06 UTC (permalink / raw)
  To: Brandon McCaig; +Cc: git

Brandon:

Please note that what I am asking for is not always dropping the stash, 
but doing that *only* when the merge conflict is resolved. This is 
simply getting the whole command to be consistent. If you do `git stash 
pop` and it succeeds, the stash reference is dropped. If you do `git 
stash pop` and it succeeds *after resolving the merge conflict*, the 
stash reference is *not* dropped. This is *not* consistent and *is* a 
user experience problem. I'm not asking about dumbing git down by any means.

On 24-02-14 17:04, Brandon McCaig wrote:
> Omar:
>
> On Mon, Feb 24, 2014 at 3:32 AM, Omar Othman <omar.othman@booking.com> wrote:
>> In general, whenever something a user "should" do, git always tells. So, for
>> example, when things go wrong with a merge, you have the option to abort.
>> When you are doing a rebase, git tells you to do git commit --amend, and
>> then git rebase --continue... and so on.
>>
>> The point is: Because of this, git is expected to always instruct you on
>> what to do next in a multilevel operation, or instructing you what to do
>> when an operation has gone wrong.
>>
>> Now comes the problem. When you do a git stash pop, and a merge conflict
>> happens, git correctly tells you to fix the problems and then git add to
>> resolve the conflict. But once that happens, and the internal status of git
>> tells you that there are no more problems (I have a prompt that tells me
>> git's internal status), the operation is not culminated by dropping the
>> stash reference, which what normally happens automatically after a git stash
>> pop. This has actually confused me for a lot of time, till I ran into a git
>> committer and asked him, and only then were I 100% confident that I did
>> nothing wrong and it is indeed a UX problem. I wasted a lot of time to know
>> why the operation is not completed as expected (since I trusted that git
>> just does the right thing), and it turned out that it is git's fault.
>>
>> If this is accepted, please reply to this email and tell me to start working
>> on it. I've read the Documenation/SubmittingPatches guidelines, but I'll
>> appreciate also telling me where to base my change. My guess is maint, since
>> it's a "bug" in the sense of UX.
> Unlike a merge, when you pop a stash that history is lost. If you
> screw up the merge and the stash is dropped then there's generally no
> reliable way to get it back. I think that it's correct behavior for
> the stash to not be dropped if the merge conflicts. The user is
> expected to manually drop the stash when they're done with it. It's
> been a while since I've relied much on the stash (commits and branches
> are more powerful to work with) so I'm not really familiar with what
> help the UI gives when a conflict occurs now. Git's UI never really
> expects the user to be negligent. It does help to hint to you what is
> needed, but for the most part it still expects you to know what you're
> doing and does what you say, not what you mean.
>
> If there's any change that should be made it should be purely
> providing more detailed instructions to the user about how to deal
> with it. Either resolve the merge conflicts and git-add the
> conflicting files, or use git-reset to either reset the index
> (unstaging files nad clear) or reset index and working tree back to
> HEAD. In general, I almost always git-reset after a git-stash pop
> because I'm probably not ready to commit those changes yet and
> generally want to still see those changes with git diff (without
> --staged). Or perhaps just direct them to the appropriate sections of
> the man pages.
>
> I'm not really in favor of "dumbing down" Git in any way and I think
> that any step in that direction would be for the worst... Software
> should do what you say, not what you mean, because it's impossible to
> reliably guess what you meant. When a git-stash pop operation fails
> that might make the user rethink popping that stash. That's why it
> becomes a manual operation to drop it if still desired. And unlike
> git-reset --continue, which is explicitly the user saying "it is fixed
> and I accept the consequences, let's move on", there is no such option
> to git-stash to acknowledge that the merge conflicts have been
> resolved and you no longer need that stash (aside from git-stash drop,
> of course). It's not a UI problem. It's maybe a documentation problem,
> but again I'm not familiar with the current state of that.
>
> /not a git dev...yet
>
> Regards,
>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 13:06   ` Omar Othman
@ 2014-02-25 13:15     ` Matthieu Moy
  2014-02-25 14:12       ` Omar Othman
  0 siblings, 1 reply; 48+ messages in thread
From: Matthieu Moy @ 2014-02-25 13:15 UTC (permalink / raw)
  To: Omar Othman; +Cc: Brandon McCaig, git

Omar Othman <omar.othman@booking.com> writes:

> Brandon:

Please, don't top-post on this list. Look how other people answer to
each other and follow the use.

> Please note that what I am asking for is not always dropping the
> stash, but doing that *only* when the merge conflict is resolved. This
> is simply getting the whole command to be consistent. If you do `git
> stash pop` and it succeeds, the stash reference is dropped. If you do
> git stash pop` and it succeeds *after resolving the merge conflict*,
> the stash reference is *not* dropped. This is *not* consistent and
> *is* a user experience problem. I'm not asking about dumbing git down
> by any means.

Can you describe precisely what you would expect, e.g. what Git's output
should look like after such and such command?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 13:15     ` Matthieu Moy
@ 2014-02-25 14:12       ` Omar Othman
  2014-02-25 15:25         ` Matthieu Moy
  0 siblings, 1 reply; 48+ messages in thread
From: Omar Othman @ 2014-02-25 14:12 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Brandon McCaig, git


>> Please note that what I am asking for is not always dropping the
>> stash, but doing that *only* when the merge conflict is resolved. This
>> is simply getting the whole command to be consistent. If you do `git
>> stash pop` and it succeeds, the stash reference is dropped. If you do
>> git stash pop` and it succeeds *after resolving the merge conflict*,
>> the stash reference is *not* dropped. This is *not* consistent and
>> *is* a user experience problem. I'm not asking about dumbing git down
>> by any means.
> Can you describe precisely what you would expect, e.g. what Git's output
> should look like after such and such command?
Sure. This is my current command prompt (which shows git's internal status):

[omar_othman main (trunk*)]$

I do a git stash pop, which causes a merge conflict:

Auto-merging path/to/file.txt
CONFLICT (content): Merge conflict in path/to/file.txt

[omar_othman main (trunk|MERGING*)]$ vi path/to/file.txt
[omar_othman main (trunk|MERGING*)]$ git add path/to/file.txt
[omar_othman main (trunk*)]$

Note how the status message has changed to show that git is now happy. 
It is at that moment that the stash reference should be dropped (or the 
user (somehow) is notified to do that herself if desired), because this 
means that the popping operation has succeeded.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 14:12       ` Omar Othman
@ 2014-02-25 15:25         ` Matthieu Moy
  2014-02-25 20:52           ` Stephen Leake
  2014-02-26  7:28           ` Omar Othman
  0 siblings, 2 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-25 15:25 UTC (permalink / raw)
  To: Omar Othman; +Cc: Brandon McCaig, git

Omar Othman <omar.othman@booking.com> writes:

> [omar_othman main (trunk|MERGING*)]$ git add path/to/file.txt
> [omar_othman main (trunk*)]$
>
> Note how the status message has changed to show that git is now happy.
> It is at that moment that the stash reference should be dropped

Dropping the stash on a "git add" operation would be really, really
weird...

> (or the user (somehow) is notified to do that herself if desired),
> because this means that the popping operation has succeeded.

But how would you expect to "be notified"?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 12:33       ` Matthieu Moy
  2014-02-25 13:02         ` Omar Othman
@ 2014-02-25 19:12         ` Junio C Hamano
  2014-02-25 20:48           ` Stephen Leake
                             ` (2 more replies)
  2014-02-25 23:50         ` brian m. carlson
  2 siblings, 3 replies; 48+ messages in thread
From: Junio C Hamano @ 2014-02-25 19:12 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Holger Hellmuth, Brandon McCaig, Omar Othman, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Holger Hellmuth <hellmuth@ira.uka.de> writes:
>
>> Am 24.02.2014 17:21, schrieb Matthieu Moy:
>>> $ git add foo.txt
>>> $ git status
>>> On branch master
>>> Changes to be committed:
>>>    (use "git reset HEAD <file>..." to unstage)
>>>
>>>          modified:   foo.txt
>>
>> Maybe status should display a stash count if that count is > 0, as
>> this is part of the state of the repo.
>
> Maybe it would help some users, but not me for example. My main use of
> "git stash" is a safe replacement for "git reset --hard": when I want to
> discard changes, but keep them safe just in case.
>
> So, my stash count is almost always >0, and I don't want to hear about
> it.

"status" is about reminding the user what changes are already in the
index (i.e. what you would commit) and what changes are in the
working tree, from which you could further update the index with
(i.e. what you could commit).

One _could_ argue that stashed changes are what could be reflected
to the working tree and form the source of the latter, but my gut
feeling is that it is a rather weak argument.  At that point you are
talking about what you could potentially change in the working tree,
and the way to do so is not limited to "stash pop" (i.e. you can
"git cherry-pick --no-commit $a_commit", or "edit" any file in the
working tree for that matter, with the same ease).

So, I tend to agree with you, while I do understand where "I want to
know about what is in stash" is coming from (and that is why we do
have "git stash list" command).

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 19:12         ` Junio C Hamano
@ 2014-02-25 20:48           ` Stephen Leake
  2014-02-25 22:20             ` Junio C Hamano
  2014-02-26  7:37           ` Omar Othman
  2014-02-26 15:17           ` Theodore Ts'o
  2 siblings, 1 reply; 48+ messages in thread
From: Stephen Leake @ 2014-02-25 20:48 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> "status" is about reminding the user what changes are already in the
> index (i.e. what you would commit) and what changes are in the
> working tree, from which you could further update the index with
> (i.e. what you could commit).

I believe "status" should tell me everything git knows about the current
workspace in a resonably concise way. That includes the stash.

> One _could_ argue that stashed changes are what could be reflected
> to the working tree and form the source of the latter, but my gut
> feeling is that it is a rather weak argument.  At that point you are
> talking about what you could potentially change in the working tree,

No, I saved things in the stash on purpose. For example, I had changes
that were not ready to commit, but I wanted to do a merge from upstream.

There are workflows where the stash is not important; provide an option
to 'git status' that means "ignore stash". 

> So, I tend to agree with you, while I do understand where "I want to
> know about what is in stash" is coming from (and that is why we do
> have "git stash list" command).

My Emacs front end currently checks both 'git status' and 'git stash
list' to build "the status of the current workspace".

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 15:25         ` Matthieu Moy
@ 2014-02-25 20:52           ` Stephen Leake
  2014-02-25 22:23             ` Junio C Hamano
  2014-02-26  7:28           ` Omar Othman
  1 sibling, 1 reply; 48+ messages in thread
From: Stephen Leake @ 2014-02-25 20:52 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Omar Othman <omar.othman@booking.com> writes:
>
>> [omar_othman main (trunk|MERGING*)]$ git add path/to/file.txt
>> [omar_othman main (trunk*)]$
>>
>> Note how the status message has changed to show that git is now happy.
>> It is at that moment that the stash reference should be dropped
>
> Dropping the stash on a "git add" operation would be really, really
> weird...

Why? That is when the merge conflicts are resolved, which is what
logically indicates that the stash is no longer needed, _if_ the merge
conflicts are related to the stash, which is true in this use case.

There are other uses for 'git add' that don't indicate that; we'd have
to be very careful to not throw away the stash at the wrong time.

>> (or the user (somehow) is notified to do that herself if desired),
>> because this means that the popping operation has succeeded.
>
> But how would you expect to "be notified"?

When 'git add' checks to see if all merge conflicts are now resolved,
and those merge conflicts were related to the stash, it can either pop
the stash, or issue a message telling the user it is now safe to do so.
We would need a config setting to indicate which to do.

Maybe that check is hard to do in general?

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 20:48           ` Stephen Leake
@ 2014-02-25 22:20             ` Junio C Hamano
  2014-02-27 13:18               ` Stephen Leake
  0 siblings, 1 reply; 48+ messages in thread
From: Junio C Hamano @ 2014-02-25 22:20 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

>> One _could_ argue that stashed changes are what could be reflected
>> to the working tree and form the source of the latter, but my gut
>> feeling is that it is a rather weak argument.  At that point you are
>> talking about what you could potentially change in the working tree,
>
> No, I saved things in the stash on purpose. For example, I had changes
> that were not ready to commit, but I wanted to do a merge from upstream.

I often save things by running "git diff >P.diff" on purpose.
Should "git status" read these patches and tell me what paths I
could change in the working tree by applying it?  Where does it end?

> There are workflows where the stash is not important; provide an option
> to 'git status' that means "ignore stash". 

How is that different to tell those who want to know what are in the
stash to type "git stash list" when they want to learn that
information?

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 20:52           ` Stephen Leake
@ 2014-02-25 22:23             ` Junio C Hamano
  2014-02-26 10:24               ` Stefan Haller
  0 siblings, 1 reply; 48+ messages in thread
From: Junio C Hamano @ 2014-02-25 22:23 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

>> Dropping the stash on a "git add" operation would be really, really
>> weird...
>
> Why? That is when the merge conflicts are resolved, which is what
> logically indicates that the stash is no longer needed,...

Not necessarily.  Imagine a case where you used stash to quickly
save away a tangled mess that was not ready for a logically single
commit and now you are in the process of creating the first commit
by applying it piece-by-piece to create multiple resulting ones.
After you commit the result, you would still want to keep the parts
of that stashed change you did not include in the first commit so
that you can go back, no?

You may run "git add", but that does not say anything about what you
are going to use the rest of the stash for.  Not even "git commit"
may be a good enough sign.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 12:33       ` Matthieu Moy
  2014-02-25 13:02         ` Omar Othman
  2014-02-25 19:12         ` Junio C Hamano
@ 2014-02-25 23:50         ` brian m. carlson
  2 siblings, 0 replies; 48+ messages in thread
From: brian m. carlson @ 2014-02-25 23:50 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Holger Hellmuth, Brandon McCaig, Omar Othman, git

[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]

On Tue, Feb 25, 2014 at 01:33:56PM +0100, Matthieu Moy wrote:
> Holger Hellmuth <hellmuth@ira.uka.de> writes:
> > Maybe status should display a stash count if that count is > 0, as
> > this is part of the state of the repo.
> 
> Maybe it would help some users, but not me for example. My main use of
> "git stash" is a safe replacement for "git reset --hard": when I want to
> discard changes, but keep them safe just in case.
> 
> So, my stash count is almost always >0, and I don't want to hear about
> it.

I concur with this.  Sometimes the stashed changes are remnants of a
small hack or a very brief start to an aborted project that I stashed
when I needed to change branches.  I figure that they might be useful in
the future, but I don't care about them right now.  I may pick them up,
I may not, but I certainly don't want to be reminded of them constantly.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-24 16:21   ` Matthieu Moy
  2014-02-25 12:14     ` Holger Hellmuth
@ 2014-02-26  0:39     ` Simon Ruderich
  2014-02-27 13:22       ` Stephen Leake
  1 sibling, 1 reply; 48+ messages in thread
From: Simon Ruderich @ 2014-02-26  0:39 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Brandon McCaig, Omar Othman, git

On Mon, Feb 24, 2014 at 05:21:40PM +0100, Matthieu Moy wrote:
> One easy thing to do OTOH would be to show a hint at the end of "git
> stash pop"'s output, like

I think that's a good idea. It makes it obvious that Git has kept
the stash and that the user should drop it when he's done - if he
wants to.

> $ git stash pop
> Auto-merging foo.txt
> CONFLICT (content): Merge conflict in foo.txt
> 'stash pop' failed. Please, resolve the conflicts manually. The stash
> was not dropped in case you need to restart the operation. When you are
> done resolving the merge, you may run the following to drop the stash:
>
>   git stash drop

Maybe just the following to keep the output on a single line:

    Use 'git stash drop' to remove the stash after resolving the conflicts.

But maybe that's too short as it doesn't mention explicitly, that
the stash was kept.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 15:25         ` Matthieu Moy
  2014-02-25 20:52           ` Stephen Leake
@ 2014-02-26  7:28           ` Omar Othman
  2014-02-26  8:27             ` Matthieu Moy
  1 sibling, 1 reply; 48+ messages in thread
From: Omar Othman @ 2014-02-26  7:28 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Brandon McCaig, git


>> [omar_othman main (trunk|MERGING*)]$ git add path/to/file.txt
>> [omar_othman main (trunk*)]$
>>
>> Note how the status message has changed to show that git is now happy.
>> It is at that moment that the stash reference should be dropped
> Dropping the stash on a "git add" operation would be really, really
> weird...
>
>> (or the user (somehow) is notified to do that herself if desired),
>> because this means that the popping operation has succeeded.
> But how would you expect to "be notified"?
Answering the last question, your previous comments are fine with me:
>> If there's any change that should be made it should be purely
>> providing more detailed instructions to the user about how to deal
>> with it.
> Yes, there may be room for improvement, but that does not seem so easy.
> Today, we have:
>
> $ git stash pop
> Auto-merging foo.txt
> CONFLICT (content): Merge conflict in foo.txt
>
> $ git status
> On branch master
> Unmerged paths:
>    (use "git reset HEAD <file>..." to unstage)
>    (use "git add <file>..." to mark resolution)
>
>          both modified:      foo.txt
>
> => The advices shown here are OK. Then:
>
> $ git add foo.txt
> $ git status
> On branch master
> Changes to be committed:
>    (use "git reset HEAD <file>..." to unstage)
>
>          modified:   foo.txt
>
> => here, "git status" could have hinted the user "you may now run 'git
> stash drop' if you are satisfied with your merge".
Though I don't know why you think this is important:
> Now, the real question is: when would Git stop showing this advice. I
> don't see a real way to answer this, and I'd rather avoid doing just a
> guess.
If it is really annoying for the user, we can just have a configuration 
parameter to switch this message on/off. I don't know whether git has 
such customizations (in general) currently.

This is very useful (maybe we can agree on wording later):
> One easy thing to do OTOH would be to show a hint at the end of "git
> stash pop"'s output, like
>
> $ git stash pop
> Auto-merging foo.txt
> CONFLICT (content): Merge conflict in foo.txt
> 'stash pop' failed. Please resolve the conflicts manually. The stash
> was not dropped in case you need to restart the operation. When you are
> done resolving the merge, you may run the following to drop the stash reference:
>
>    git stash drop

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 12:14     ` Holger Hellmuth
  2014-02-25 12:33       ` Matthieu Moy
@ 2014-02-26  7:34       ` Omar Othman
  1 sibling, 0 replies; 48+ messages in thread
From: Omar Othman @ 2014-02-26  7:34 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Holger Hellmuth, Brandon McCaig, git


> Am 24.02.2014 17:21, schrieb Matthieu Moy:
>> $ git add foo.txt
>> $ git status
>> On branch master
>> Changes to be committed:
>>    (use "git reset HEAD <file>..." to unstage)
>>
>>          modified:   foo.txt
>
> Maybe status should display a stash count if that count is > 0, as 
> this is part of the state of the repo.
>
> $ git status
> On branch master
> Stashes: 1                         <----------
> Changes to be committed:
>     (use "git reset HEAD <file>..." to unstage)
>
>           modified:   foo.txt
>
> It would be in Omars example case a clear message that git kept the 
> stash. And generally a reminder that there is still a stash around 
> that might or might not be obsolete.
Again, the same comment: If there is a way to customize git's messages 
by turning them on/off (or, even cooler, the ability to change their 
wording) then this is also a nice option to have and we can turn it off 
by default if we find that most people (here at least) don't like it. I 
don't know whether you guys have discussed this option before (or does 
it exist? I doubt, but I don't know), because having such an option (the 
ability to turn messages on/off or change their wording and what 
internal status information they manifest) will really resolve all kinds 
of such potential conflicts of preferences. Even cooler, people will be 
able to change the wording to their native languages for example.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 19:12         ` Junio C Hamano
  2014-02-25 20:48           ` Stephen Leake
@ 2014-02-26  7:37           ` Omar Othman
  2014-02-26 15:17           ` Theodore Ts'o
  2 siblings, 0 replies; 48+ messages in thread
From: Omar Othman @ 2014-02-26  7:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Holger Hellmuth, Brandon McCaig, git


> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> Holger Hellmuth <hellmuth@ira.uka.de> writes:
>>
>>> Am 24.02.2014 17:21, schrieb Matthieu Moy:
>>>> $ git add foo.txt
>>>> $ git status
>>>> On branch master
>>>> Changes to be committed:
>>>>     (use "git reset HEAD <file>..." to unstage)
>>>>
>>>>           modified:   foo.txt
>>> Maybe status should display a stash count if that count is > 0, as
>>> this is part of the state of the repo.
>> Maybe it would help some users, but not me for example. My main use of
>> "git stash" is a safe replacement for "git reset --hard": when I want to
>> discard changes, but keep them safe just in case.
>>
>> So, my stash count is almost always >0, and I don't want to hear about
>> it.
> "status" is about reminding the user what changes are already in the
> index (i.e. what you would commit) and what changes are in the
> working tree, from which you could further update the index with
> (i.e. what you could commit).
>
> One _could_ argue that stashed changes are what could be reflected
> to the working tree and form the source of the latter, but my gut
> feeling is that it is a rather weak argument.  At that point you are
> talking about what you could potentially change in the working tree,
> and the way to do so is not limited to "stash pop" (i.e. you can
> "git cherry-pick --no-commit $a_commit", or "edit" any file in the
> working tree for that matter, with the same ease).
>
> So, I tend to agree with you, while I do understand where "I want to
> know about what is in stash" is coming from (and that is why we do
> have "git stash list" command).
Same comment. Everyone will have his own opinion. As long as the 
messages are not customizable, we can debate for hours and everybody has 
a valid point.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26  7:28           ` Omar Othman
@ 2014-02-26  8:27             ` Matthieu Moy
  2014-02-26 19:36               ` Junio C Hamano
  2014-02-27 13:25               ` Stephen Leake
  0 siblings, 2 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-26  8:27 UTC (permalink / raw)
  To: Omar Othman; +Cc: Brandon McCaig, git

Omar Othman <omar.othman@booking.com> writes:

> Though I don't know why you think this is important:
>> Now, the real question is: when would Git stop showing this advice. I
>> don't see a real way to answer this, and I'd rather avoid doing just a
>> guess.
> If it is really annoying for the user, we can just have a
> configuration parameter to switch this message on/off.

Just saying "You have X stash" is OK to me as long as there is an option
to deactivate it.

Hinting "You should now run "git stash drop"." OTOH is far more dangerous
if guessed wrong. Keeping a stash active when you don't need it does no
real harm, but droping one you actually needed is data loss.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 22:23             ` Junio C Hamano
@ 2014-02-26 10:24               ` Stefan Haller
  2014-02-26 10:45                 ` Matthieu Moy
  0 siblings, 1 reply; 48+ messages in thread
From: Stefan Haller @ 2014-02-26 10:24 UTC (permalink / raw)
  To: Junio C Hamano, Stephen Leake; +Cc: git

Junio C Hamano <gitster@pobox.com> wrote:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
> 
> >> Dropping the stash on a "git add" operation would be really, really
> >> weird...
> >
> > Why? That is when the merge conflicts are resolved, which is what
> > logically indicates that the stash is no longer needed,...
> 
> Not necessarily.  Imagine a case where you used stash to quickly
> save away a tangled mess that was not ready for a logically single
> commit and now you are in the process of creating the first commit
> by applying it piece-by-piece to create multiple resulting ones.
> After you commit the result, you would still want to keep the parts
> of that stashed change you did not include in the first commit so
> that you can go back, no?
> 
> You may run "git add", but that does not say anything about what you
> are going to use the rest of the stash for.  Not even "git commit"
> may be a good enough sign.

But we are only talking about the situation where you typed "git stash
pop", and this resulted in a merge conflict. Your intention was clearly
to drop the stash, it just wasn't dropped because of the conflict.
Dropping it automatically once the conflict is resolved would be nice.

I know it happened to me too that I forgot to drop a stash after
resolving conflicts, so I'd appreciate a feature that somehow does this
automatically for me.


-- 
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 10:24               ` Stefan Haller
@ 2014-02-26 10:45                 ` Matthieu Moy
  2014-02-28  2:57                   ` Stephen Leake
  0 siblings, 1 reply; 48+ messages in thread
From: Matthieu Moy @ 2014-02-26 10:45 UTC (permalink / raw)
  To: Stefan Haller; +Cc: Junio C Hamano, Stephen Leake, git

lists@haller-berlin.de (Stefan Haller) writes:

> Your intention was clearly to drop the stash, it just wasn't dropped
> because of the conflict. Dropping it automatically once the conflict
> is resolved would be nice.

Your intention when you ran "git stash pop", yes. Your intention when
you ran "git add", I call that guessing.

The condition for dropping the stash should be more "conflits
resolutions are done AND the user is happy with it". Otherwise, if you
mess up your conflict resolution, and notice it after running "git add",
then you're screwed because Git just happily discarded your important
data. The point of keeping the stash is to leave it up to the user to
decide between "I'm happy, I can drop" or "I'm not, I should re-apply",
and Git cannot tell which is which.

Hinting the user to run "stash pop" would be more acceptable, but
talking about "git stash" in "git add"'s code is somehow a dependency
order violation (stash is normally implemented on top of Git's basic
features, not the other way around). Does not seem serious from at first
from the user point of view, but this pushes the codebase one step in
the direction of an unmaintainable mess.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 19:12         ` Junio C Hamano
  2014-02-25 20:48           ` Stephen Leake
  2014-02-26  7:37           ` Omar Othman
@ 2014-02-26 15:17           ` Theodore Ts'o
  2 siblings, 0 replies; 48+ messages in thread
From: Theodore Ts'o @ 2014-02-26 15:17 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Matthieu Moy, Holger Hellmuth, Brandon McCaig, Omar Othman, git

On Tue, Feb 25, 2014 at 11:12:10AM -0800, Junio C Hamano wrote:
> So, I tend to agree with you, while I do understand where "I want to
> know about what is in stash" is coming from (and that is why we do
> have "git stash list" command).

One thing that would be nice is if there was built-in "git stash list"
option which only shows the stash items which match the current
branch.  The discussion on this thread inspired me to create the
following:

#!/bin/sh

b=$(git symbolic-ref HEAD | sed -e 's;refs/heads/;;')
git stash list --pretty="%gd %cr on: %s" | grep "WIP on $b" | \
    sed -e "s/ WIP on $b: [0-9a-f]*//"

This results in:

stash@{0} 4 weeks ago on: mke2fs: add make_hugefile feature
stash@{1} 5 weeks ago on: e2fsck, mke2fs: enable octal integers in the profile/config file
stash@{2} 5 weeks ago on: e2fsck, mke2fs: enable octal integers in the profile/config file
stash@{3} 5 weeks ago on: mke2fs: optimize fix_cluster_bg_counts()
stash@{4} 8 weeks ago on: e4defrag: choose the best available posix_fadvise variant
stash@{5} 9 weeks ago on: e2image: add -c option to optimize file system copying for flash devices
stash@{6} 9 weeks ago on: e2image: clean up gcc -Wall and sparse nits
stash@{7} 9 weeks ago on: e2fsck: fix printf conversion specs in ea_refcount.c

(Yes, I have a lot of junk on my git stash; showing the relative time
is going to help my GC what I have left on my git stash list.)

Cheers,

						- Ted

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26  8:27             ` Matthieu Moy
@ 2014-02-26 19:36               ` Junio C Hamano
  2014-02-26 19:46                 ` Matthieu Moy
  2014-02-28  3:00                 ` Stephen Leake
  2014-02-27 13:25               ` Stephen Leake
  1 sibling, 2 replies; 48+ messages in thread
From: Junio C Hamano @ 2014-02-26 19:36 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Omar Othman, Brandon McCaig, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Omar Othman <omar.othman@booking.com> writes:
>
>> Though I don't know why you think this is important:
>>> Now, the real question is: when would Git stop showing this advice. I
>>> don't see a real way to answer this, and I'd rather avoid doing just a
>>> guess.
>> If it is really annoying for the user, we can just have a
>> configuration parameter to switch this message on/off.
>
> Just saying "You have X stash" is OK to me as long as there is an option
> to deactivate it.
>
> Hinting "You should now run "git stash drop"." OTOH is far more dangerous
> if guessed wrong. Keeping a stash active when you don't need it does no
> real harm, but droping one you actually needed is data loss.

Yes, definitely.

I'm inclined to say that we should go in the direction you suggested
earlier in Message-ID: <vpqlhx0a3cb.fsf@anie.imag.fr>, that is:

>> One easy thing to do OTOH would be to show a hint at the end of "git
>> stash pop"'s output, like
>> 
>> $ git stash pop
>> Auto-merging foo.txt
>> CONFLICT (content): Merge conflict in foo.txt
>> 'stash pop' failed. Please, resolve the conflicts manually. The stash
>> was not dropped in case you need to restart the operation. When you are
>> done resolving the merge, you may run the following to drop the stash:
>> 
>>   git stash drop
>> 
>> or so (I couldn't find a concise yet accurate wording).

I'd however have to say that even "please resolve the conflicts
manually" is over-assuming.

I often start some WIP of a fix, realize that the fix should apply
to a lot older maintenance branch than where I happened to have
started the WIP (which typically is at the tip of somebody else's
branch where I received the series from the list---and then noticed
some existing breakage that needs to be fixed), stash the WIP, and
then repeat:

 (1) checkout an old maintenance track;
 (2) try to pop;
 (3) if it succeeds, stop the iteration;
 (4) otherwise, reset and go back to (1) to checkout a bit newer
     maintenance track.

to decide.  So "resolve the conflicts" is assuming the intention of
the user who issued "pop" too much (let alone "manually"---it does
not matter how the user resolves conflicts---the only thing we want
to say is Git did all it would and no further automated help in
resolving is availble, but "manually" is not quite the word).

"The stash was not dropped" is the most important thing in your
additional text.  How about rephrasing like this?

    $ git stash pop
    Auto-merging foo.txt
    CONFLICT (content): Merge conflict in foo.txt

    The stashed change could not be replayed cleanly, leaving
    conflicts in the working tree. The stash was not dropped in case
    you need it again.

    After you are done with the stash, you may want to "git stash
    drop" to discard it.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 19:36               ` Junio C Hamano
@ 2014-02-26 19:46                 ` Matthieu Moy
  2014-02-26 20:20                   ` Junio C Hamano
  2014-02-26 20:33                   ` David Kastrup
  2014-02-28  3:00                 ` Stephen Leake
  1 sibling, 2 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-26 19:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Omar Othman, Brandon McCaig, git

Junio C Hamano <gitster@pobox.com> writes:

> I'd however have to say that even "please resolve the conflicts
> manually" is over-assuming.

I understand your point, but in a short hint message, I still find it
reasonable. Fixing conflicts is the natural way to go after a "stash
pop", and the user who do not want to go this way probably knows why.

> "The stash was not dropped" is the most important thing in your
> additional text.  How about rephrasing like this?
>
>     $ git stash pop
>     Auto-merging foo.txt
>     CONFLICT (content): Merge conflict in foo.txt
>
>     The stashed change could not be replayed cleanly, leaving
>     conflicts in the working tree. The stash was not dropped in case
>     you need it again.
>
>     After you are done with the stash, you may want to "git stash
>     drop" to discard it.

I'm fine with this, but it's even longer than mine which I already found
too long. Perhaps the "leaving conflicts in the working tree" could be
dropped, as the message follows "CONFLICT (content): Merge conflict in
foo.txt".

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 19:46                 ` Matthieu Moy
@ 2014-02-26 20:20                   ` Junio C Hamano
  2014-02-26 20:33                   ` David Kastrup
  1 sibling, 0 replies; 48+ messages in thread
From: Junio C Hamano @ 2014-02-26 20:20 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Omar Othman, Brandon McCaig, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I'd however have to say that even "please resolve the conflicts
>> manually" is over-assuming.
>
> I understand your point, but in a short hint message, I still find it
> reasonable. Fixing conflicts is the natural way to go after a "stash
> pop", and the user who do not want to go this way probably knows why.
>
>> "The stash was not dropped" is the most important thing in your
>> additional text.  How about rephrasing like this?
>>
>>     $ git stash pop
>>     Auto-merging foo.txt
>>     CONFLICT (content): Merge conflict in foo.txt
>>
>>     The stashed change could not be replayed cleanly, leaving
>>     conflicts in the working tree. The stash was not dropped in case
>>     you need it again.
>>
>>     After you are done with the stash, you may want to "git stash
>>     drop" to discard it.
>
> I'm fine with this, but it's even longer than mine which I already found
> too long. Perhaps the "leaving conflicts in the working tree" could be
> dropped, as the message follows "CONFLICT (content): Merge conflict in
> foo.txt".

Surely.  s/was not dropped/is kept/ would make the result even
shorter.

We can also remove the last three lines, for that matter.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 19:46                 ` Matthieu Moy
  2014-02-26 20:20                   ` Junio C Hamano
@ 2014-02-26 20:33                   ` David Kastrup
  2014-02-26 22:17                     ` Junio C Hamano
  1 sibling, 1 reply; 48+ messages in thread
From: David Kastrup @ 2014-02-26 20:33 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Junio C Hamano, Omar Othman, Brandon McCaig, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I'd however have to say that even "please resolve the conflicts
>> manually" is over-assuming.
>
> I understand your point, but in a short hint message, I still find it
> reasonable. Fixing conflicts is the natural way to go after a "stash
> pop", and the user who do not want to go this way probably knows why.
>
>> "The stash was not dropped" is the most important thing in your
>> additional text.  How about rephrasing like this?
>>
>>     $ git stash pop
>>     Auto-merging foo.txt
>>     CONFLICT (content): Merge conflict in foo.txt
>>
>>     The stashed change could not be replayed cleanly, leaving
>>     conflicts in the working tree. The stash was not dropped in case
>>     you need it again.
>>
>>     After you are done with the stash, you may want to "git stash
>>     drop" to discard it.
>
> I'm fine with this, but it's even longer than mine which I already found
> too long. Perhaps the "leaving conflicts in the working tree" could be
> dropped, as the message follows "CONFLICT (content): Merge conflict in
> foo.txt".

All that verbosity...

$ git stash pop
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Cowardly refusing to drop stash.
$

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 20:33                   ` David Kastrup
@ 2014-02-26 22:17                     ` Junio C Hamano
  2014-02-27  0:19                       ` David Kastrup
  0 siblings, 1 reply; 48+ messages in thread
From: Junio C Hamano @ 2014-02-26 22:17 UTC (permalink / raw)
  To: David Kastrup; +Cc: Matthieu Moy, Omar Othman, Brandon McCaig, git

David Kastrup <dak@gnu.org> writes:

> All that verbosity...
>
> $ git stash pop
> Auto-merging foo.txt
> CONFLICT (content): Merge conflict in foo.txt
> Cowardly refusing to drop stash.
> $

Actually, modulo "Cowardly", that may be the most harmless phrasing,
as apply_stash may try to signal an error for reasons not related to
an inability to apply the change cleanly (e.g. we may have failed to
refresh the index).

Whatever phrasing we may end up choosing, the change itself should
be trivial in any case.

 git-stash.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index f0a94ab..4798bcf 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -512,8 +512,14 @@ apply_stash () {
 pop_stash() {
 	assert_stash_ref "$@"
 
-	apply_stash "$@" &&
-	drop_stash "$@"
+	if apply_stash "$@"
+	then
+		drop_stash "$@"
+	else
+		status=$?
+		say "The stash is kept in case you need it again."
+		exit $status
+	fi
 }
 
 drop_stash () {

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 22:17                     ` Junio C Hamano
@ 2014-02-27  0:19                       ` David Kastrup
  0 siblings, 0 replies; 48+ messages in thread
From: David Kastrup @ 2014-02-27  0:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Omar Othman, Brandon McCaig, git

Junio C Hamano <gitster@pobox.com> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> All that verbosity...
>>
>> $ git stash pop
>> Auto-merging foo.txt
>> CONFLICT (content): Merge conflict in foo.txt
>> Cowardly refusing to drop stash
>> $
>
> Actually, modulo "Cowardly", that may be the most harmless phrasing,
> as apply_stash may try to signal an error for reasons not related to
> an inability to apply the change cleanly (e.g. we may have failed to
> refresh the index).

Without "Cowardly", the capriciosity of "refusing" does not make much
sense.  The error message is a tribute to GNU tar:
dak@lola:/tmp$ mkdir x
dak@lola:/tmp$ tar cfz x
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
dak@lola:/tmp$ 

The boring variant would be

$ git stash pop
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Not dropping stash
$

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-25 22:20             ` Junio C Hamano
@ 2014-02-27 13:18               ` Stephen Leake
  0 siblings, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-27 13:18 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>>> One _could_ argue that stashed changes are what could be reflected
>>> to the working tree and form the source of the latter, but my gut
>>> feeling is that it is a rather weak argument.  At that point you are
>>> talking about what you could potentially change in the working tree,
>>
>> No, I saved things in the stash on purpose. For example, I had changes
>> that were not ready to commit, but I wanted to do a merge from upstream.
>
> I often save things by running "git diff >P.diff" on purpose.

Ok. How is that better than 'git stash save'?

> Should "git status" read these patches and tell me what paths I
> could change in the working tree by applying it?  

No, 'git stash save' appears to be the method git provides to do this,
so it is the only one that git needs to support.

(The content of 'P.diff' already tells you what paths are modified, as
does 'git stash show')

But I am new to git, so I could just be missing the point.

>Where does it end?

Where we agree it ends :).

>> There are workflows where the stash is not important; provide an option
>> to 'git status' that means "ignore stash". 
>
> How is that different to tell those who want to know what are in the
> stash to type "git stash list" when they want to learn that
> information?

You are correct, this is a question of style. The question is:

Which style is best for git, considering the needs of newbies and
seasoned users?

As a newbie, I find these things confusing:

- the stash status is not displayed by 'git status'

- 'git add' does not report that all pending merge conflicts are now
resolved.

I'm sure I will discover other confusing things in the future :).


I am a seasoned user of CM systems in general; in all cases, I have
customized an Emacs front-end to do _exactly_ what I want, rather than
relying on the command line tools directly. So I have a rather extreme
perspective on this :). I do rely on the command line tools while
learning a new CM system.

In general, I expect seasoned users to be more accepting of the need to
provide additional options to customize the tools to their workflow.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26  0:39     ` Simon Ruderich
@ 2014-02-27 13:22       ` Stephen Leake
  0 siblings, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-27 13:22 UTC (permalink / raw)
  To: git

Simon Ruderich <simon@ruderich.org> writes:

> On Mon, Feb 24, 2014 at 05:21:40PM +0100, Matthieu Moy wrote:
>> One easy thing to do OTOH would be to show a hint at the end of "git
>> stash pop"'s output, like
>
> I think that's a good idea. It makes it obvious that Git has kept
> the stash and that the user should drop it when he's done - if he
> wants to.

+1

This does not mean I don't _also_ think 'git add' dropping the stash
when the last conflict is resolved is a good idea. If that is
implemented, 'stash pop' might have to mention that effect as well; that
does make things more complicated.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26  8:27             ` Matthieu Moy
  2014-02-26 19:36               ` Junio C Hamano
@ 2014-02-27 13:25               ` Stephen Leake
  1 sibling, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-27 13:25 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Omar Othman <omar.othman@booking.com> writes:
>
>> Though I don't know why you think this is important:
>>> Now, the real question is: when would Git stop showing this advice. I
>>> don't see a real way to answer this, and I'd rather avoid doing just a
>>> guess.
>> If it is really annoying for the user, we can just have a
>> configuration parameter to switch this message on/off.
>
> Just saying "You have X stash" is OK to me as long as there is an option
> to deactivate it.

+1

> Hinting "You should now run "git stash drop"." OTOH is far more dangerous
> if guessed wrong. Keeping a stash active when you don't need it does no
> real harm, but droping one you actually needed is data loss.

I agree giving possibly incorrect advice is bad.

Can you construct a use case where git will give incorrect advice? 

I don't know git well enough to do that, nor to assert that it will never
happen. 

I think we need a more concrete proposal to move this forward.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 10:45                 ` Matthieu Moy
@ 2014-02-28  2:57                   ` Stephen Leake
  2014-02-28  4:50                     ` Brandon McCaig
  2014-02-28 17:45                     ` Junio C Hamano
  0 siblings, 2 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-28  2:57 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> lists@haller-berlin.de (Stefan Haller) writes:
>
>> Your intention was clearly to drop the stash, it just wasn't dropped
>> because of the conflict. Dropping it automatically once the conflict
>> is resolved would be nice.
>
> Your intention when you ran "git stash pop", yes. Your intention when
> you ran "git add", I call that guessing.

You might be adding other files for other reasons. But if you add a file
that does resolve a conflict caused by 'git stash pop', it is not
guessing.

> The condition for dropping the stash should be more "conflits
> resolutions are done AND the user is happy with it". Otherwise, if you
> mess up your conflict resolution, and notice it after running "git add",
> then you're screwed because Git just happily discarded your important
> data. The point of keeping the stash is to leave it up to the user to
> decide between "I'm happy, I can drop" or "I'm not, I should re-apply",
> and Git cannot tell which is which.

Yes, that makes sense.

> Hinting the user to run "stash pop" would be more acceptable, but
> talking about "git stash" in "git add"'s code is somehow a dependency
> order violation (stash is normally implemented on top of Git's basic
> features, not the other way around). Does not seem serious from at first
> from the user point of view, but this pushes the codebase one step in
> the direction of an unmaintainable mess.

Also makes sense.

So "git add" and "git stash *" are lower level tools; to get the effect
we are asking for, we should use a front-end (which is why I'm writing
one for Emacs :).

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-26 19:36               ` Junio C Hamano
  2014-02-26 19:46                 ` Matthieu Moy
@ 2014-02-28  3:00                 ` Stephen Leake
  1 sibling, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-28  3:00 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> ...  So "resolve the conflicts" is assuming the intention of
> the user who issued "pop" too much (let alone "manually"---it does
> not matter how the user resolves conflicts---the only thing we want
> to say is Git did all it would and no further automated help in
> resolving is availble, but "manually" is not quite the word).

+1

> "The stash was not dropped" is the most important thing in your
> additional text.  How about rephrasing like this?
>
>     $ git stash pop
>     Auto-merging foo.txt
>     CONFLICT (content): Merge conflict in foo.txt
>
>     The stashed change could not be replayed cleanly, leaving
>     conflicts in the working tree. The stash was not dropped in case
>     you need it again.
>
>     After you are done with the stash, you may want to "git stash
>     drop" to discard it.

+1

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28  2:57                   ` Stephen Leake
@ 2014-02-28  4:50                     ` Brandon McCaig
  2014-02-28 15:12                       ` Stephen Leake
  2014-02-28 17:45                     ` Junio C Hamano
  1 sibling, 1 reply; 48+ messages in thread
From: Brandon McCaig @ 2014-02-28  4:50 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephan:

On Thu, Feb 27, 2014 at 9:57 PM, Stephen Leake
<stephen_leake@stephe-leake.org> wrote:
> You might be adding other files for other reasons. But if you add a file
> that does resolve a conflict caused by 'git stash pop', it is not
> guessing.

Staging a file doesn't tell git that you resolved a conflict. Git will
happily accept a blob full of conflict markers. Git doesn't know the
difference. Git expects the user to know what is right. The user has
the freedom to manipulate the index as they see fit, which means both
adding and removing from it anytime they wish.

> So "git add" and "git stash *" are lower level tools; to get the effect
> we are asking for, we should use a front-end (which is why I'm writing
> one for Emacs :).

You *can* use a front end, but I would argue that you shouldn't
necessarily. Most third-party front ends only serve to confuse users.
In general, they only cause problems and encourage ignorance.

Git is a very pure system. It doesn't impose too may rules on you. It
basically just gives you the tools that you need to work within the
system and gets out of your way. It is up to the user to learn how to
assemble those tools for good (and many front ends exist to help;
sometimes arguably too many as it is, such as git-pull(1) for
example).

 This isn't a case of the API being wrong. This is a case of PEBKAC,
IMO. Maybe the API can be a little bit more verbose in assisting the
user to understand what has happened and what sensible options there
are, but we should avoid catering to newbies too much. You should only
be a newbie for a short time. After that you should begin to learn the
API. Hand holding at that point would be noise (as it would for most
of us here, I imagine). The worst kind of "hand holding" is the kind
that imposes rules on you that aren't universal. Dropping the stash
after adding all changes to the index after a failed pop is not
universal. At most, git stash pop should give the user a bit more
guidance to understand what the situation is. At least, the user
should RTFM and learn to use the tools. And that might involve some
mistakes, but you learn from mistakes. At least Git does a good job of
making it easy to recover from most of your mistakes. The proposed
change to git-add takes away one of those safety nets.

Git isn't always the easiest thing to wrap your head around, but I
have found that once you have wrapped your head around it Git is the
easiest thing to get the job done the way you want. I consider the
learning curve a strength of Git. Which isn't to say that there isn't
room for improvement, but when proposing improvements we should try to
make sure that they actually make things universally better.

Regards,


-- 
Brandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28  4:50                     ` Brandon McCaig
@ 2014-02-28 15:12                       ` Stephen Leake
  2014-02-28 15:42                         ` Matthieu Moy
  2014-02-28 16:02                         ` David Kastrup
  0 siblings, 2 replies; 48+ messages in thread
From: Stephen Leake @ 2014-02-28 15:12 UTC (permalink / raw)
  To: git

Brandon McCaig <bamccaig@gmail.com> writes:

> On Thu, Feb 27, 2014 at 9:57 PM, Stephen Leake
> <stephen_leake@stephe-leake.org> wrote:
>> You might be adding other files for other reasons. But if you add a file
>> that does resolve a conflict caused by 'git stash pop', it is not
>> guessing.
>
> Staging a file doesn't tell git that you resolved a conflict. Git will
> happily accept a blob full of conflict markers. Git doesn't know the
> difference. Git expects the user to know what is right. The user has
> the freedom to manipulate the index as they see fit, which means both
> adding and removing from it anytime they wish.

But git has a notion of "unresolved conflict". For example, when I have
conflicts from a 'git stash pop', 'git status' shows:

stephe@takver$ git status
# On branch master
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#	both modified:      CommandBasedAutonomous.java
#	both modified:      DriveByInches.java
#
# ...

How does it know those files are "unmerged"? I'm guessing it has
recorded the fact that they had conflicts. Where does it record that?

In fact, at this point, I have edited CommandBasedAutonomous.java to
resolve the conflicts. But git apparently doesn't know that.

So I do 'git add CommandBasedAutonomous.java', then 'git status':

stephe@takver$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   AerialAssist2014/src/org/usfirst/frc1939/AerialAssist2014/commands/CommandBasedAutonomous.java
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#	both modified:      AerialAssist2014/src/org/usfirst/frc1939/AerialAssist2014/commands/DriveByInches.java

And git thinks that file is now "merged".

So it appears that adding a file _does_ tell git that the conflict is
resolved.

Or am I still missing something?


>> So "git add" and "git stash *" are lower level tools; to get the effect
>> we are asking for, we should use a front-end (which is why I'm writing
>> one for Emacs :).
>
> You *can* use a front end, but I would argue that you shouldn't
> necessarily. Most third-party front ends only serve to confuse users.
> In general, they only cause problems and encourage ignorance.

Won't happen here; I'm writing it. It may confuse other people, but
not me :).

> Git is a very pure system.

Hmm. We'll have to disagree on that. git gives the impression of having
grown organically for quite a while, and therefore suffers from changing
and competing design paradigms and conflicting requirements due to
preserving backward compatiblity.

monotone is much cleaner, since it has had very few design paradigm
changes, and they were implemented cleanly, without preserving backward
compatibility. monotone is not as flexible as git, but what I've seen so
far could be added to monotone (I don't think it ever will be; monotone
is dying as a project).

We are probably using different definitions of "pure" here.

> It is up to the user to learn how to assemble those tools for
> good (and many front ends exist to help; sometimes arguably too many
> as it is, such as git-pull(1) for example).

Yes. Which is why we are discussing how much help git should be while
still learning the rules.

>  This isn't a case of the API being wrong. This is a case of PEBKAC,
> IMO.

(wikipedia to the rescue; PEBKAC = "operator error")

Yes, I'm not using it correctly, because I don't understand it yet.
That's the definition of "newbie".

> Dropping the stash after adding all changes to the index after a
> failed pop is not universal.

Not universal, but it appears to be very common; it is certainly what I
expect, as a newbie. So it could be the default as long as there is a
configuration option to have it not do that.

I _did_ "RTFM" (specifically the man page on 'git stash', and before
that the git book at http://git-scm.com/documentation (which did not
mention stash)); it did not explain the full cycle of how to resolve
conflicts after stash pop.

Perhaps there is a different manual that I could read instead?

In particular, one that explains what "unmerged paths" means in the 'git
status' output? The 'git-status' man page does not do that.

--
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 15:12                       ` Stephen Leake
@ 2014-02-28 15:42                         ` Matthieu Moy
  2014-02-28 17:27                           ` Stephen Leake
  2014-02-28 16:02                         ` David Kastrup
  1 sibling, 1 reply; 48+ messages in thread
From: Matthieu Moy @ 2014-02-28 15:42 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> So it appears that adding a file _does_ tell git that the conflict is
> resolved.

Yes it does. Git _knows_ that you consider the conflict to be resolved.
It cannot know how happy you are with the result.

Similarly, in a conflicted merge, the last "git add" does not trigger a
commit silently. And a silent commit would be much less serious than a
silent data drop.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 15:12                       ` Stephen Leake
  2014-02-28 15:42                         ` Matthieu Moy
@ 2014-02-28 16:02                         ` David Kastrup
  2014-02-28 17:45                           ` Stephen Leake
  1 sibling, 1 reply; 48+ messages in thread
From: David Kastrup @ 2014-02-28 16:02 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Brandon McCaig <bamccaig@gmail.com> writes:
>
>> On Thu, Feb 27, 2014 at 9:57 PM, Stephen Leake
>> <stephen_leake@stephe-leake.org> wrote:
>>> You might be adding other files for other reasons. But if you add a file
>>> that does resolve a conflict caused by 'git stash pop', it is not
>>> guessing.
>>
>> Staging a file doesn't tell git that you resolved a conflict. Git will
>> happily accept a blob full of conflict markers. Git doesn't know the
>> difference. Git expects the user to know what is right. The user has
>> the freedom to manipulate the index as they see fit, which means both
>> adding and removing from it anytime they wish.
>
> But git has a notion of "unresolved conflict".

Not really.  It has a notion of "unmerged path".

> For example, when I have conflicts from a 'git stash pop', 'git
> status' shows:
>
> stephe@takver$ git status
> # On branch master
> # Unmerged paths:
> #   (use "git reset HEAD <file>..." to unstage)
> #   (use "git add/rm <file>..." as appropriate to mark resolution)
> #
> #	both modified:      CommandBasedAutonomous.java
> #	both modified:      DriveByInches.java
> #
> # ...
>
> How does it know those files are "unmerged"? I'm guessing it has
> recorded the fact that they had conflicts. Where does it record that?

The index contains the unmerged versions of the file.  Possibly also the
version with conflict markers, but it's been too long since I last
checked.

After "git add", there is only one version in the index.

If you apply a stash with unmerged paths to a worktree/index, possibly
containing unmerged paths of its own, possibly getting new unmerged
paths by failing to apply the stash, you get unmerged paths from several
different unresolved conflicts.

Git has no idea about the history of unmerged paths.  So having "git
add" modify the operation of "git reset" whenever "git add" overwrites
an unmerged path in the index could lead to quite funny results.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 15:42                         ` Matthieu Moy
@ 2014-02-28 17:27                           ` Stephen Leake
  2014-02-28 19:45                             ` Matthieu Moy
  0 siblings, 1 reply; 48+ messages in thread
From: Stephen Leake @ 2014-02-28 17:27 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> So it appears that adding a file _does_ tell git that the conflict is
>> resolved.
>
> Yes it does. Git _knows_ that you consider the conflict to be resolved.
> It cannot know how happy you are with the result.
>
> Similarly, in a conflicted merge, the last "git add" does not trigger a
> commit silently. And a silent commit would be much less serious than a
> silent data drop.

Ok, I see your point now.

So a message "merge complete; you can drop the stash" would be the most
git should do.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 16:02                         ` David Kastrup
@ 2014-02-28 17:45                           ` Stephen Leake
  2014-02-28 19:39                             ` Matthieu Moy
  0 siblings, 1 reply; 48+ messages in thread
From: Stephen Leake @ 2014-02-28 17:45 UTC (permalink / raw)
  To: git

David Kastrup <dak@gnu.org> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> Brandon McCaig <bamccaig@gmail.com> writes:
>>
>>> On Thu, Feb 27, 2014 at 9:57 PM, Stephen Leake
>>> <stephen_leake@stephe-leake.org> wrote:
>>>> You might be adding other files for other reasons. But if you add a file
>>>> that does resolve a conflict caused by 'git stash pop', it is not
>>>> guessing.
>>>
>>> Staging a file doesn't tell git that you resolved a conflict. Git will
>>> happily accept a blob full of conflict markers. Git doesn't know the
>>> difference. Git expects the user to know what is right. The user has
>>> the freedom to manipulate the index as they see fit, which means both
>>> adding and removing from it anytime they wish.
>>
>> But git has a notion of "unresolved conflict".
>
> Not really.  It has a notion of "unmerged path".
>
> <snip>

> The index contains the unmerged versions of the file.  Possibly also the
> version with conflict markers, but it's been too long since I last
> checked.

Paraphrasing, is this correct? 

    "the index contains both versions of the unmerged file; any file
     with more than one version in the index is unmerged".

So what 'git add' does in this case is replace both versions of the file
in the index with a new version.

I was not aware that the git system could support more than one version
of a file in one branch. That makes it more like monotone :).

> If you apply a stash with unmerged paths to a worktree/index, possibly
> containing unmerged paths of its own, possibly getting new unmerged
> paths by failing to apply the stash, you get unmerged paths from several
> different unresolved conflicts.

Yes; doing too many things at once is a bad idea. But that should never
cause git to lose data or do something wrong.

At the same time, it seems all unmerged paths result from unresolved
merge conflicts, so the two notions are equivalent for git?

> Git has no idea about the history of unmerged paths.  So having "git
> add" modify the operation of "git reset" whenever "git add" overwrites
> an unmerged path in the index could lead to quite funny results.

Ok; I'll take that as describing a large class of "bad thing" use cases.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28  2:57                   ` Stephen Leake
  2014-02-28  4:50                     ` Brandon McCaig
@ 2014-02-28 17:45                     ` Junio C Hamano
  2014-03-01  8:47                       ` Stephen Leake
  1 sibling, 1 reply; 48+ messages in thread
From: Junio C Hamano @ 2014-02-28 17:45 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> lists@haller-berlin.de (Stefan Haller) writes:
>>
>>> Your intention was clearly to drop the stash, it just wasn't dropped
>>> because of the conflict. Dropping it automatically once the conflict
>>> is resolved would be nice.
>>
>> Your intention when you ran "git stash pop", yes. Your intention when
>> you ran "git add", I call that guessing.
>
> You might be adding other files for other reasons. But if you add a file
> that does resolve a conflict caused by 'git stash pop', it is not
> guessing.

The only thing you know for sure is that the user has consumed _one_
part of the stashed change, no?  What if the stash had changes for
more than one path?

At the time of "git add $path", can you reliably tell if the
conflict to the $path the user is resolving came from a previous
"git stash pop", not from any other mergy operations, e.g. "git
stash apply" or "git apply -3"?

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 17:45                           ` Stephen Leake
@ 2014-02-28 19:39                             ` Matthieu Moy
  0 siblings, 0 replies; 48+ messages in thread
From: Matthieu Moy @ 2014-02-28 19:39 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> I was not aware that the git system could support more than one version
> of a file in one branch. 

The index only. The history itself does not.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 17:27                           ` Stephen Leake
@ 2014-02-28 19:45                             ` Matthieu Moy
  2014-03-01  8:41                               ` Stephen Leake
  0 siblings, 1 reply; 48+ messages in thread
From: Matthieu Moy @ 2014-02-28 19:45 UTC (permalink / raw)
  To: Stephen Leake; +Cc: git

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> So a message "merge complete; you can drop the stash" would be the most
> git should do.

>From the user experience point of view, that would be good. It could
bother some users, but we have advice.* to silent this kind of warnings.

>From the implementation point of view, it's much harder than it seems
because as other pointed out, Git does not know that the merge conflicts
comes from, so as it is, the best it could say is "merge complete; you
can now proceed". Thas is a solvable problem (git stash could leave a
file like .git/conflicted-stash, and git add could look for this file
and remove it), but I can't think of an implementation that would not be
really awful. For example, "git reset" should also remove the file, and in
general a substancial subset of Git's command would need to be aware of
the status of git stash.

So, I wouldn't object, but I don't think the implementation cost is
worth the benefit.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 19:45                             ` Matthieu Moy
@ 2014-03-01  8:41                               ` Stephen Leake
  0 siblings, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-03-01  8:41 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> So a message "merge complete; you can drop the stash" would be the most
>> git should do.
>
> From the user experience point of view, that would be good. It could
> bother some users, but we have advice.* to silent this kind of warnings.
>
> <snip explanation of implementation issues>
>
> So, I wouldn't object, but I don't think the implementation cost is
> worth the benefit.

Ok, that makes sense.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
  2014-02-28 17:45                     ` Junio C Hamano
@ 2014-03-01  8:47                       ` Stephen Leake
  0 siblings, 0 replies; 48+ messages in thread
From: Stephen Leake @ 2014-03-01  8:47 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>>
>>> lists@haller-berlin.de (Stefan Haller) writes:
>>>
>>>> Your intention was clearly to drop the stash, it just wasn't dropped
>>>> because of the conflict. Dropping it automatically once the conflict
>>>> is resolved would be nice.
>>>
>>> Your intention when you ran "git stash pop", yes. Your intention when
>>> you ran "git add", I call that guessing.
>>
>> You might be adding other files for other reasons. But if you add a file
>> that does resolve a conflict caused by 'git stash pop', it is not
>> guessing.
>
> The only thing you know for sure is that the user has consumed _one_
> part of the stashed change, no?  What if the stash had changes for
> more than one path?

Count the unmerged paths in the index; when the count is zero, all
conflicts are resolved.

paths in the stash that had no conflicts are already in the index.

So _if_ there is nothing going on except finishing the stash pop, an
unmerged path count of zero means you are done with the stash, and it
can be dropped.

> At the time of "git add $path", can you reliably tell if the
> conflict to the $path the user is resolving came from a previous
> "git stash pop", not from any other mergy operations, e.g. "git
> stash apply" or "git apply -3"?

This is the real problem. I can impose a rule on my team of "don't do
more than one merge at a time" by implementing that in the front-end,
but git can't assume that.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: `git stash pop` UX Problem
@ 2014-02-27 11:23 Damien Robert
  0 siblings, 0 replies; 48+ messages in thread
From: Damien Robert @ 2014-02-27 11:23 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy, Brandon McCaig, Omar Othman

Matthieu Moy  wrote in message <vpqzjlf5q2z.fsf@anie.imag.fr>:
>> Maybe status should display a stash count if that count is > 0, as
>> this is part of the state of the repo.
> Maybe it would help some users, but not me for example. My main use of
> "git stash" is a safe replacement for "git reset --hard": when I want to
> discard changes, but keep them safe just in case.
> So, my stash count is almost always >0, and I don't want to hear about
> it.

Related to your comment, I adapted git-stash
  https://gist.github.com/DamienRobert/9227034
to have the following (mis)features:

- There is a global --ref option that allows to specify the reference the
  stash will use (by default this is refs/mystash, git-stash.sh uses
  refs/stash).

  This allows to differenciate between different uses of stashes: save WIP
  before switching branch; keep a backup before a git reset;...

- There is a new command `git mystash dosave` that works like git stash but
  does not reset the worktree afterwards. Note that `git stash create`
  already does that, but it handles options differently than `git stash
  save`. `git mystash dosave` can be seen as a wrapper around `git stash
  create`.
  The reason is that while `git stash create` is intended for scripts, `git
  mystash dosave` is intended for the UI. One example of when we don't want
  to drop the worktree is when we want to do a `git checkout -m -- paths`
  but we want to save the current state in case the merge has conflicts.

- `git stash branch` pops the stash once the branch is created. I did not
  like this feature so `git mystash branch` does not pop the stash; use `git
  mystash popbranch` to have the original meaning of `git stash branch`.

- `git mystash save` (and `git stash dosave`) has a new option
  `--on-branch` which stores the stash onto the current branch rather than
  in $ref_stash. The idea is that when I use `git stash` for a WIP, then
  when I come back to the original branch I always forget that I had a
  stash for this branch, and if there were several WIP in between it can be
  hard to remember which stash to apply. With `--on-branch`, when I come
  back to the original branch I am now on the stash, and I know I just need
  to apply it. For that `git mystash apply` (or `git mystash pop`) also has
  a `--on-branch` option that tells it to use the stash on the current
  branch.

- `git mystash info` gives informations about a stash.

So obviously not all of these would be good for inclusion into git, but
maybe some of them would be somewhat worth it. When I have the time I'll
try to write tests and send proper patches.

-- 
Damien Robert

^ permalink raw reply	[flat|nested] 48+ messages in thread

* `git stash pop` UX Problem
@ 2014-02-24  8:33 Omar Othman
  0 siblings, 0 replies; 48+ messages in thread
From: Omar Othman @ 2014-02-24  8:33 UTC (permalink / raw)
  To: git

Hi there,

I'm fairly new to git and I wanted to ask about a certain behavior
that I want to fix myself (if you agree with me that it is a
misbehavior)... since I've never contributed to open source and it'll
be an important step for me to start and get something done.

In general, whenever something a user "should" do, git always tells.
So, for example, when things go wrong with a merge, you have the
option to abort. When you are doing a rebase, git tells you to do git
commit --amend, and then git rebase --continue... and so on.

The point is: Because of this, git is expected to always instruct you
on what to do next in a multilevel operation, or instructing you what
to do when an operation has gone wrong.

Now comes the problem. When you do a git stash pop, and a merge
conflict happens, git correctly tells you to fix the problems and then
git add to resolve the conflict. But once that happens, and the
internal status of git tells you that there are no more problems (I
have a prompt that tells me git's internal status), the operation is
not culminated by dropping the stash reference, which what normally
happens automatically after a git stash pop. This has actually
confused me for a lot of time, till I ran into a git committer and
asked him, and only then were I 100% confident that I did nothing
wrong and it is indeed a UX problem. I wasted a lot of time to know
why the operation is not completed as expected (since I trusted that
git just does the right thing), and it turned out that it is git's
fault.

If this is accepted, please reply to this email and tell me to start
working on it. I've read the Documenation/SubmittingPatches
guidelines, but I'll appreciate also telling me where to base my
change. My guess is maint, since it's a "bug" in the sense of UX.

Thanks and sorry for the long email.

-- 
Best Regards,

Omar Othman

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2014-03-01  8:48 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24  8:32 `git stash pop` UX Problem Omar Othman
2014-02-24 16:04 ` Brandon McCaig
2014-02-24 16:21   ` Matthieu Moy
2014-02-25 12:14     ` Holger Hellmuth
2014-02-25 12:33       ` Matthieu Moy
2014-02-25 13:02         ` Omar Othman
2014-02-25 19:12         ` Junio C Hamano
2014-02-25 20:48           ` Stephen Leake
2014-02-25 22:20             ` Junio C Hamano
2014-02-27 13:18               ` Stephen Leake
2014-02-26  7:37           ` Omar Othman
2014-02-26 15:17           ` Theodore Ts'o
2014-02-25 23:50         ` brian m. carlson
2014-02-26  7:34       ` Omar Othman
2014-02-26  0:39     ` Simon Ruderich
2014-02-27 13:22       ` Stephen Leake
2014-02-25 13:06   ` Omar Othman
2014-02-25 13:15     ` Matthieu Moy
2014-02-25 14:12       ` Omar Othman
2014-02-25 15:25         ` Matthieu Moy
2014-02-25 20:52           ` Stephen Leake
2014-02-25 22:23             ` Junio C Hamano
2014-02-26 10:24               ` Stefan Haller
2014-02-26 10:45                 ` Matthieu Moy
2014-02-28  2:57                   ` Stephen Leake
2014-02-28  4:50                     ` Brandon McCaig
2014-02-28 15:12                       ` Stephen Leake
2014-02-28 15:42                         ` Matthieu Moy
2014-02-28 17:27                           ` Stephen Leake
2014-02-28 19:45                             ` Matthieu Moy
2014-03-01  8:41                               ` Stephen Leake
2014-02-28 16:02                         ` David Kastrup
2014-02-28 17:45                           ` Stephen Leake
2014-02-28 19:39                             ` Matthieu Moy
2014-02-28 17:45                     ` Junio C Hamano
2014-03-01  8:47                       ` Stephen Leake
2014-02-26  7:28           ` Omar Othman
2014-02-26  8:27             ` Matthieu Moy
2014-02-26 19:36               ` Junio C Hamano
2014-02-26 19:46                 ` Matthieu Moy
2014-02-26 20:20                   ` Junio C Hamano
2014-02-26 20:33                   ` David Kastrup
2014-02-26 22:17                     ` Junio C Hamano
2014-02-27  0:19                       ` David Kastrup
2014-02-28  3:00                 ` Stephen Leake
2014-02-27 13:25               ` Stephen Leake
2014-02-24  8:33 Omar Othman
2014-02-27 11:23 Damien Robert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.