{"thread":{"id":"45308","subject":"Re: git init --separate-git-dir does not update symbolic .git links for submodules","startedAt":"2017-03-07T19:35:59Z","lastAt":"2017-03-07T19:59:46Z","messageCount":2,"participants":["Valery Tolstov","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"313441","messageId":"1488913150.8812.0@smtp.yandex.ru","threadId":"45308","inReplyTo":null,"subject":"Re: git init --separate-git-dir does not update symbolic .git links for submodules","fromName":"Valery Tolstov","fromEmail":"me@vtolstov.org","sentAt":"2017-03-07T18:59:10Z","receivedAt":"2017-03-07T19:35:59Z","isPatch":false,"sender":{"key":"me@vtolstov.org","avatar":"https://avatars.githubusercontent.com/u/1188278?v=4"},"body":"I think we can reuse code from module_clone that writes .git link.\nPossibly this code fragment needs to be factored out from module_clone\n\nAlso, to fix all the links, we need to obtain the list of submodules\nand then iterate over them. module_list command iterates\nand prints the result to stdout. Maybe we can reuse this output.\nOr create separate function that returns the list of submodules.\n\nCan we call these functions from submodule--helper inside init command,\nor run them thorugh internal command interface?\n\nIn my opinion, make submodule--helper fully responsible for link fixes\nwould be a good solution. Then we create two additional function, one\nthat fixes all submodules on the current level, and another that\nfixes individual submodule.\nAlthough it looks good, I'm not quite sure that it's really good.\n\nSo, maybe we can do link fixes like this:\n\n    1. Start fixing from init command using submodule--helper, with\n       subcommand that fixes all submodules on current level\n    2. Each submodule processed with another subcommand/function in\n       submodule--helper individually\n    3. Repeat for current submodule recursively\n\nGlad to see your advices.\n\nRegards,\n  Valery Tolstov\n\n\n\n"},{"id":"313443","messageId":"CAGZ79kY+1E-wg0-uzGJmE+haOE+1WCmg0Eux7rWGtkU_aBDQ9g@mail.gmail.com","threadId":"45308","inReplyTo":"1488913150.8812.0@smtp.yandex.ru","subject":"Re: git init --separate-git-dir does not update symbolic .git links for submodules","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-03-07T19:59:35Z","receivedAt":"2017-03-07T19:59:46Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Mar 7, 2017 at 10:59 AM, Valery Tolstov <me@vtolstov.org> wrote:\n> I think we can reuse code from module_clone that writes .git link.\n> Possibly this code fragment needs to be factored out from module_clone\n\nThat fragment already exists, see dir.h:\nconnect_work_tree_and_git_dir(work_tree, git_dir);\nMaybe another good microproject is to use that in module_clone.\n\n>\n> Also, to fix all the links, we need to obtain the list of submodules\n> and then iterate over them.\n\nRight, but a submodule may have a nested submodule.\nSo we need to fix each submodule from that list recursively,\ni.e. not just the submodule itself, but any potential nested\nsubmodule in that submodule, too.\n(the listing doesn't list these nested submodules)\n\nSo we would call\n\n    fix_gitlink(sub)\n    {\n        fix_locally(sub);\n\n        // have a child process that calls\n        // this function on any submodule inside sub.\n    }\n\n> module_list command iterates\n> and prints the result to stdout. Maybe we can reuse this output.\n> Or create separate function that returns the list of submodules.\n\nyeah you can make use of module_list_compute to just produce\nthe list internally.\n\n>\n> Can we call these functions from submodule--helper inside init command,\n> or run them thorugh internal command interface?\n\nBoth sounds fine, though calling internally is preferable for\nperformance reasons.\n\n>\n> In my opinion, make submodule--helper fully responsible for link fixes\n> would be a good solution. Then we create two additional function, one\n> that fixes all submodules on the current level, and another that\n> fixes individual submodule.\n> Although it looks good, I'm not quite sure that it's really good.\n\nThat sounds good to me.\n\nSo \"git init --separate-git-dir\" calls internally a new function\nin the submodule--helper to\n\n>\n> So, maybe we can do link fixes like this:\n>\n>    1. Start fixing from init command using submodule--helper, with\n>       subcommand that fixes all submodules on current level\n\nfor this step we do not change the repository we are in, so there\nis no need to call a new process, but we rather want to\ncall it internally.\n\n>    2. Each submodule processed with another subcommand/function in\n>       submodule--helper individually\n\nsounds good.\n\n>    3. Repeat for current submodule recursively\n\nand this recursive action needs to have its own process in the submodule,\ne.g. \"git submodule--helper --recursive fix-git-links\"\n\n>\n> Glad to see your advices.\n>\n> Regards,\n>  Valery Tolstov\n\nRegards,\nStefan\n"}]}