{"thread":{"id":"32622","subject":"[BUG] Bug in git stash","startedAt":"2013-01-14T09:18:19Z","lastAt":"2013-01-14T11:45:39Z","messageCount":2,"participants":["Nikolay Frantsev","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"206785","messageId":"CAOJsraHfKRoK1G8tA2ROUH6qt-q0kG6WesZr5enOeeqFF_AC=w@mail.gmail.com","threadId":"32622","inReplyTo":null,"subject":"[BUG] Bug in git stash","fromName":"Nikolay Frantsev","fromEmail":"nikolay@frantsev.ru","sentAt":"2013-01-14T09:18:19Z","receivedAt":"2013-01-14T09:18:19Z","isPatch":false,"sender":{"key":"nikolay@frantsev.ru","avatar":null},"body":"Hi, I found very strange bug in git stash. Testcase attached to this mail.\n\n1. I have a test repo with two modified files and one new file with\ncontent witch added to commit (see repo in attached file):\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   3\n#\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#\tmodified:   1\n#\tmodified:   2\n#\n\n2. Stashing two modified files into stash named one:\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save --keep-index one\nSaved working directory and index state On master: one\nHEAD is now at 7e495f9 files added\n\n3. Checking status, files stashed successfully:\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   3\n#\n\n4. Stashing one added to commit file into stash named zero:\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save zero\nSaved working directory and index state On master: zero\nHEAD is now at 7e495f9 files added\n\n5. Checking status, files stashed successfully:\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git status\n# On branch master\nnothing to commit, working directory clean\n\n6. Trying to unstash first stashed changes (on step 2), there a bug:\n\nnikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash pop stash@{1}\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   3\n#\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#\tmodified:   1\n#\tmodified:   2\n#\nDropped stash@{1} (7926ab7285753c179a368a3a7e8ebfb0f39d0437)\n\nWhy there a new empty file named 3?\n\nI'm using git 1.8.1, same problem confirmed on git 1.7.12.4.\n\n--\nNikolay Frantsev\nHomepage: http://frantsev.ru/\n"},{"id":"206790","messageId":"50F3EFE3.9020100@viscovery.net","threadId":"32622","inReplyTo":"CAOJsraHfKRoK1G8tA2ROUH6qt-q0kG6WesZr5enOeeqFF_AC=w@mail.gmail.com","subject":"Re: [BUG] Bug in git stash","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-01-14T11:45:39Z","receivedAt":"2013-01-14T11:45:39Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 1/14/2013 10:18, schrieb Nikolay Frantsev:\n> nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status\n> # On branch master\n> # Changes to be committed:\n> #   (use \"git reset HEAD <file>...\" to unstage)\n> #\n> #\tnew file:   3\n> #\n> # Changes not staged for commit:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> #\tmodified:   1\n> #\tmodified:   2\n> #\n> nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save --keep-index one\n> Saved working directory and index state On master: one\n> HEAD is now at 7e495f9 files added\n...\n> nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash pop stash@{1}\n> # On branch master\n> # Changes to be committed:\n> #   (use \"git reset HEAD <file>...\" to unstage)\n> #\n> #\tnew file:   3\n> #\n> # Changes not staged for commit:\n> #   (use \"git add <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> #\tmodified:   1\n> #\tmodified:   2\n> #\n> Dropped stash@{1} (7926ab7285753c179a368a3a7e8ebfb0f39d0437)\n> \n> Why there a new empty file named 3?\n\nIt is by design. --keep-index only achieves that your staged changes are\nnot reverted, but nevertheless all changes are stashed away. Therefore,\nwhen you later apply the stash, you also get back the modified index.\n\n-- Hannes\n"}]}