{"thread":{"id":"40070","subject":"Git stash behavior","startedAt":"2015-08-12T14:57:25Z","lastAt":"2015-08-17T11:00:06Z","messageCount":2,"participants":["sivno.20.toranaga-san@spamgourmet.com","Ed Avis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"267908","messageId":"55CB5ED5.5020908@gmx.de","threadId":"40070","inReplyTo":null,"subject":"Git stash behavior","fromName":"","fromEmail":"sivno.20.toranaga-san@spamgourmet.com","sentAt":"2015-08-12T14:57:25Z","receivedAt":"2015-08-12T14:57:25Z","isPatch":false,"sender":{"key":"sivno.20.toranaga-san@spamgourmet.com","avatar":null},"body":"Hello all,\n\nI am using git stashes to ensure that my source builds and tests\ncorrectly. My general work flow is this: Before committing I create a\nstash and clean everything:\n\n    git stash save -q --keep-index --include-untracked\n\nThen I perform some tests (mvn compile test), after that I restore\neverything:\n\n    git stash pop -q\n\nI am using this from a pre-commit hook so I really need this to work\nreliably. The problem is that I think that it really doesn't. I created\na small gist to show the problem here:\n\nhttps://gist.github.com/x2b/3cc3d8aa8979561de4b5\n\nThere are actually multiple problems here:\n\n1.\n\nIf an untracked file already exists then git refuses to pop the stash.\nThis is certainly the desired behavior in most cases. However, I would\nappreciate a \"--force\" option to override it.\n\n2.\n\nAs you can see the content of the \"untracked\" file in the gist is the\nsame in the stash and the working directory. Is it really necessary to\nabort the operation in this case??\n\n3.\n\nThe most severe problem is that after unsuccessfully trying to pop the\nstash the \"first_untracked\" file is restored while the \"untracked\" file\nis not. The stash is *partially* applied to the working directory. It\nseems like git restores some files before giving up after encountering\nthe first file which can't be restored. I think this behavior is not\ngenerally what is expected. Git should either fail and leave the working\ndirectory as-is or succeed and change the directory's content.\nSince there is no \"--force\" option (see 1.) it is necessary to remove\nthe already restored untracked files by hand before attempting to pop\nthe stash once more (this is really inconvenient to me).\n\nWhile these are not technically bugs I would appreciate it if you could\naddress these issues all the same.\n\nx2b\n"},{"id":"268179","messageId":"loom.20150817T125938-440@post.gmane.org","threadId":"40070","inReplyTo":"55CB5ED5.5020908@gmx.de","subject":"Re: Git stash behavior","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-08-17T11:00:06Z","receivedAt":"2015-08-17T11:00:06Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"You may want to see this recent thread about a similar feature:\n\n<http://thread.gmane.org/gmane.comp.version-control.git/275607>\n\n-- \nEd Avis <eda@waniasset.com>\n"}]}