Hi,
What good reason is it that 'git stash apply' gives hairy conflict markers, while 'git merge stash' does not. No renames involved.
-- robin
Hi,
What good reason is it that 'git stash apply' gives hairy conflict markers, while 'git merge stash' does not. No renames involved.
-- robin
Re: Behavior of stash apply vs merge
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---Wwhere
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.
Re: Behavior of stash apply vs merge
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
Re: Behavior of stash apply vs merge
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.
Re: Behavior of stash apply vs merge
----- 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