git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Behavior of stash apply vs merge
       [not found] <1192924141.1697155.1359285809347.JavaMail.root@dewire.com>
@ 2013-01-27 11:35 ` Robin Rosenberg
  2013-01-27 17:57   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Rosenberg @ 2013-01-27 11:35 UTC (permalink / raw)
  To: Git List

Hi,

What good reason is it that 'git stash apply' gives hairy conflict markers, while 'git merge stash' does not. No renames involved.

-- robin

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

* Re: Behavior of stash apply vs merge
  2013-01-27 11:35 ` Behavior of stash apply vs merge Robin Rosenberg
@ 2013-01-27 17:57   ` Junio C Hamano
  2013-01-27 19:09     ` Robin Rosenberg
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2013-01-27 17:57 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Git List

Robin Rosenberg <robin.rosenberg@dewire.com> writes:

> What good reason is it that 'git stash apply' gives hairy conflict
> markers, while 'git merge stash' does not. No renames involved.

"git merge stash" is nonsensical and would do a vastly different
thing compared to "git stash apply" depending on where you created
the stash and where you are attempting to run that operation.

Imagine you started fixing a bug while on the 'master' branch,
realized that the fix equally well applies to your 'maint' branch.
You would do "git stash" followed by "git checkout maint".

A sane person would do "git stash apply" at this point.  It applies
the difference between the 'master' you were working on and your WIP
on top of your 'maint'.

"git merge stash" is entirely different.  The history leading to a
stash looks like this:

                   I
                  / \
      ---o---o---B---W

where

	B is the commit you were working on (i.e. 'master');
	I records the state of the index;
	W records the state of the working tree.

and "stash" refers to W.

Think what commit B is in this example and the reason why you should
never ever do "git merge stash" will become apparent.  By merging W
into 'maint', you would be pulling the entire history between
'maint' and 'master' to the result.

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

* Re: Behavior of stash apply vs merge
  2013-01-27 17:57   ` Junio C Hamano
@ 2013-01-27 19:09     ` Robin Rosenberg
  2013-01-27 19:12       ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Rosenberg @ 2013-01-27 19:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

Thanks. Feeling a bit studid now.

I was actually thinking about using merge to implement stash apply
in JGit. What we have is broken so I tried using merge to implement
it and them compared to git merge --no-commit.. FAIL.

The main difference is of course that I set the merge base to
stash^1, which is obviously not what my question was about.

-- robin

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

* Re: Behavior of stash apply vs merge
  2013-01-27 19:09     ` Robin Rosenberg
@ 2013-01-27 19:12       ` Junio C Hamano
  2013-01-27 19:51         ` Robin Rosenberg
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2013-01-27 19:12 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Git List

Robin Rosenberg <robin.rosenberg@dewire.com> writes:

> Thanks. Feeling a bit studid now.
>
> I was actually thinking about using merge to implement stash apply
> in JGit. What we have is broken so I tried using merge to implement
> it and them compared to git merge --no-commit.. FAIL.

Do you have "cherry-pick"?

In short, "stash apply" is a "cherry-pick" in disguise.

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

* Re: Behavior of stash apply vs merge
  2013-01-27 19:12       ` Junio C Hamano
@ 2013-01-27 19:51         ` Robin Rosenberg
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Rosenberg @ 2013-01-27 19:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List



----- Ursprungligt meddelande -----
> Robin Rosenberg <robin.rosenberg@dewire.com> writes:
> 
> > Thanks. Feeling a bit studid now.
> >
> > I was actually thinking about using merge to implement stash apply
> > in JGit. What we have is broken so I tried using merge to implement
> > it and them compared to git merge --no-commit.. FAIL.
> 
> Do you have "cherry-pick"?
>
> In short, "stash apply" is a "cherry-pick" in disguise.

Yes, that's what I did. Thanks for confirming this. One for the working
tree and if that succeeds I do another one to restore the index if requested.

-- robin

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

end of thread, other threads:[~2013-01-27 19:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1192924141.1697155.1359285809347.JavaMail.root@dewire.com>
2013-01-27 11:35 ` Behavior of stash apply vs merge Robin Rosenberg
2013-01-27 17:57   ` Junio C Hamano
2013-01-27 19:09     ` Robin Rosenberg
2013-01-27 19:12       ` Junio C Hamano
2013-01-27 19:51         ` Robin Rosenberg

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).