{"thread":{"id":"32741","subject":"Behavior of stash apply vs merge","startedAt":"2013-01-27T11:35:56Z","lastAt":"2013-01-27T19:51:09Z","messageCount":5,"participants":["Robin Rosenberg","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"207945","messageId":"61173190.1700449.1359286556865.JavaMail.root@dewire.com","threadId":"32741","inReplyTo":"1192924141.1697155.1359285809347.JavaMail.root@dewire.com","subject":"Behavior of stash apply vs merge","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2013-01-27T11:35:56Z","receivedAt":"2013-01-27T11:35:56Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Hi,\n\nWhat good reason is it that 'git stash apply' gives hairy conflict markers, while 'git merge stash' does not. No renames involved.\n\n-- robin\n"},{"id":"207965","messageId":"7vvcaiwltj.fsf@alter.siamese.dyndns.org","threadId":"32741","inReplyTo":"61173190.1700449.1359286556865.JavaMail.root@dewire.com","subject":"Re: Behavior of stash apply vs merge","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-27T17:57:28Z","receivedAt":"2013-01-27T17:57:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n\n> What good reason is it that 'git stash apply' gives hairy conflict\n> markers, while 'git merge stash' does not. No renames involved.\n\n\"git merge stash\" is nonsensical and would do a vastly different\nthing compared to \"git stash apply\" depending on where you created\nthe stash and where you are attempting to run that operation.\n\nImagine you started fixing a bug while on the 'master' branch,\nrealized that the fix equally well applies to your 'maint' branch.\nYou would do \"git stash\" followed by \"git checkout maint\".\n\nA sane person would do \"git stash apply\" at this point.  It applies\nthe difference between the 'master' you were working on and your WIP\non top of your 'maint'.\n\n\"git merge stash\" is entirely different.  The history leading to a\nstash looks like this:\n\n                   I\n                  / \\\n      ---o---o---B---W\n\nwhere\n\n\tB is the commit you were working on (i.e. 'master');\n\tI records the state of the index;\n\tW records the state of the working tree.\n\nand \"stash\" refers to W.\n\nThink what commit B is in this example and the reason why you should\nnever ever do \"git merge stash\" will become apparent.  By merging W\ninto 'maint', you would be pulling the entire history between\n'maint' and 'master' to the result.\n"},{"id":"207969","messageId":"2043716001.1806075.1359313796808.JavaMail.root@dewire.com","threadId":"32741","inReplyTo":"7vvcaiwltj.fsf@alter.siamese.dyndns.org","subject":"Re: Behavior of stash apply vs merge","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2013-01-27T19:09:56Z","receivedAt":"2013-01-27T19:09:56Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Thanks. Feeling a bit studid now.\n\nI was actually thinking about using merge to implement stash apply\nin JGit. What we have is broken so I tried using merge to implement\nit and them compared to git merge --no-commit.. FAIL.\n\nThe main difference is of course that I set the merge base to\nstash^1, which is obviously not what my question was about.\n\n-- robin\n"},{"id":"207970","messageId":"7vfw1mwibu.fsf@alter.siamese.dyndns.org","threadId":"32741","inReplyTo":"2043716001.1806075.1359313796808.JavaMail.root@dewire.com","subject":"Re: Behavior of stash apply vs merge","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-27T19:12:53Z","receivedAt":"2013-01-27T19:12:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n\n> Thanks. Feeling a bit studid now.\n>\n> I was actually thinking about using merge to implement stash apply\n> in JGit. What we have is broken so I tried using merge to implement\n> it and them compared to git merge --no-commit.. FAIL.\n\nDo you have \"cherry-pick\"?\n\nIn short, \"stash apply\" is a \"cherry-pick\" in disguise.\n"},{"id":"207974","messageId":"35452020.1815583.1359316269106.JavaMail.root@dewire.com","threadId":"32741","inReplyTo":"7vfw1mwibu.fsf@alter.siamese.dyndns.org","subject":"Re: Behavior of stash apply vs merge","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2013-01-27T19:51:09Z","receivedAt":"2013-01-27T19:51:09Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"\n\n----- Ursprungligt meddelande -----\n> Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n> \n> > Thanks. Feeling a bit studid now.\n> >\n> > I was actually thinking about using merge to implement stash apply\n> > in JGit. What we have is broken so I tried using merge to implement\n> > it and them compared to git merge --no-commit.. FAIL.\n> \n> Do you have \"cherry-pick\"?\n>\n> In short, \"stash apply\" is a \"cherry-pick\" in disguise.\n\nYes, that's what I did. Thanks for confirming this. One for the working\ntree and if that succeeds I do another one to restore the index if requested.\n\n-- robin\n"}]}