git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git automatic stashing?
       [not found] <AANLkTim3MacQK6EtTPNJsYbqb=5bOM3W3BXC6p=hT+PU@mail.gmail.com>
@ 2010-11-09  5:37 ` Casey McGinty
  2010-11-09  7:49   ` Matthieu Moy
  2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
  0 siblings, 2 replies; 7+ messages in thread
From: Casey McGinty @ 2010-11-09  5:37 UTC (permalink / raw)
  To: git

Is there any feature in git to perform and auto stash apply/pop when
trying to do a merge/rebase in a dirty working dir? This would save
some keystrokes from time-to-time, and make it easier for new users
unfamiliar with git.

Regards,
Casey McGinty

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

* Re: Git automatic stashing?
  2010-11-09  5:37 ` Git automatic stashing? Casey McGinty
@ 2010-11-09  7:49   ` Matthieu Moy
  2010-11-09 12:02     ` Martin von Zweigbergk
  2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
  1 sibling, 1 reply; 7+ messages in thread
From: Matthieu Moy @ 2010-11-09  7:49 UTC (permalink / raw)
  To: Casey McGinty; +Cc: git

Casey McGinty <casey.mcginty@gmail.com> writes:

> Is there any feature in git to perform and auto stash apply/pop when
> trying to do a merge/rebase in a dirty working dir? This would save
> some keystrokes from time-to-time, and make it easier for new users
> unfamiliar with git.

I agree with the keystrokes part, but not with the fact that it would
make it easier in general. In the sequence

git stash
git merge
git stash pop

conflicts can occur in 2 distinct places. One can easily forsee this
senario occuring:

git stash
git merge
# fix conflicts
# git commit
# forget to do the action needed to get the "git stash pop"

and voila, you've just lost data.

Actually, what I'd like to see would be this feature, but limited to
the case where the merge is a fast-forward, because then, only the
last action of the sequence could possibly leave conflict, so Git
could finish with a message like "please fix conflicts and continue
working". Actually, this is not far from what "git checout -m" is
doing.

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

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

* Re: Git automatic stashing?
  2010-11-09  7:49   ` Matthieu Moy
@ 2010-11-09 12:02     ` Martin von Zweigbergk
  0 siblings, 0 replies; 7+ messages in thread
From: Martin von Zweigbergk @ 2010-11-09 12:02 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Casey McGinty, git

On Tue, Nov 9, 2010 at 2:49 AM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Casey McGinty <casey.mcginty@gmail.com> writes:
>
>> Is there any feature in git to perform and auto stash apply/pop when
>> trying to do a merge/rebase in a dirty working dir? This would save
>> some keystrokes from time-to-time, and make it easier for new users
>> unfamiliar with git.
>
> I agree with the keystrokes part, but not with the fact that it would
> make it easier in general. In the sequence
>
> git stash
> git merge
> git stash pop
>
> conflicts can occur in 2 distinct places. [...]

Correct me if I'm wrong, but I think git will only stop you from
performing a merge if it would involve touching any of your dirty files,
so in the case of merge, I agree with Matthieu that temporarily stashing
your changes would probably just increase the risk of confusing the
user.

However, in the case of rebase, git will not let you rebase if *any*
file is dirty. So, in this case of rebase, there are often cases where
git prevents a rebase that could have been a stash + rebase + stash pop
without any conflicts in the pop step.

I know that the fact that 'git rebase' (usually in the form of a
'git pull' configured for rebase on the current branch) forces the user
to temporarily stash his changes has been somewhat annoying to some of
my colleagues.

I actually implemented support for stashing changes using 'stash create'
and 'stash apply', but only for non-interactive rebase. The implentation
supports a '--stash' argument and a 'rebase.stash' configuration. I am
currently working on refactoring git-rebase.sh and
git-rebase--interactive.sh, but once that's done, I will post an updated
version of the 'git rebase --stash' patch(es).

I later found out that this seems to have been attempted at least twice
before. The first time by Junio in 6c9ad16 (rebase: allow starting from
a dirty tree., 2007-07-09). This was later reverted. I think it was
reverted because the stashing was not optional.

Some months later, Simon Sasburg sent some patches on the same subject,
see http://thread.gmane.org/gmane.comp.version-control.git/63007/. These
patches don't see to have been accepted, but I'm not sure why.

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

* Re: Git automatic stashing?
  2010-11-09  5:37 ` Git automatic stashing? Casey McGinty
  2010-11-09  7:49   ` Matthieu Moy
@ 2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
  2010-11-09 12:58     ` Martin von Zweigbergk
  2010-11-09 19:12     ` Matthieu Moy
  1 sibling, 2 replies; 7+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-11-09 12:36 UTC (permalink / raw)
  To: Casey McGinty; +Cc: git

On Tue, Nov 9, 2010 at 12:37 PM, Casey McGinty <casey.mcginty@gmail.com> wrote:
> Is there any feature in git to perform and auto stash apply/pop when
> trying to do a merge/rebase in a dirty working dir? This would save
> some keystrokes from time-to-time, and make it easier for new users
> unfamiliar with git.

And when switching branches too.
-- 
Duy

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

* Re: Git automatic stashing?
  2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
@ 2010-11-09 12:58     ` Martin von Zweigbergk
  2010-11-09 19:12     ` Matthieu Moy
  1 sibling, 0 replies; 7+ messages in thread
From: Martin von Zweigbergk @ 2010-11-09 12:58 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Casey McGinty, git

On Tue, Nov 9, 2010 at 7:36 AM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Tue, Nov 9, 2010 at 12:37 PM, Casey McGinty <casey.mcginty@gmail.com> wrote:
>> Is there any feature in git to perform and auto stash apply/pop when
>> trying to do a merge/rebase in a dirty working dir? This would save
>> some keystrokes from time-to-time, and make it easier for new users
>> unfamiliar with git.
>
> And when switching branches too.

When switching branches (or checking out a different commit in general),
I think git allows you to check out as long as the files that need to be
replaced have not been updated, much like when merging. As far as I can
see, that makes the benefit of temporarily stashing changes much smaller
(but not non-existent) in these two cases (checkout and merge) than it
is when rebasing.

Thinking a bit more about it, I think you are right, though, that it
would still be a nice-to-have, as an option. Currently, 'git rebase' is
more restrictive than 'git merge', but adding the option to 'git rebase'
would not just make it on par with 'git merge', but would actually make
it less restrictive than 'git merge', as even non-conflicting changes
within files would be automatically handled.

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

* Re: Git automatic stashing?
  2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
  2010-11-09 12:58     ` Martin von Zweigbergk
@ 2010-11-09 19:12     ` Matthieu Moy
  2010-11-09 19:19       ` Thomas Rast
  1 sibling, 1 reply; 7+ messages in thread
From: Matthieu Moy @ 2010-11-09 19:12 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Casey McGinty, git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:

> On Tue, Nov 9, 2010 at 12:37 PM, Casey McGinty <casey.mcginty@gmail.com> wrote:
>> Is there any feature in git to perform and auto stash apply/pop when
>> trying to do a merge/rebase in a dirty working dir? This would save
>> some keystrokes from time-to-time, and make it easier for new users
>> unfamiliar with git.
>
> And when switching branches too.

Isn't that what "git checkout -m" does?

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

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

* Re: Git automatic stashing?
  2010-11-09 19:12     ` Matthieu Moy
@ 2010-11-09 19:19       ` Thomas Rast
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Rast @ 2010-11-09 19:19 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Nguyen Thai Ngoc Duy, Casey McGinty, git

Matthieu Moy wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> 
> > On Tue, Nov 9, 2010 at 12:37 PM, Casey McGinty <casey.mcginty@gmail.com> wrote:
> >> Is there any feature in git to perform and auto stash apply/pop when
> >> trying to do a merge/rebase in a dirty working dir? This would save
> >> some keystrokes from time-to-time, and make it easier for new users
> >> unfamiliar with git.
> >
> > And when switching branches too.
> 
> Isn't that what "git checkout -m" does?

The problem with checkout -m is that you get only a single shot at
conflict resolution.  'git stash pop' does not drop the stash in the
case of a conflict, so you can try again.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

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

end of thread, other threads:[~2010-11-09 19:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <AANLkTim3MacQK6EtTPNJsYbqb=5bOM3W3BXC6p=hT+PU@mail.gmail.com>
2010-11-09  5:37 ` Git automatic stashing? Casey McGinty
2010-11-09  7:49   ` Matthieu Moy
2010-11-09 12:02     ` Martin von Zweigbergk
2010-11-09 12:36   ` Nguyen Thai Ngoc Duy
2010-11-09 12:58     ` Martin von Zweigbergk
2010-11-09 19:12     ` Matthieu Moy
2010-11-09 19:19       ` Thomas Rast

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).