{"thread":{"id":"43959","subject":"Bug Report: \"git submodule deinit\" fails right after a clone","startedAt":"2016-08-30T11:46:02Z","lastAt":"2016-10-06T16:11:00Z","messageCount":6,"participants":["Thomas Bétous","Heiko Voigt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"300555","messageId":"CAPOqYV+C-P9M2zcUBBkD2LALPm4K3sxSut+BjAkZ9T1AKLEr+A@mail.gmail.com","threadId":"43959","inReplyTo":null,"subject":"Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Thomas Bétous","fromEmail":"th.betous@gmail.com","sentAt":"2016-08-30T11:45:56Z","receivedAt":"2016-08-30T11:46:02Z","isPatch":false,"sender":{"key":"th.betous@gmail.com","avatar":null},"body":"Hello,\n\nI found a curious bug in git version 2.9.0.windows.1 (run on Windows 7\nvia git bash).\n\nIf I clone a repository containing submodules and run a \"git submodule\ndeinit\" on any of the submodules of this repository without executing\nanother git command, this command fails.\n\nFor instance:\n\n(let's say the repo MyProject contains 2 submodules: Submodule1 and Submodule2)\n\n$ git clone ssh://****/MyProject\n[ ... \"git clone\" output ... ]\n$ cd MyProject\n$ git submodule deinit Submodule1\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'Submodule1' contains local modifications; use\n'-f' to discard them\n$ git submodule deinit Submodule2\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'Submodule2' contains local modifications; use\n'-f' to discard them\n\nFirst the error message is strange.\nThen what is even stranger is that the error disappears if a \"git\nstatus\" is run before the submodule deinit...\n\n\n$ git clone ssh://****/MyProject\n[ ... \"git clone\" output ... ]\n$ cd MyProject\n$ git submodule deinit Submodule1\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'Submodule1' contains local modifications; use\n'-f' to discard them\n$ git status\n[ ... \"git status\" output ...]\n$ git submodule deinit Submodule1\nCleared directory 'Submodule1'\n\nI have been able to reproduce this error at least 10 times and with\ndifferent repositories so I do not think it comes from the state of my\nrepositories.\nMoreover, the use of \"--recursive\" argument to the \"git clone\" command\ndid not change anything.\n\nAre you able to reproduce this problem?\n\nThank you in advance.\n\nBest regards,\n\nThomas\n"},{"id":"301927","messageId":"20160914202907.GD7613@sandbox","threadId":"43959","inReplyTo":"CAPOqYV+C-P9M2zcUBBkD2LALPm4K3sxSut+BjAkZ9T1AKLEr+A@mail.gmail.com","subject":"Re: Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2016-09-14T20:29:07Z","receivedAt":"2016-09-14T20:29:16Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Tue, Aug 30, 2016 at 01:45:56PM +0200, Thomas Bétous wrote:\n> Are you able to reproduce this problem?\n\nNo. I just did a clone and an immediate deinit afterwards and no error.\nMaybe you can provide a script to reproduce? Which System was this on?\n\nCheers Heiko\n"},{"id":"303246","messageId":"CAPOqYV+xsrLk7y1hJYHZFY8OfkxVRwPcZBdqhdgrhThqdZysQA@mail.gmail.com","threadId":"43959","inReplyTo":"20160914202907.GD7613@sandbox","subject":"Re: Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Thomas Bétous","fromEmail":"th.betous@gmail.com","sentAt":"2016-10-04T15:46:45Z","receivedAt":"2016-10-04T15:46:53Z","isPatch":false,"sender":{"key":"th.betous@gmail.com","avatar":null},"body":"Thank you for your answer and sorry for the delay (I was on vacation...).\n\nI am using git 2.9.0.windows.1 (run on Windows 7 via git bash).\n\nI tested it on this repo:\nhttps://github.com/githubtraining/example-dependency.git\nThe same problem occurs.\nHere a small script to reproduce the error on my PC:\n#!/bin/bash\ngit clone https://github.com/githubtraining/example-dependency.git\ncd example-dependency\ngit submodule deinit js\n\nIt ends with this error:\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'js' contains local modifications; use '-f' to discard them\n\nIs the script working on your PC?\n\nThank you in advance.\n\nThomas\n\nOn Wed, Sep 14, 2016 at 10:29 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> On Tue, Aug 30, 2016 at 01:45:56PM +0200, Thomas Bétous wrote:\n>> Are you able to reproduce this problem?\n>\n> No. I just did a clone and an immediate deinit afterwards and no error.\n> Maybe you can provide a script to reproduce? Which System was this on?\n>\n> Cheers Heiko\n"},{"id":"303362","messageId":"20161005133650.GB30930@book.hvoigt.net","threadId":"43959","inReplyTo":"CAPOqYV+xsrLk7y1hJYHZFY8OfkxVRwPcZBdqhdgrhThqdZysQA@mail.gmail.com","subject":"Re: Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2016-10-05T13:36:50Z","receivedAt":"2016-10-05T13:37:35Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nplease do not top-post the conversation will otherwise get hard to\nfollow. Thank you.\n\nOn Tue, Oct 04, 2016 at 05:46:45PM +0200, Thomas Bétous wrote:\n> Thank you for your answer and sorry for the delay (I was on vacation...).\n> \n> I am using git 2.9.0.windows.1 (run on Windows 7 via git bash).\n\nMy initial reaction is that this might be a problem with line endings. Did you\ncheck whether you get any diff when you do a 'git diff' after the clone?\n\nMaybe the variable 'core.autocrlf' is set to 'input' ? Have a look at 'git help\nconfig'\n\n> I tested it on this repo:\n> https://github.com/githubtraining/example-dependency.git\n> The same problem occurs.\n> Here a small script to reproduce the error on my PC:\n> #!/bin/bash\n> git clone https://github.com/githubtraining/example-dependency.git\n> cd example-dependency\n> git submodule deinit js\n> \n> It ends with this error:\n> fatal: Please stage your changes to .gitmodules or stash them to proceed\n> Submodule work tree 'js' contains local modifications; use '-f' to discard them\n\nHere I get\n\n$ git submodule deinit js\nCleared directory 'js'\n\nSo all seems fine.\n\n> Is the script working on your PC?\n\nYes. I am on Mac OS X though.\n\nCheers Heiko\n"},{"id":"303467","messageId":"20161006092040.GA38550@book.hvoigt.net","threadId":"43959","inReplyTo":"CAPOqYV+SR8=E24HR18ygJ-J-rV7=FedU+gGpq9mp+a7Mfk2LiQ@mail.gmail.com","subject":"Re: Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2016-10-06T09:20:41Z","receivedAt":"2016-10-06T09:20:55Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nplease also keep the mailinglist in the CC so everyone can read this.\n\nOn Thu, Oct 06, 2016 at 09:11:05AM +0200, Thomas Bétous wrote:\n> On Wed, Oct 5, 2016 at 3:36 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> \n> >\n> > My initial reaction is that this might be a problem with line endings. Did\n> > you\n> > check whether you get any diff when you do a 'git diff' after the clone?\n> >\n> > Maybe the variable 'core.autocrlf' is set to 'input' ? Have a look at 'git\n> > help\n> > config'\n> \n> \n> When I do a 'git diff' right after the clone, nothing appears.\n> Moreover my global setting for core.autocrlf is true. (This was configured\n> on purpose as I work on Windows whereas the repositories are hosted on an\n> UNIX server.)\n\nSo I guess the same applies to 'git status'?\n\n> Nevertheless when I change core.autocrlf to 'input', the error disappears\n> and I got the expected behavior for git submodule deinit...\n> So I guess it is just a configuration problem but I do not understand why\n> core.autocrlf should be set to 'input' to remove this error. Do you have\n> any idea?\n\nThis is indeed strange. That's why I asked whether 'git diff' shows\nanything. I was suspecting that the .gitmodules is somehow checked out\nin UNIX format. And the fact that setting core.autocrlf to\n'input' seems to fix it supports that.\n\nI currently do not have access to a windows machine as the moment to\ntest this. Copying the windows mailing list maybe someone over there\ncan reproduce and help with the issue[1].\n\nCheers Heiko\n\n[1] http://public-inbox.org/git/%3CCAPOqYV+xsrLk7y1hJYHZFY8OfkxVRwPcZBdqhdgrhThqdZysQA@mail.gmail.com%3E/\n"},{"id":"303494","messageId":"CAPOqYV+DWVeK3sfgtDXzTF=es3d23dZq+rMeMcTuJ7kF0UjNkA@mail.gmail.com","threadId":"43959","inReplyTo":"20161006092040.GA38550@book.hvoigt.net","subject":"Re: Bug Report: \"git submodule deinit\" fails right after a clone","fromName":"Thomas Bétous","fromEmail":"th.betous@gmail.com","sentAt":"2016-10-06T16:10:19Z","receivedAt":"2016-10-06T16:11:00Z","isPatch":false,"sender":{"key":"th.betous@gmail.com","avatar":null},"body":"Hello,\n\nSorry again for the mailing list...\n\nOn Thu, Oct 6, 2016 at 11:20 AM, Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> So I guess the same applies to 'git status'?\n\nNo, it is the strange thing.\nAs told in my very first message here what happens after git diff and\ngit status:\n\n$ git clone https://github.com/githubtraining/example-dependency.git\nCloning into 'example-dependency'...\nremote: Counting objects: 35, done.\nremote: Total 35 (delta 0), reused 0 (delta 0), pack-reused 35\nUnpacking objects: 100% (35/35), done.\nChecking connectivity... done.\n$ cd example-dependency\n$ git submodule deinit js\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'js' contains local modifications; use '-f' to discard them\n$ git diff\n[no output]\n$ git submodule deinit js\nfatal: Please stage your changes to .gitmodules or stash them to proceed\nSubmodule work tree 'js' contains local modifications; use '-f' to discard them\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\nnothing to commit, working directory clean\n$ git submodule deinit js\nCleared directory 'js'\n\nSo as you can see, the 'git status' makes the problem magically disappear.\n\nThomas\n"}]}