{"thread":{"id":"52456","subject":"Bug? git commit fileA tries to delete fileB and other oddities","startedAt":"2019-12-14T10:39:24Z","lastAt":"2019-12-17T11:05:05Z","messageCount":5,"participants":["Mikael Simonsson","Johannes Schindelin","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388205","messageId":"CA+PLxnUR2skor9CGfDKfEEm8XTmoHwM2cDf5Kpgt-ppo=4zhbQ@mail.gmail.com","threadId":"52456","inReplyTo":null,"subject":"Bug? git commit fileA tries to delete fileB and other oddities","fromName":"Mikael Simonsson","fromEmail":"m@mikaelsimonsson.com","sentAt":"2019-12-14T10:39:09Z","receivedAt":"2019-12-14T10:39:24Z","isPatch":false,"sender":{"key":"m@mikaelsimonsson.com","avatar":null},"body":"Hi,\n\nI have the following problems with a local repository:\n\n* git commit fileA tries to delete fileX (fileX still exists).\n\n* git restore --staged fileX doesn't work, the file remains staged.\n\n* A commit from a few days back deleted 2 random files that I haven't\ntouched or staged in months and pulled in staged changes I didn't ask\nfor.\n\ngit version: 2.24.0 and 2.24.1 (OS: FreeBSD 12)\n\nHow can this happen? The repository has a local remote (on the same\nfilesystem) that is pushed to only. I tarred the project and copied it\nto a Mac with git 2.23.0 and the problem persists.\n\nFor example (I've only changed the filenames):\n\n% git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nChanges to be committed:\n  (use \"git restore --staged <file>...\" to unstage)\n        modified:   fileA\n        modified:   fileB\n        modified:   fileC\n\nChanges not staged for commit:\n  (use \"git add/rm <file>...\" to update what will be committed)\n  (use \"git restore <file>...\" to discard changes in working directory)\n        ...\n\n\n% git commit fileA\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n# Your branch is up to date with 'origin/master'.\n#\n# Changes to be committed:\n#       deleted:    fileX\n#       modified:   fileA\n#\n# Changes not staged for commit:\n\n\n% git stash\nSaved working directory and index state WIP on master: 488e7081 ...\n\n\n% git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nChanges to be committed:\n  (use \"git restore --staged <file>...\" to unstage)\n        deleted:    fileX\n\nUntracked files:\n\n\n% git restore --staged fileX\n\n\n% git status\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nChanges to be committed:\n  (use \"git restore --staged <file>...\" to unstage)\n        deleted:    fileX\n\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n\nThanks,\nMikael\n"},{"id":"388239","messageId":"nycvar.QRO.7.76.6.1912152209020.46@tvgsbejvaqbjf.bet","threadId":"52456","inReplyTo":"CA+PLxnUR2skor9CGfDKfEEm8XTmoHwM2cDf5Kpgt-ppo=4zhbQ@mail.gmail.com","subject":"Re: Bug? git commit fileA tries to delete fileB and other oddities","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-12-15T21:09:54Z","receivedAt":"2019-12-15T21:10:13Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Mikael,\n\nOn Sat, 14 Dec 2019, Mikael Simonsson wrote:\n\n> I have the following problems with a local repository:\n>\n> * git commit fileA tries to delete fileX (fileX still exists).\n>\n> * git restore --staged fileX doesn't work, the file remains staged.\n>\n> * A commit from a few days back deleted 2 random files that I haven't\n> touched or staged in months and pulled in staged changes I didn't ask\n> for.\n>\n> git version: 2.24.0 and 2.24.1 (OS: FreeBSD 12)\n>\n> How can this happen? The repository has a local remote (on the same\n> filesystem) that is pushed to only. I tarred the project and copied it\n> to a Mac with git 2.23.0 and the problem persists.\n\nIt would be good if you could come up with a minimal list of commands to\nrecreate that problem. That way, we can turn it into a regression test and\nfix the problem.\n\nCiao,\nJohannes\n\n>\n> For example (I've only changed the filenames):\n>\n> % git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n>\n> Changes to be committed:\n>   (use \"git restore --staged <file>...\" to unstage)\n>         modified:   fileA\n>         modified:   fileB\n>         modified:   fileC\n>\n> Changes not staged for commit:\n>   (use \"git add/rm <file>...\" to update what will be committed)\n>   (use \"git restore <file>...\" to discard changes in working directory)\n>         ...\n>\n>\n> % git commit fileA\n>\n> # Please enter the commit message for your changes. Lines starting\n> # with '#' will be ignored, and an empty message aborts the commit.\n> #\n> # On branch master\n> # Your branch is up to date with 'origin/master'.\n> #\n> # Changes to be committed:\n> #       deleted:    fileX\n> #       modified:   fileA\n> #\n> # Changes not staged for commit:\n>\n>\n> % git stash\n> Saved working directory and index state WIP on master: 488e7081 ...\n>\n>\n> % git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n>\n> Changes to be committed:\n>   (use \"git restore --staged <file>...\" to unstage)\n>         deleted:    fileX\n>\n> Untracked files:\n>\n>\n> % git restore --staged fileX\n>\n>\n> % git status\n> On branch master\n> Your branch is up to date with 'origin/master'.\n>\n> Changes to be committed:\n>   (use \"git restore --staged <file>...\" to unstage)\n>         deleted:    fileX\n>\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n>\n>\n> Thanks,\n> Mikael\n>\n"},{"id":"388243","messageId":"CA+PLxnWLWckpZdjy8XQLbO0EVJ1khiyUYi1T=Mcy_rBkvbLpZA@mail.gmail.com","threadId":"52456","inReplyTo":"nycvar.QRO.7.76.6.1912152209020.46@tvgsbejvaqbjf.bet","subject":"Re: Bug? git commit fileA tries to delete fileB and other oddities","fromName":"Mikael Simonsson","fromEmail":"m@mikaelsimonsson.com","sentAt":"2019-12-16T09:50:33Z","receivedAt":"2019-12-16T09:50:49Z","isPatch":false,"sender":{"key":"m@mikaelsimonsson.com","avatar":null},"body":"Hi Johannes,\n\nI will try to recreate the problem with a new repository.\n\nSo far I think I've narrowed it down to a bug introduced in git 2.20.0.\n\nNot buggy:\n1.9.5\n2.7.1\n2.11.0\n2.15.0\n2.18.0\n2.19.0\n2.19.2\n2.19.3\n\nBuggy:\n2.20.0\n2.21.1\n2.23.0 (Mac)\n2.24.0\n2.24.1\n\nThe buggy versions all try to delete fileX when running \"git commit fileA\":\n\n% git commit fileA\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n# Your branch is up to date with 'origin/master'.\n#\n# Changes to be committed:\n#       deleted:    fileX\n#       modified:   fileA\n#\n# Changes not staged for commit:\n\n\nKind regards,\nMikael\n\n\nOn Sun, Dec 15, 2019 at 9:10 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi Mikael,\n>\n> On Sat, 14 Dec 2019, Mikael Simonsson wrote:\n>\n> > I have the following problems with a local repository:\n> >\n> > * git commit fileA tries to delete fileX (fileX still exists).\n> >\n> > * git restore --staged fileX doesn't work, the file remains staged.\n> >\n> > * A commit from a few days back deleted 2 random files that I haven't\n> > touched or staged in months and pulled in staged changes I didn't ask\n> > for.\n> >\n> > git version: 2.24.0 and 2.24.1 (OS: FreeBSD 12)\n> >\n> > How can this happen? The repository has a local remote (on the same\n> > filesystem) that is pushed to only. I tarred the project and copied it\n> > to a Mac with git 2.23.0 and the problem persists.\n>\n> It would be good if you could come up with a minimal list of commands to\n> recreate that problem. That way, we can turn it into a regression test and\n> fix the problem.\n>\n> Ciao,\n> Johannes\n>\n> >\n> > For example (I've only changed the filenames):\n> >\n> > % git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > Changes to be committed:\n> >   (use \"git restore --staged <file>...\" to unstage)\n> >         modified:   fileA\n> >         modified:   fileB\n> >         modified:   fileC\n> >\n> > Changes not staged for commit:\n> >   (use \"git add/rm <file>...\" to update what will be committed)\n> >   (use \"git restore <file>...\" to discard changes in working directory)\n> >         ...\n> >\n> >\n> > % git commit fileA\n> >\n> > # Please enter the commit message for your changes. Lines starting\n> > # with '#' will be ignored, and an empty message aborts the commit.\n> > #\n> > # On branch master\n> > # Your branch is up to date with 'origin/master'.\n> > #\n> > # Changes to be committed:\n> > #       deleted:    fileX\n> > #       modified:   fileA\n> > #\n> > # Changes not staged for commit:\n> >\n> >\n> > % git stash\n> > Saved working directory and index state WIP on master: 488e7081 ...\n> >\n> >\n> > % git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > Changes to be committed:\n> >   (use \"git restore --staged <file>...\" to unstage)\n> >         deleted:    fileX\n> >\n> > Untracked files:\n> >\n> >\n> > % git restore --staged fileX\n> >\n> >\n> > % git status\n> > On branch master\n> > Your branch is up to date with 'origin/master'.\n> >\n> > Changes to be committed:\n> >   (use \"git restore --staged <file>...\" to unstage)\n> >         deleted:    fileX\n> >\n> > Untracked files:\n> >   (use \"git add <file>...\" to include in what will be committed)\n> >\n> >\n> > Thanks,\n> > Mikael\n> >\n"},{"id":"388332","messageId":"20191217073306.GA3313061@coredump.intra.peff.net","threadId":"52456","inReplyTo":"CA+PLxnWLWckpZdjy8XQLbO0EVJ1khiyUYi1T=Mcy_rBkvbLpZA@mail.gmail.com","subject":"Re: Bug? git commit fileA tries to delete fileB and other oddities","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-12-17T07:33:06Z","receivedAt":"2019-12-17T07:33:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Dec 16, 2019 at 09:50:33AM +0000, Mikael Simonsson wrote:\n\n> I will try to recreate the problem with a new repository.\n> \n> So far I think I've narrowed it down to a bug introduced in git 2.20.0.\n> \n> Not buggy:\n> [...]\n\nIf you can build Git from source, you might try using \"git bisect\" to\nfind the exact commit where the problem starts.\n\n> The buggy versions all try to delete fileX when running \"git commit fileA\":\n> \n> % git commit fileA\n> \n> # Please enter the commit message for your changes. Lines starting\n> # with '#' will be ignored, and an empty message aborts the commit.\n> #\n> # On branch master\n> # Your branch is up to date with 'origin/master'.\n> #\n> # Changes to be committed:\n> #       deleted:    fileX\n> #       modified:   fileA\n> #\n> # Changes not staged for commit:\n\nIs there anything about \"fileX\" and \"fileA\"'s names that might be\nrelevant? E.g., might they case-fold to the same name or something?\n\n-Peff\n"},{"id":"388349","messageId":"CA+PLxnVzu0zDtpT2T660UGhZ0RvFcq50nPfZz9Que7_7mqiSyQ@mail.gmail.com","threadId":"52456","inReplyTo":"20191217073306.GA3313061@coredump.intra.peff.net","subject":"Re: Bug? git commit fileA tries to delete fileB and other oddities","fromName":"Mikael Simonsson","fromEmail":"m@mikaelsimonsson.com","sentAt":"2019-12-17T11:04:50Z","receivedAt":"2019-12-17T11:05:05Z","isPatch":false,"sender":{"key":"m@mikaelsimonsson.com","avatar":null},"body":"git bisect made that pretty easy, thanks. It looks like it started\nwith this commit:\n\n\"unpack-trees: optimize walking same trees with cache-tree\"\nhttps://github.com/git/git/commit/b4da37380b7774248086f42bcd59397a44e1ac79\n\n(I ran git bisect between tags v2.19.2 and v2.20.0.)\n\n\nTesting the commit in question:\n% git checkout b4da37380b7774248086f42bcd59397a44e1ac79\n% gmake -j 6 NO_OPENSSL=YesPlease NO_PERL=YesPlease NO_TCLTK=YesPlease\nNO_GETTEXT=YesPlease NO_EXPAT=YesPlease all\n\n% ~/tmp/git-source/git version\ngit version 2.18.0.751.gb4da37380b\n\n% ~/tmp/git-source/git commit null_terminated.hh\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n# Your branch is up to date with 'origin/master'.\n#\n# Changes to be committed:\n#       deleted:    algo/find.hh\n#       new file:   app/.reserved\n#       deleted:    ascii/contains_icase.hh\n#       deleted:    ascii/contains_icase.test.cc\n#       modified:   null_terminated.hh\n#\n# Changes not staged for commit:\nAborting commit due to empty commit message.\n\n\nNote that the latest version behaves differently (it tries to delete\nanother file):\n\n% git version\ngit version 2.24.1\n\n% git commit null_terminated.hh\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n# Your branch is up to date with 'origin/master'.\n#\n# Changes to be committed:\n#       deleted:    defer.hh\n#       modified:   null_terminated.hh\nAborting commit due to empty commit message.\n\n\nThe commit before \"unpack-trees: optimize walking same trees with\ncache-tree\" works as it should:\n% git checkout b4da37380b7774248086f42bcd59397a44e1ac79^\n% gmake -j 6 NO_OPENSSL=YesPlease NO_PERL=YesPlease NO_TCLTK=YesPlease\nNO_GETTEXT=YesPlease NO_EXPAT=YesPlease all\n\n% ~/tmp/git-source/git version\ngit version 2.18.0.750.g0d1ed5963d\n\n% ~/tmp/git-source/git commit null_terminated.hh\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n# Your branch is up to date with 'origin/master'.\n#\n# Changes to be committed:\n#       modified:   null_terminated.hh\n#\n# Changes not staged for commit:\nAborting commit due to empty commit message.\n\n\nHere's my local commit from about a week ago when the problems started.\n\nI'm sure I ran \"git commit readme.md\" because I had several files\nstaged. The commit pulled in 3 staged files (I think there were more)\nand deleted 3 files that 100% weren't staged.\n\n% git show --numstat 7d5d43d849f1391b3cc11f12e037b8cb5174e3a3\ncommit 7d5d43d849f1391b3cc11f12e037b8cb5174e3a3\nAuthor: Mikael Simonsson <m@mikaelsimonsson.com>\nDate:   Sun Dec 8 10:38:38 2019 +0000\n\n    Add short info and requirements for ranges\n\n56      0       algo/find.hh\n0       1       app/.reserved\n16      0       ascii/contains_icase.hh\n28      0       ascii/contains_icase.test.cc\n0       41      bench/bench.hh\n0       41      debug.hh\n76      0       readme.md\n\n-Mikael\n\n\n\nOn Tue, Dec 17, 2019 at 7:33 AM Jeff King <peff@peff.net> wrote:\n>\n> On Mon, Dec 16, 2019 at 09:50:33AM +0000, Mikael Simonsson wrote:\n>\n> > I will try to recreate the problem with a new repository.\n> >\n> > So far I think I've narrowed it down to a bug introduced in git 2.20.0.\n> >\n> > Not buggy:\n> > [...]\n>\n> If you can build Git from source, you might try using \"git bisect\" to\n> find the exact commit where the problem starts.\n>\n> > The buggy versions all try to delete fileX when running \"git commit fileA\":\n> >\n> > % git commit fileA\n> >\n> > # Please enter the commit message for your changes. Lines starting\n> > # with '#' will be ignored, and an empty message aborts the commit.\n> > #\n> > # On branch master\n> > # Your branch is up to date with 'origin/master'.\n> > #\n> > # Changes to be committed:\n> > #       deleted:    fileX\n> > #       modified:   fileA\n> > #\n> > # Changes not staged for commit:\n>\n> Is there anything about \"fileX\" and \"fileA\"'s names that might be\n> relevant? E.g., might they case-fold to the same name or something?\n>\n> -Peff\n"}]}