{"thread":{"id":"40770","subject":"git clone --recursive should run git submodule update with flag --remote","startedAt":"2015-11-11T12:46:30Z","lastAt":"2015-11-11T19:48:08Z","messageCount":2,"participants":["Stanislav","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"273189","messageId":"loom.20151111T133121-436@post.gmane.org","threadId":"40770","inReplyTo":null,"subject":"git clone --recursive should run git submodule update with flag --remote","fromName":"Stanislav","fromEmail":"s.seletskiy@gmail.com","sentAt":"2015-11-11T12:46:30Z","receivedAt":"2015-11-11T12:46:30Z","isPatch":false,"sender":{"key":"s.seletskiy@gmail.com","avatar":null},"body":"Consider two repositories, A and B.\n\nRepo A is embedded into B by using submodule:\n\n  git submodule add -b master <url-to-A> sub-a\n\nSo, submodule sub-a is set to track master branch of the repo A.\n\nRunning git submodule update --remote inside repo B will automatically\nupdate and checkout submodule sub-a to the latest master commit (as expected).\n\nHowever, when using git clone --recursive <url-to-B>, repo B will be cloned\nwith submodule A checkouted to the commmit which was recorded on git\nsubmodule add command, not the master commit.\n\nExpected behaviour is to automatically update checkout commit pointed by\nbranch, that was specified by -b flag in the git submodule add invocation.\n\nReason for this behaviour is that line:\n\n  https://github.com/git/git/blob/master/builtin/clone.c#L99\n\nI guess, it should be changed to include --remote flag.\n"},{"id":"273218","messageId":"CAGZ79kbOyXm11uPCXcDJzKxbQzBx6ZOmq0TS8kc52xy-qV_FiQ@mail.gmail.com","threadId":"40770","inReplyTo":"loom.20151111T133121-436@post.gmane.org","subject":"Re: git clone --recursive should run git submodule update with flag --remote","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-11-11T19:48:08Z","receivedAt":"2015-11-11T19:48:08Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Nov 11, 2015 at 4:46 AM, Stanislav <s.seletskiy@gmail.com> wrote:\n> Consider two repositories, A and B.\n>\n> Repo A is embedded into B by using submodule:\n>\n>   git submodule add -b master <url-to-A> sub-a\n>\n> So, submodule sub-a is set to track master branch of the repo A.\n>\n> Running git submodule update --remote inside repo B will automatically\n> update and checkout submodule sub-a to the latest master commit (as expected).\n>\n> However, when using git clone --recursive <url-to-B>, repo B will be cloned\n> with submodule A checkouted to the commmit which was recorded on git\n> submodule add command, not the master commit.\n>\n> Expected behaviour is to automatically update checkout commit pointed by\n> branch, that was specified by -b flag in the git submodule add invocation.\n\nTo achieve what you want to do, you can first clone B and then\ndo a `git submodule update` using the --remote option yourself.\nThat is cumbersome however, I agree.\n\n>\n> Reason for this behaviour is that line:\n>\n>   https://github.com/git/git/blob/master/builtin/clone.c#L99\n>\n> I guess, it should be changed to include --remote flag.\n\nI guess we could tweak the behavior to include the --remote flag\nwhen the branch is recorded in the .gitmodules file.\n\nJust wondering what should happen if there are both a sha1\nand a branch recorded?\n\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}