{"thread":{"id":"14336","subject":"[PATCH] git-submodule - register module url if adding in place","startedAt":"2008-07-08T02:37:10Z","lastAt":"2008-07-09T00:11:16Z","messageCount":4,"participants":["Mark Levedahl","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"82526","messageId":"1215484630-3784-1-git-send-email-mlevedahl@gmail.com","threadId":"14336","inReplyTo":null,"subject":"[PATCH] git-submodule - register module url if adding in place","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-07-08T02:37:10Z","receivedAt":"2008-07-08T02:37:10Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"When adding a new submodule in place, meaning the user created the\nsubmodule as a git repo in the tree first, we don't go through\ngit submodule init to register the module. Thus, the url is\nnot stored in .git/config, and no git operation will ever do so. In\nthis case, assume the url the user supplies to git add is the one\nthat should be registered, and do so.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-submodule.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 099a7d7..7525922 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -173,6 +173,16 @@ cmd_add()\n \t\telse\n \t\t\tdie \"'$path' already exists and is not a valid git repo\"\n \t\tfi\n+\n+\t\tcase \"$repo\" in\n+\t\t./*|../*)\n+\t\t\turl=$(resolve_relative_url \"$repo\") || exit\n+\t\t    ;;\n+\t\t*)\n+\t\t\turl=\"$repo\"\n+\t\t\t;;\n+\t\tesac\n+\t\tgit config submodule.\"$path\".url \"$url\"\n \telse\n \t\tcase \"$repo\" in\n \t\t./*|../*)\n-- \n1.5.6.2.271.g73ad8\n"},{"id":"82589","messageId":"alpine.DEB.1.00.0807081332580.4319@eeepc-johanness","threadId":"14336","inReplyTo":"1215484630-3784-1-git-send-email-mlevedahl@gmail.com","subject":"Re: [PATCH] git-submodule - register module url if adding in place","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-08T11:34:33Z","receivedAt":"2008-07-08T11:34:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 7 Jul 2008, Mark Levedahl wrote:\n\n> When adding a new submodule in place, meaning the user created the \n> submodule as a git repo in the tree first, we don't go through git \n> submodule init to register the module. Thus, the url is not stored in \n> .git/config, and no git operation will ever do so. In this case, assume \n> the url the user supplies to git add is the one that should be \n> registered, and do so.\n\nI agree with Sylvain here, namely that this is too dangerous.  Imagine \nthis very valid scenario:\n\n\t$ git clone <somewhere> abc\n\t$ git submodule add abc\n\nBummer.\n\nYes, happened to me.\n\nSo I'd like this to be an error, not something that tries to be helpful, \nwhen it clearly cannot be.\n\nCiao,\nDscho\n"},{"id":"82652","messageId":"4873FF6E.2020602@gmail.com","threadId":"14336","inReplyTo":"alpine.DEB.1.00.0807081332580.4319@eeepc-johanness","subject":"Re: [PATCH] git-submodule - register module url if adding in place","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-07-08T23:59:42Z","receivedAt":"2008-07-08T23:59:42Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Johannes Schindelin wrote:\n> I agree with Sylvain here, namely that this is too dangerous.  Imagine \n> this very valid scenario:\n>\n> \t$ git clone <somewhere> abc\n> \t$ git submodule add abc\n>\n> Bummer.\n>\n> Yes, happened to me.\n>\n> So I'd like this to be an error, not something that tries to be helpful, \n> when it clearly cannot be.\n>\n> Ciao,\n> Dscho\n>\n>   \nI think the real issue here is that submodule-add is too flexible and \npoorly documented, see my response to Junio in the other thread.\n\nMark\n"},{"id":"82654","messageId":"alpine.DEB.1.00.0807090210080.5277@eeepc-johanness","threadId":"14336","inReplyTo":"4873FF6E.2020602@gmail.com","subject":"Re: [PATCH] git-submodule - register module url if adding in place","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-09T00:11:16Z","receivedAt":"2008-07-09T00:11:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 8 Jul 2008, Mark Levedahl wrote:\n\n> Johannes Schindelin wrote:\n> > I agree with Sylvain here, namely that this is too dangerous.  \n> > Imagine this very valid scenario:\n> >\n> >  $ git clone <somewhere> abc\n> >  $ git submodule add abc\n> >\n> > Bummer.\n> >\n> > Yes, happened to me.\n> >\n> > So I'd like this to be an error, not something that tries to be \n> > helpful, when it clearly cannot be.\n>\n> I think the real issue here is that submodule-add is too flexible and \n> poorly documented, see my response to Junio in the other thread.\n\nIn contrast, I think that we should either disallow the form without URL, \nor get the URL automatically from the submodule's current branch's default \nremote.\n\nCiao,\nDscho\n"}]}