{"thread":{"id":"48049","subject":"[bug] git stash push {dir-pathspec} wipes untracked files","startedAt":"2018-03-15T16:40:45Z","lastAt":"2018-03-15T20:39:53Z","messageCount":4,"participants":["Jake Stine","Junio C Hamano","Randall S. Becker","Igor Djordjevic"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"341758","messageId":"CABWk7R9xNDHJbbsMZbOyhcYXq-bD6Krvbw_mKDBJFALALS3AHA@mail.gmail.com","threadId":"48049","inReplyTo":null,"subject":"[bug] git stash push {dir-pathspec} wipes untracked files","fromName":"Jake Stine","fromEmail":"jake.stine@gmail.com","sentAt":"2018-03-15T16:40:38Z","receivedAt":"2018-03-15T16:40:45Z","isPatch":false,"sender":{"key":"jake.stine@gmail.com","avatar":null},"body":"Hi, I ran into what I believe is a bug today.  I’m using primarily Git\nfor Windows 2.16.2 and also reproduced the behavior on Git for Windows\n2.15.1 and Git 2.14.1 on Ubuntu:\n\nGiven any repository with at least one subdirectory:\n\n1.       Create some untracked files in the subdir\n2.       Modify a tracked file in the subdir\n3.       Execute `git stash push subdir`\n4.       The untracked files will be removed, without warning.\n\n`git stash push` behaves as-expcted and does not touch untracked\nfiles.  It’s only when a directory tree is specified as [pathspec]\nthat the problem occurs.\n\nHere's the precise reproduction case executed on a linux box:\n\njake@jake-VirtualBox:~/woot$ git --version\ngit version 2.14.1\njake@jake-VirtualBox:~/woot$ git config --global user.email jake.stine@gmail.com\njake@jake-VirtualBox:~/woot$ git config --global user.name \"Jake Stine\"\njake@jake-VirtualBox:~$ git init woot\nInitialized empty Git repository in /home/jake/woot/.git/\njake@jake-VirtualBox:~$ cd woot\njake@jake-VirtualBox:~/woot$ mkdir subdir\njake@jake-VirtualBox:~/woot$ echo \"test\" > meh.txt\njake@jake-VirtualBox:~/woot$ echo \"test\" > subdir/meh2.txt\njake@jake-VirtualBox:~/woot$ git add meh.txt subdir/meh2.txt\njake@jake-VirtualBox:~/woot$ git commit --message=\"stash bug testing\"\njake@jake-VirtualBox:~/woot$ git commit --message=\"stash bug testing\"\n[master (root-commit) 2c05580] stash bug testing\n 2 files changed, 2 insertions(+)\n create mode 100644 meh.txt\n create mode 100644 subdir/meh2.txt\njake@jake-VirtualBox:~/woot$ echo \"test\" > subdir/untracked.txt\njake@jake-VirtualBox:~/woot$ echo \"append\" >> subdir/meh2.txt\njake@jake-VirtualBox:~/woot$ git stash push subdir\nSaved working directory and index state WIP on master: 2c05580 stash bug testing\njake@jake-VirtualBox:~/woot$ ls subdir\nmeh2.txt\n\n\nThe expected result is that when I do `ls subdir` the file\n\"untracked.txt\" still exists.  Alternatively, git stash should warn me\nbefore destroying my untracked files, and require I specify --force or\nsimilar to invoke destructive behavior.\n\n\nThanks!\nJake Stine\n"},{"id":"341764","messageId":"xmqq1sgl703v.fsf@gitster-ct.c.googlers.com","threadId":"48049","inReplyTo":"CABWk7R9xNDHJbbsMZbOyhcYXq-bD6Krvbw_mKDBJFALALS3AHA@mail.gmail.com","subject":"Re: [bug] git stash push {dir-pathspec} wipes untracked files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-15T16:52:04Z","receivedAt":"2018-03-15T16:52:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jake Stine <jake.stine@gmail.com> writes:\n\n> Hi, I ran into what I believe is a bug today.  I’m using primarily Git\n> for Windows 2.16.2 and also reproduced the behavior on Git for Windows\n> 2.15.1 and Git 2.14.1 on Ubuntu:\n>\n> Given any repository with at least one subdirectory:\n>\n> 1.       Create some untracked files in the subdir\n> 2.       Modify a tracked file in the subdir\n> 3.       Execute `git stash push subdir`\n> 4.       The untracked files will be removed, without warning.\n>\n> `git stash push` behaves as-expcted and does not touch untracked\n> files.  It’s only when a directory tree is specified as [pathspec]\n> that the problem occurs.\n\nI wonder if this is the same as the topic on this thread.\n\n  https://public-inbox.org/git/CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_A@mail.gmail.com/\n\nWhat is curious is that the fix bba067d2 (\"stash: don't delete\nuntracked files that match pathspec\", 2018-01-06) appeared first in\n2.16.2, on which Windows 2.16.2 is supposed to be built upon.\n\n> Here's the precise reproduction case executed on a linux box:\n\nThis does not reproduce for me with v2.16.2-17-g38e79b1fda (the tip\nof 'maint'); I do not have an  install of vanilla v2.16.2 handy, but\nI suspect v2.16.2 would work just fine, too.\n\n> jake@jake-VirtualBox:~/woot$ git --version\n> git version 2.14.1\n> ...\n> The expected result is that when I do `ls subdir` the file\n> \"untracked.txt\" still exists.  Alternatively, git stash should warn me\n> before destroying my untracked files, and require I specify --force or\n> similar to invoke destructive behavior.\n>\n>\n> Thanks!\n> Jake Stine\n"},{"id":"341767","messageId":"002f01d3bc7f$7b6261f0$722725d0$@nexbridge.com","threadId":"48049","inReplyTo":"xmqq1sgl703v.fsf@gitster-ct.c.googlers.com","subject":"RE: [bug] git stash push {dir-pathspec} wipes untracked files","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2018-03-15T17:02:58Z","receivedAt":"2018-03-15T17:03:15Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"\n\n> -----Original Message-----\n> From: git-owner@vger.kernel.org <git-owner@vger.kernel.org> On Behalf\n> Of Junio C Hamano\n> Sent: March 15, 2018 12:52 PM\n> To: Jake Stine <jake.stine@gmail.com>\n> Cc: git@vger.kernel.org\n> Subject: Re: [bug] git stash push {dir-pathspec} wipes untracked files\n> \n> Jake Stine <jake.stine@gmail.com> writes:\n> \n> > Hi, I ran into what I believe is a bug today.  I’m using primarily Git\n> > for Windows 2.16.2 and also reproduced the behavior on Git for Windows\n> > 2.15.1 and Git 2.14.1 on Ubuntu:\n> >\n> > Given any repository with at least one subdirectory:\n> >\n> > 1.       Create some untracked files in the subdir\n> > 2.       Modify a tracked file in the subdir\n> > 3.       Execute `git stash push subdir`\n> > 4.       The untracked files will be removed, without warning.\n> >\n> > `git stash push` behaves as-expcted and does not touch untracked\n> > files.  It’s only when a directory tree is specified as [pathspec]\n> > that the problem occurs.\n> \n> I wonder if this is the same as the topic on this thread.\n> \n>   https://public-\n> inbox.org/git/CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_\n> A@mail.gmail.com/\n> \n> What is curious is that the fix bba067d2 (\"stash: don't delete untracked files\n> that match pathspec\", 2018-01-06) appeared first in 2.16.2, on which\n> Windows 2.16.2 is supposed to be built upon.\n> \n> > Here's the precise reproduction case executed on a linux box:\n> \n> This does not reproduce for me with v2.16.2-17-g38e79b1fda (the tip of\n> 'maint'); I do not have an  install of vanilla v2.16.2 handy, but I suspect v2.16.2\n> would work just fine, too.\n\nThis does not reproduce for me either in v2.16.2.9-g3dbadef9f (which is the NonStop port of 2.16.2)\n\nOn branch master\nChanges 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        modified:   subdir/a\n\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n        subdir/b\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n/home/randall/foot: git stash push subdir\nSaved working directory and index state WIP on master: b772270 i\n/home/randall/foot: ls subdir\na  b\n/home/randall/foot: git status\nOn branch master\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n        subdir/b\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\n"},{"id":"341829","messageId":"780a67cd-7e94-f155-d04d-72799e2997fa@gmail.com","threadId":"48049","inReplyTo":"xmqq1sgl703v.fsf@gitster-ct.c.googlers.com","subject":"Re: [bug] git stash push {dir-pathspec} wipes untracked files","fromName":"Igor Djordjevic","fromEmail":"igor.d.djordjevic@gmail.com","sentAt":"2018-03-15T20:39:25Z","receivedAt":"2018-03-15T20:39:53Z","isPatch":false,"sender":{"key":"igor.d.djordjevic@gmail.com","avatar":null},"body":"On 15/03/2018 17:52, Junio C Hamano wrote:\n> \n> > Hi, I ran into what I believe is a bug today.  I’m using primarily Git\n> > for Windows 2.16.2 and also reproduced the behavior on Git for Windows\n> > 2.15.1 and Git 2.14.1 on Ubuntu:\n> >\n> > Given any repository with at least one subdirectory:\n> >\n> > 1.       Create some untracked files in the subdir\n> > 2.       Modify a tracked file in the subdir\n> > 3.       Execute `git stash push subdir`\n> > 4.       The untracked files will be removed, without warning.\n> >\n> > `git stash push` behaves as-expcted and does not touch untracked\n> > files.  It’s only when a directory tree is specified as [pathspec]\n> > that the problem occurs.\n> \n> I wonder if this is the same as the topic on this thread.\n> \n>   https://public-inbox.org/git/CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_A@mail.gmail.com/\n> \n> What is curious is that the fix bba067d2 (\"stash: don't delete\n> untracked files that match pathspec\", 2018-01-06) appeared first in\n> 2.16.2, on which Windows 2.16.2 is supposed to be built upon.\n> \n> > Here's the precise reproduction case executed on a linux box:\n> \n> This does not reproduce for me with v2.16.2-17-g38e79b1fda (the tip\n> of 'maint'); I do not have an  install of vanilla v2.16.2 handy, but\n> I suspect v2.16.2 would work just fine, too.\n> \n> > jake@jake-VirtualBox:~/woot$ git --version\n> > git version 2.14.1\n> > ...\n> > The expected result is that when I do `ls subdir` the file\n> > \"untracked.txt\" still exists.  Alternatively, git stash should warn me\n> > before destroying my untracked files, and require I specify --force or\n> > similar to invoke destructive behavior.\n\nI can't seem to reproduce this on 2.16.2.windows.1, either:\n\n+ git --version\ngit version 2.16.2.windows.1\n+ git init woot\nInitialized empty Git repository in /woot/.git/\n+ cd woot\n+ mkdir subdir\n+ echo test\n+ echo test\n+ git add meh.txt subdir/meh2.txt\n+ git commit '--message=stash bug testing'\n[master (root-commit) afec47d] stash bug testing\n 2 files changed, 2 insertions(+)\n create mode 100644 meh.txt\n create mode 100644 subdir/meh2.txt\n+ git commit '--message=stash bug testing'\nOn branch master\nnothing to commit, working tree clean\n+ echo test\n+ echo append\n+ git stash push subdir\nSaved working directory and index state WIP on master: afec47d stash bug testing\n+ ls subdir\nmeh2.txt  untracked.txt\n\nRegards, Buga\n"}]}