{"thread":{"id":"47462","subject":"Bug with \"git submodule update\" + subrepo with differing path/name?","startedAt":"2017-12-18T23:18:50Z","lastAt":"2017-12-21T23:08:17Z","messageCount":11,"participants":["Andreas Urke","Stefan Beller","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"335004","messageId":"CAFBGMVPBwxeSXCTcoBdxDbYtJo-38w=tf4T6-rNWuys=3drP+A@mail.gmail.com","threadId":"47462","inReplyTo":null,"subject":"Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Andreas Urke","fromEmail":"arurke@gmail.com","sentAt":"2017-12-18T23:18:24Z","receivedAt":"2017-12-18T23:18:50Z","isPatch":false,"sender":{"key":"arurke@gmail.com","avatar":null},"body":"Hi,\n\nI have a repo with two submodules. I regularly use \"git submodule\nupdate\", which works fine for one subrepo, but not for the other. The\nonly relevant difference I can think of between these two subrepos is\nthat the latter one does not have a matching path and name:\n\n$ cat .gitmodules\n[submodule \"subrepo1\"]\n    path = subrepo1\n    url = git@gitlab.com:subrepo1.git\n[submodule \"name_subrepo2\"]\n    path = subrepo2\n    url = git@gitlab.com:name_subrepo2.git\n\nAnd a reproduction looks like this:\n\n$ git --version\ngit version 2.15.1\n\n$ git status\nHEAD detached at 05412d4\nChanges not staged for commit:\n\nmodified:   subrepo1 (new commits)\nmodified:   subrepo2 (new commits)\n\n$ git submodule update\nSubmodule path 'subrepo1': checked out\n'e4785498130ec4188bb1745f27e311bff08ed4c8'\n\n$ git status\nHEAD detached at 05412d4\nChanges not staged for commit:\n\nmodified:   subrepo2  (new commits)\n\nChecking out the relevant commit manually in subrepo2 works fine (and\nis what I end up doing).\n\nRegards,\nAndreas Urke\n"},{"id":"335032","messageId":"20171219180230.254881-1-sbeller@google.com","threadId":"47462","inReplyTo":"CAFBGMVPBwxeSXCTcoBdxDbYtJo-38w=tf4T6-rNWuys=3drP+A@mail.gmail.com","subject":"[PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-19T18:02:30Z","receivedAt":"2017-12-19T18:02:44Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"I tried reproducing the issue (based on the `next` branch, not 2.15,\nbut I do not recall any changes in the submodule area lately), and\ncould not come up with a reproduction recipe, but here is what I got so\nfar, maybe you can take it from here (i.e. either make the test case\nmore like your environment such that it fails, or rather bisect git\nto tell us the offending commit) ?\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n t/t7406-submodule-update.sh | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 6f083c4d68..d957305c38 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -978,4 +978,20 @@ test_expect_success 'git clone passes the parallel jobs config on to submodules'\n \trm -rf super4\n '\n \n+test_expect_success 'git submodule update works with submodules with name/path difference' '\n+\ttest_create_repo super6 &&\n+\t(\n+\t\tcd super6 &&\n+\t\tgit submodule add ../submodule sub1 &&\n+\t\tgit submodule add --name testingname ../submodule sub2 &&\n+\t\tgit commit -m initial &&\n+\t\tgit -C sub1 checkout HEAD^ &&\n+\t\tgit -C sub2 checkout HEAD^ &&\n+\n+\t\tgit submodule update >actual &&\n+\t\tgrep sub1 actual &&\n+\t\tgrep sub2 actual\n+\t)\n+'\n+\n test_done\n-- \n2.15.1.620.gb9897f4670-goog\n\n"},{"id":"335047","messageId":"xmqqk1xitl6l.fsf@gitster.mtv.corp.google.com","threadId":"47462","inReplyTo":"20171219180230.254881-1-sbeller@google.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-19T22:19:46Z","receivedAt":"2017-12-19T22:19:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> I tried reproducing the issue (based on the `next` branch, not 2.15,\n> but I do not recall any changes in the submodule area lately), and\n> could not come up with a reproduction recipe,...\n\nI do not offhand recall anything; the closest I can think of is the\nthree-patch series <20171016135623.GA12756@book.hvoigt.net> that\ntaught the on-demand recursive fetch to pay attention to the location\nin the superproject tree a submodule is bound to.\n\n    4b4acedd61 submodule: simplify decision tree whether to or not to fetch\n    c68f837576 implement fetching of moved submodules\n    01ce12252c fetch: add test to make sure we stay backwards compatible\n\nBut IIRC, \"submodule update\" uses a separate codepath?\n"},{"id":"335055","messageId":"CAGZ79kbqntXuYuLGF7zjXfQ5X998QdEba20yy8A0cqS=DaRxFA@mail.gmail.com","threadId":"47462","inReplyTo":"xmqqk1xitl6l.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-19T22:33:18Z","receivedAt":"2017-12-19T22:33:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Dec 19, 2017 at 2:19 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> I tried reproducing the issue (based on the `next` branch, not 2.15,\n>> but I do not recall any changes in the submodule area lately), and\n>> could not come up with a reproduction recipe,...\n>\n> I do not offhand recall anything; the closest I can think of is the\n> three-patch series <20171016135623.GA12756@book.hvoigt.net> that\n> taught the on-demand recursive fetch to pay attention to the location\n> in the superproject tree a submodule is bound to.\n\nI tried the same test on 2.15 and cannot reproduce there either.\n\n>\n>     4b4acedd61 submodule: simplify decision tree whether to or not to fetch\n>     c68f837576 implement fetching of moved submodules\n>     01ce12252c fetch: add test to make sure we stay backwards compatible\n>\n> But IIRC, \"submodule update\" uses a separate codepath?\n\nYes, any portion of git-submodule.sh that calls out to C is going\nthrough the submodule--helper. I want to revive the port of that\nshell script to C again.\n\nThe \"submodule update\" uses the submodule helper to obtain\nthe list of submodules and then does a \"git -C $sub fetch\" in there.\n\nStefan\n"},{"id":"335066","messageId":"CAFBGMVO+P99hJ_nKgCJ4OqhMEdRdc3m8KHNS1pPrrhU_0wS6=A@mail.gmail.com","threadId":"47462","inReplyTo":"CAGZ79kbqntXuYuLGF7zjXfQ5X998QdEba20yy8A0cqS=DaRxFA@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Andreas Urke","fromEmail":"arurke@gmail.com","sentAt":"2017-12-20T08:22:48Z","receivedAt":"2017-12-20T08:23:15Z","isPatch":true,"sender":{"key":"arurke@gmail.com","avatar":null},"body":"Thanks for looking into this.\n\nI was able to reproduce it from scratch, but I followed my earlier\nworkflow where I first created the subrepos, and then later renamed\nit. At the time I was not able to find any command to rename without\nchanging the path (and I was not able find one now either, is there\nany?), so I edited name and path in .gitmodules and ran git submodule\nsync. Am I asking for trouble doing it that way?\n\nLet me know if you need the exact steps I followed.\n\nAndreas\n\n\nOn 19 December 2017 at 23:33, Stefan Beller <sbeller@google.com> wrote:\n> On Tue, Dec 19, 2017 at 2:19 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Stefan Beller <sbeller@google.com> writes:\n>>\n>>> I tried reproducing the issue (based on the `next` branch, not 2.15,\n>>> but I do not recall any changes in the submodule area lately), and\n>>> could not come up with a reproduction recipe,...\n>>\n>> I do not offhand recall anything; the closest I can think of is the\n>> three-patch series <20171016135623.GA12756@book.hvoigt.net> that\n>> taught the on-demand recursive fetch to pay attention to the location\n>> in the superproject tree a submodule is bound to.\n>\n> I tried the same test on 2.15 and cannot reproduce there either.\n>\n>>\n>>     4b4acedd61 submodule: simplify decision tree whether to or not to fetch\n>>     c68f837576 implement fetching of moved submodules\n>>     01ce12252c fetch: add test to make sure we stay backwards compatible\n>>\n>> But IIRC, \"submodule update\" uses a separate codepath?\n>\n> Yes, any portion of git-submodule.sh that calls out to C is going\n> through the submodule--helper. I want to revive the port of that\n> shell script to C again.\n>\n> The \"submodule update\" uses the submodule helper to obtain\n> the list of submodules and then does a \"git -C $sub fetch\" in there.\n>\n> Stefan\n"},{"id":"335094","messageId":"CAGZ79kZf8GL1DY6Vmc-byEOOy+hrKF8X8qRPM6jNO-La+rD4uw@mail.gmail.com","threadId":"47462","inReplyTo":"CAFBGMVO+P99hJ_nKgCJ4OqhMEdRdc3m8KHNS1pPrrhU_0wS6=A@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-20T17:54:44Z","receivedAt":"2017-12-20T17:54:52Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Dec 20, 2017 at 12:22 AM, Andreas Urke <arurke@gmail.com> wrote:\n> Thanks for looking into this.\n>\n> I was able to reproduce it from scratch, but I followed my earlier\n> workflow where I first created the subrepos, and then later renamed\n> it. At the time I was not able to find any command to rename without\n> changing the path (and I was not able find one now either, is there\n> any?), so I edited name and path in .gitmodules and ran git submodule\n> sync. Am I asking for trouble doing it that way?\n\n\"rename without changing the path\" sounds like a red flag to me,\nas the submodule name was introduced specifically to be a constant\nas the path may change, whereas the name ought to never change.\n\n\n\n\n>\n> Let me know if you need the exact steps I followed.\n\nWell yes, ideally as a shell script (or even embedded into our test suite).\n"},{"id":"335129","messageId":"CAFBGMVMmLX4BjkQ8Xd4bQBCgoYYxWTU-p2pNF=b8JNsUsKXwUA@mail.gmail.com","threadId":"47462","inReplyTo":"CAGZ79kZf8GL1DY6Vmc-byEOOy+hrKF8X8qRPM6jNO-La+rD4uw@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Andreas Urke","fromEmail":"arurke@gmail.com","sentAt":"2017-12-21T16:21:26Z","receivedAt":"2017-12-21T16:21:52Z","isPatch":true,"sender":{"key":"arurke@gmail.com","avatar":null},"body":"If I am entering into undefined behavior territory with the renaming\nthen there might not be any point to pursue this further, but in any\ncase, script below:\n\nApologies up-front for the verbosity, there are probably a lot of\nunnecessary steps and git shortcuts missed - I just wanted it to\nexactly match my scenario. Note that it is divided into two parts as\nit requires you to edit .gitmodules.\n\nPart 1:\n\ncd ~/\n# Make sub repos and add a commit to each\nmkdir super && cd super\nmkdir sub1 && mkdir sub2\ncd sub1\ngit init && touch first && git add . && git commit -m \"first\"\ncd ../sub2\ngit init && touch first && git add . && git commit -m \"first\"\ncd ..\n\n# Make super repo, add subrepos, and commit\ngit init\ngit submodule add ./sub1\ngit submodule add ./sub2\ngit add .\ngit commit -m \"first\"\n\n# Edit .gitmodules, change sub2 name and path to sub2_newname:\n# $ cat .gitmodules\n# [submodule \"sub1\"]\n# path = sub1\n# url = ./sub1\n# [submodule \"sub2_newname\"]\n# path = sub2\n# url = ./sub2_newname\n\nPart 2:\n\ncd ~/\n# Sync submodule after we edited .gitmodules\ncd super\ngit submodule sync\n\n# Commit in subrepos and commit this to superrepo\ncd sub1\ntouch second && git add . && git commit -m \"second\"\ncd ../sub2\ntouch second && git add . && git commit -m \"second\"\ncd ..\ngit add .\ngit commit -m \"second\"\n\n# Commit in subrepos and commit this to superrepo\ncd sub1\ntouch third && git add . && git commit -m \"third\"\ncd ../sub2\ntouch third && git add . && git commit -m \"third\"\ncd ..\ngit add .\ngit commit -m \"third\"\n\ngit checkout HEAD^\ngit status\ngit submodule update\ngit status # Observe only sub1 repo was updated\n\nOn 20 December 2017 at 18:54, Stefan Beller <sbeller@google.com> wrote:\n> On Wed, Dec 20, 2017 at 12:22 AM, Andreas Urke <arurke@gmail.com> wrote:\n>> Thanks for looking into this.\n>>\n>> I was able to reproduce it from scratch, but I followed my earlier\n>> workflow where I first created the subrepos, and then later renamed\n>> it. At the time I was not able to find any command to rename without\n>> changing the path (and I was not able find one now either, is there\n>> any?), so I edited name and path in .gitmodules and ran git submodule\n>> sync. Am I asking for trouble doing it that way?\n>\n> \"rename without changing the path\" sounds like a red flag to me,\n> as the submodule name was introduced specifically to be a constant\n> as the path may change, whereas the name ought to never change.\n>\n>\n>\n>\n>>\n>> Let me know if you need the exact steps I followed.\n>\n> Well yes, ideally as a shell script (or even embedded into our test suite).\n"},{"id":"335137","messageId":"CAGZ79kauYRLaPKsUKxvsc-T+KzMt2UsyoDLzdyZON_vjp6y28w@mail.gmail.com","threadId":"47462","inReplyTo":"CAFBGMVMmLX4BjkQ8Xd4bQBCgoYYxWTU-p2pNF=b8JNsUsKXwUA@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-21T18:55:52Z","receivedAt":"2017-12-21T18:55:59Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Dec 21, 2017 at 8:21 AM, Andreas Urke <arurke@gmail.com> wrote:\n> If I am entering into undefined behavior territory with the renaming\n> then there might not be any point to pursue this further, but in any\n> case, script below:\n>\n> Apologies up-front for the verbosity, there are probably a lot of\n> unnecessary steps and git shortcuts missed - I just wanted it to\n> exactly match my scenario. Note that it is divided into two parts as\n> it requires you to edit .gitmodules.\n>\n> Part 1:\n>\n> cd ~/\n> # Make sub repos and add a commit to each\n> mkdir super && cd super\n> mkdir sub1 && mkdir sub2\n> cd sub1\n> git init && touch first && git add . && git commit -m \"first\"\n> cd ../sub2\n> git init && touch first && git add . && git commit -m \"first\"\n> cd ..\n>\n> # Make super repo, add subrepos, and commit\n> git init\n> git submodule add ./sub1\n> git submodule add ./sub2\n> git add .\n> git commit -m \"first\"\n>\n> # Edit .gitmodules, change sub2 name and path to sub2_newname:\n> # $ cat .gitmodules\n> # [submodule \"sub1\"]\n> # path = sub1\n> # url = ./sub1\n> # [submodule \"sub2_newname\"]\n> # path = sub2\n> # url = ./sub2_newname\n>\n\nA couple of things here:\n(a) In a script you could do this via\n    git config -f .gitmodules --rename-section <old> <new>\n(b) This is not just undefined, but rather Git explicitly assumes\n    the user does not rename the section themselves.\n\nThe reason for this is found in gits history:\n1. submodules were invented\n2. submodule configuration such as where to obtain\n    the submodule from needs some place, and at the time\n    submodule.<path>.url inside the .gitmodules file seemed\n    like a good idea.\n3. \"What if we want git-mv, git-rm support for submodules?\"\n    Or for example when bisecting and jumping between revisions\n    where the submodule exists or does not exists. To solve\n    this problem, the concept of a \"submodule name\" was invented,\n    such that the submodules git dir can be put into the\n    superprojects .git/modules/<name> dir, and the working tree\n    only needs to have a \".git\" file pointing at that gitdir. The the\n    working tree of the submodule can be removed while keeping\n    the submodules git dir (with potentially important information\n    such as local-only commits) around! Success!\n\n    The transition path is also easy:\n    These newly \"named\" submodules have an additional entry of\n    'submodule.<name>.path =<path>'. Note how the subsection\n    part of the config changed its meaning, but that is ok, as the\n    name is allowed to be equal to the <path> value, and keeps\n    all config related to one submodule in one section. Easy but\n    confusing as now we have to adhere to a couple assumptions:\n    The <path> value must match where it is in the working tree,\n    the <name> however must not be changed because that is\n    where we'll find its repository inside the superproject.\n    And confusingly these two keys have often the same value,\n    for this historic reason.\n\n4. (rather lately): We need to fix the submodule mess.\n    While in (3) we were unclear about name/path issues,\n    and tried to be super backwards compatible, now we'd\n    rather want the submodules to be well-defined. So we'll\n    try to write some docs, such as gitsubmodules [1] in addition\n    to the usage manual of \"git submodule\"[2]. Of course there is\n    still the description of the .gitmodules file[3].\n\n[1] https://www.kernel.org/pub/software/scm/git/docs/gitsubmodules.html\n[2] https://www.kernel.org/pub/software/scm/git/docs/git-submodule.html\n[3] https://www.kernel.org/pub/software/scm/git/docs/gitmodules.html\n\nI guess in [1] we'd want to add a discussion on what the <name> and\nwhat the <path> is for and why one can change but not the other.\n\nI think you ran into trouble here because you and Git had\ndiffering assumptions on some part of the submodule model.\nIs there any part of the documentation, configuration or some\ncommands that would have helped explaining some of these things?\n(i.e. What do we best patch to help others from running into the\nsame issue?)\n\nThanks,\nStefan\n"},{"id":"335157","messageId":"CAFBGMVOjCK_XnqJpTvPs=joXgfOH9SDWe0pJwmgYx-5-+FL+uA@mail.gmail.com","threadId":"47462","inReplyTo":"CAGZ79kauYRLaPKsUKxvsc-T+KzMt2UsyoDLzdyZON_vjp6y28w@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Andreas Urke","fromEmail":"arurke@gmail.com","sentAt":"2017-12-21T22:17:18Z","receivedAt":"2017-12-21T22:17:44Z","isPatch":true,"sender":{"key":"arurke@gmail.com","avatar":null},"body":"Thanks for the detailed explanation. Although I am not too git savvy,\nI believe I got the gist of it.\n\nRegarding your question,\nI would say the term \"name\" in an IT context makes me primarily think\nof something that is specified by a user (as opposed to e.g. an \"id\"),\nand can be altered by a user. Also, the manual mention it as a\n\"logical name\", which would further strengthen my belief that it is an\nabstraction which can be changed (as opposed to something \"physical\").\nI would be much more reluctant to change the id of something than its\nname.\n\nIn terms of the commands...In an ideal world I would obviously ask for\na --rename or mv command which would achieve what I wanted to do.\nOther than that, maybe a word about this in the man for \"git mv\"? Or\nperhaps \"git submodule sync\" could give me some kind of warning that I\ndid something strange/illegal.\n\nCan I ask you, now that I have made this mess, do you have any\nsuggestion on how to rectify it or some other way to achieve my goal?\nThe only side-effect I have seen is this update problem (been running\nthis for a few months), but after your explanations I would like to\nget back to solid ground. My use-case is that I need to follow a\nspecific folder-naming (i.e. subrepo path) convention, but I do not\nwant to use that naming as the repo name in our gitlab.\n\nRegards,\nAndreas\n\nOn 21 December 2017 at 19:55, Stefan Beller <sbeller@google.com> wrote:\n> On Thu, Dec 21, 2017 at 8:21 AM, Andreas Urke <arurke@gmail.com> wrote:\n>> If I am entering into undefined behavior territory with the renaming\n>> then there might not be any point to pursue this further, but in any\n>> case, script below:\n>>\n>> Apologies up-front for the verbosity, there are probably a lot of\n>> unnecessary steps and git shortcuts missed - I just wanted it to\n>> exactly match my scenario. Note that it is divided into two parts as\n>> it requires you to edit .gitmodules.\n>>\n>> Part 1:\n>>\n>> cd ~/\n>> # Make sub repos and add a commit to each\n>> mkdir super && cd super\n>> mkdir sub1 && mkdir sub2\n>> cd sub1\n>> git init && touch first && git add . && git commit -m \"first\"\n>> cd ../sub2\n>> git init && touch first && git add . && git commit -m \"first\"\n>> cd ..\n>>\n>> # Make super repo, add subrepos, and commit\n>> git init\n>> git submodule add ./sub1\n>> git submodule add ./sub2\n>> git add .\n>> git commit -m \"first\"\n>>\n>> # Edit .gitmodules, change sub2 name and path to sub2_newname:\n>> # $ cat .gitmodules\n>> # [submodule \"sub1\"]\n>> # path = sub1\n>> # url = ./sub1\n>> # [submodule \"sub2_newname\"]\n>> # path = sub2\n>> # url = ./sub2_newname\n>>\n>\n> A couple of things here:\n> (a) In a script you could do this via\n>     git config -f .gitmodules --rename-section <old> <new>\n> (b) This is not just undefined, but rather Git explicitly assumes\n>     the user does not rename the section themselves.\n>\n> The reason for this is found in gits history:\n> 1. submodules were invented\n> 2. submodule configuration such as where to obtain\n>     the submodule from needs some place, and at the time\n>     submodule.<path>.url inside the .gitmodules file seemed\n>     like a good idea.\n> 3. \"What if we want git-mv, git-rm support for submodules?\"\n>     Or for example when bisecting and jumping between revisions\n>     where the submodule exists or does not exists. To solve\n>     this problem, the concept of a \"submodule name\" was invented,\n>     such that the submodules git dir can be put into the\n>     superprojects .git/modules/<name> dir, and the working tree\n>     only needs to have a \".git\" file pointing at that gitdir. The the\n>     working tree of the submodule can be removed while keeping\n>     the submodules git dir (with potentially important information\n>     such as local-only commits) around! Success!\n>\n>     The transition path is also easy:\n>     These newly \"named\" submodules have an additional entry of\n>     'submodule.<name>.path =<path>'. Note how the subsection\n>     part of the config changed its meaning, but that is ok, as the\n>     name is allowed to be equal to the <path> value, and keeps\n>     all config related to one submodule in one section. Easy but\n>     confusing as now we have to adhere to a couple assumptions:\n>     The <path> value must match where it is in the working tree,\n>     the <name> however must not be changed because that is\n>     where we'll find its repository inside the superproject.\n>     And confusingly these two keys have often the same value,\n>     for this historic reason.\n>\n> 4. (rather lately): We need to fix the submodule mess.\n>     While in (3) we were unclear about name/path issues,\n>     and tried to be super backwards compatible, now we'd\n>     rather want the submodules to be well-defined. So we'll\n>     try to write some docs, such as gitsubmodules [1] in addition\n>     to the usage manual of \"git submodule\"[2]. Of course there is\n>     still the description of the .gitmodules file[3].\n>\n> [1] https://www.kernel.org/pub/software/scm/git/docs/gitsubmodules.html\n> [2] https://www.kernel.org/pub/software/scm/git/docs/git-submodule.html\n> [3] https://www.kernel.org/pub/software/scm/git/docs/gitmodules.html\n>\n> I guess in [1] we'd want to add a discussion on what the <name> and\n> what the <path> is for and why one can change but not the other.\n>\n> I think you ran into trouble here because you and Git had\n> differing assumptions on some part of the submodule model.\n> Is there any part of the documentation, configuration or some\n> commands that would have helped explaining some of these things?\n> (i.e. What do we best patch to help others from running into the\n> same issue?)\n>\n> Thanks,\n> Stefan\n"},{"id":"335158","messageId":"CAGZ79kYRYHdpyXD+VtO-Xhg_BqTkrj4qgbgEFK7opQGXGhNiAw@mail.gmail.com","threadId":"47462","inReplyTo":"CAPc5daUJXS9DJr7BRuKbNotKA-3kBnzHfn3566su+ZDwa+xc4w@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-21T22:57:40Z","receivedAt":"2017-12-21T22:57:49Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Dec 21, 2017 at 2:08 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> That sounds like a bit of revisionist history, but you weren't around\n> back then, so...\n>\n> https://public-inbox.org/git/11793556371774-git-send-email-junkio@cox.net/#r\n>\n> is my summarization of discussions before that time. There is a\n> mention of \"three-level\"\n> thing by Steven Grimm in\n> https://public-inbox.org/git/464E4C94.5070408@midwinter.com/\n> in the thread, and together with messages like\n> https://public-inbox.org/git/7vejle6p96.fsf@assigned-by-dhcp.cox.net/\n> you can see that we already knew that submodule identity (name), path\n> in the superproject (path) and where it\n> comes from (url) need to be separate things that need to be tied\n> together by .gitmodules.\n\nTaking this private reply back to the list, I hope you don't mind.\nI think linking into the archives (hence making the huge unstructured\narchive a bit more discoverable by these links) is a good idea.\n\nYes, I was not around when these discussions happened, hence I came\nup with a narrative that I can rationalize best.\n\nThis message https://public-inbox.org/git/464CF435.1010405@midwinter.com/\nhelps (me) most as that states the problem that need to be solved and I agree\nwith the issues and how to solve it. The \"symbolic names\", however, are the\ncrux there. They must not be changed, so as Andreas says, maybe \"ID\" is\na better notion than \"submodule name\".\n\nI am of the opinion that we'd even want to go as far as to not expose\nthis symbolic to the user.\n\nSo if we redesign from scratch, I would not have \"gitlink entries\"\nbut rather \"special blobs\"[1], that contain the submodule sha1,\nas well as their ID.\n\nA special blob could look like:\n\n  git cat-file \"kernel/\"\n  version <sha1>\n  id <another hash value, determined at creation time>\n\nAdditionally you'd have slight guidance of id -> URL in\nan extra ref, versioned independently of the main history:\n\n  <other hash> -> git://kernel.org/...\n\n(A)\nSo if linux moves away from kernel.org, you can change that ref\nindependently of your history at that time, such that even old\nversions of your main history can obtain the kernel from the correct\nURL. Of course a porcelain command could do the double lookup\nsuch that the user can say \"kernel/ -> newURL\" without needing\nto have knowledge of the internal ID.\n\n(B)\nNow if you want to move the submodule locally, you can do so by\nhaving that special blob at a different path in your tree.\ngit-mv \"just works\" even for nested submodules. No need to\nrewrite the .gitmodules file.\n\n(C)\nWhat if you want to drop linux and use some BSD?\nThen you change the ID such that a new submodule repo\nis created inside .git/modules/. Of course it is also pinned\nto a different sha1. A porcelain command such as\n\"git submodule replace\" would sound like a good porcelain-ish.\n\nI think this so far is a clean design, but it is incompatible with history.\n\nThe really big difference is that the ID is the core thing that everything\nrevolves around (similar to the submodule name), but is tied to the path\nand is hidden as much as possible from the user, who can use given\ncommands for each of the scenarios.\n\nThe big flaw of this that the ID is sort of random and not based\non content, which is counter to Gits philosophy as a content\naddressable FS. Maybe the ID can be set to\nHASH(<first version> +<path>), such that when two people\nindependently of each other make a submodule pointing at the\nsame commit at the same path, they'd have the same tree-id.\n\nThanks,\nStefan\n\n[1] An in office discussion hinted at that \"special blobs\" are not\nthat special. git-LFS uses this mechanism, but of course their\ndesign flaw is to keep it out of main-Git. But one could posit\n\"submodules can be implemented using smudge filters alone\".\n"},{"id":"335159","messageId":"CAGZ79kY1=TysCagomHaqzV4w+3DMpdTQ2ki9tVHbL4pYRecXMw@mail.gmail.com","threadId":"47462","inReplyTo":"CAFBGMVOjCK_XnqJpTvPs=joXgfOH9SDWe0pJwmgYx-5-+FL+uA@mail.gmail.com","subject":"Re: [PATCH] Re: Bug with \"git submodule update\" + subrepo with differing path/name?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-21T23:08:07Z","receivedAt":"2017-12-21T23:08:17Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Dec 21, 2017 at 2:17 PM, Andreas Urke <arurke@gmail.com> wrote:\n> Thanks for the detailed explanation. Although I am not too git savvy,\n> I believe I got the gist of it.\n>\n> Regarding your question,\n> I would say the term \"name\" in an IT context makes me primarily think\n> of something that is specified by a user (as opposed to e.g. an \"id\"),\n\nID sounds great.\n\n> and can be altered by a user. Also, the manual mention it as a\n> \"logical name\", which would further strengthen my belief that it is an\n> abstraction which can be changed (as opposed to something \"physical\").\n> I would be much more reluctant to change the id of something than its\n> name.\n\nIf you changed the name in all places, it would have been no problem. ;)\nSo once you did the \"git config -f .gitmodules --rename-section ...\",\nyou'd also have to \"mv .git/modules/<old-name> .git/modules/<new-name>\"\nand then it would work fine for you. (You would also need to instruct\nany collaborators to run the move command when they pull your changes.\nSo it is more of a \"in theory it works\", rather than practical advice here)\n\n> In terms of the commands...In an ideal world I would obviously ask for\n> a --rename or mv command which would achieve what I wanted to do.\n> Other than that, maybe a word about this in the man for \"git mv\"? Or\n\ngit-mv moves the path, not the name of the submodule, though.\n\n> perhaps \"git submodule sync\" could give me some kind of warning that I\n> did something strange/illegal.\n\nThat is harder than thought, because it is normal that a submodule\nworktree doesn't exist at the given path (not initialized).\nAlso it is totally valid to have outdated entries in the .gitmodules file. :/\n\n> Can I ask you, now that I have made this mess, do you have any\n> suggestion on how to rectify it or some other way to achieve my goal?\n\nLooking at the script you had above, I would think you need to init\nthe renamed submodule again, not sure if anything else needs\nto be done, as now you'd have essentially two repositories inside\nthe superprojects .git/modules/ for just one logical submodule.\n\nSo I would assume if you were to re-clone the superproject\neverything works out fine again (except for bisection/checkout\nbefore that rename. ;) But for that you can symlink the\noldname to the newname inside the .git/modules/ of the superproject\nI would assume.\n\nStefan\n"}]}