{"thread":{"id":"14826","subject":"[PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","startedAt":"2008-08-03T22:57:00Z","lastAt":"2008-08-04T07:52:10Z","messageCount":12,"participants":["Johan Herland","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"86117","messageId":"200808040057.00221.johan@herland.net","threadId":"14826","inReplyTo":null,"subject":"[PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T22:57:00Z","receivedAt":"2008-08-03T22:57:00Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"As suggested in a thread some time ago, one could redefine the URL used to \nfetch submodules by adding a 'url.*.insteadOf' rule prior to the first \ninvocation of 'git submodule update'.\n\nHowever, this does not work with current Git, because the super-repo config \n(which is home to the 'url.*.insteadOf' rule) is not consulted by the 'git \nclone' that is invoked by 'git submodule update'.\n\nThese patches fix this issue by making 'git submodule' explicitly rewrite \nthe submodule URL according to the super-repo config, prior to calling 'git \nclone'.\n\nIn order for the 'git submodule' shell script to properly rewrite URLs, it \nmust gain access to the URL rewriting functionality in remote.c. To expose \nthe URL rewriting functionality to 'git submodule' (and others, if needed), \na new option ('rewrite-url') has been added to 'git config'.\n\nThe patch series is based on master. Whether or not this should be \nconsidered for v1.6.0 is to be decided by Junio. (My personal opinion is \nthat although we're late in the release cycle, the patches are fairly \nstraightforward, and should not pose a great risk of regressions.)\n\nJohan Herland (5):\n  Add testcase for 'git submodule' with url.*.insteadOf set in the\n    super-repo\n  Teach 'git config' to rewrite URLs according to current\n    url.*.insteadOf rules\n  Add selftest for new option '--rewrite-url' to 'git config'\n  Add documentation on the new --rewrite-url option to 'git config'\n  Teach 'git submodule' to rewrite submodule URLs according to\n    super-repo's rules\n\n Documentation/git-config.txt |   10 ++++++++++\n builtin-config.c             |   23 ++++++++++++++++++++++-\n git-submodule.sh             |    6 ++++++\n t/t1300-repo-config.sh       |   14 ++++++++++++++\n t/t7400-submodule-basic.sh   |   11 +++++++++++\n 5 files changed, 63 insertions(+), 1 deletions(-)\n\n\nHave fun!\n\n...Johan\n"},{"id":"86118","messageId":"200808040100.02944.johan@herland.net","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"[PATCH 1/5] Add testcase for 'git submodule' with url.*.insteadOf set in the super-repo","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:00:02Z","receivedAt":"2008-08-03T23:00:02Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Currently, setting url.*.insteadOf in the super-repo in order to rewrite\nsubmodule URLs, don't work. When cloning/fetching the submodule, the\nsuper-repo config is never consulted, and thus the url.*.insteadOf rule\nis never seen. This adds a testcase that confirms the current behaviour.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t7400-submodule-basic.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex cbc0c34..bafc46c 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -209,4 +209,15 @@ test_expect_success 'update --init' '\n \n '\n \n+test_expect_failure 'update --init with url.*.insteadOf' '\n+\n+\trm -rf init &&\n+\tgit config -f .gitmodules submodule.example.url \"http://example.com/init2\" \n&&\n+\tgit config --remove-section submodule.example\n+\tgit config \"url.$(pwd)/.insteadOf\" \"http://example.com/\" &&\n+\tgit submodule update --init init &&\n+\ttest -d init/.git\n+\n+'\n+\n test_done\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86120","messageId":"200808040101.01082.johan@herland.net","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"[PATCH 2/5] Teach 'git config' to rewrite URLs according to current url.*.insteadOf rules","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:01:01Z","receivedAt":"2008-08-03T23:01:01Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"This patch adds the --rewrite-url option to 'git config'. The option takes\nexactly one argument; a URL that is to be rewritten according to the longest\nmatching url.*.insteadOf rule in the current config. The resulting URL is\nprinted on stdout, and 0 is returned.\n\nThe rationale for this patch is to enable access to Git's URL rewriting\nfunctionality from shell scripts.\n\nThe URL rewriting functionality is implemented by piggybacking on the\nexisting URL rewriting code in remote.c.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n builtin-config.c |   23 ++++++++++++++++++++++-\n 1 files changed, 22 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 91fdc49..977e6cb 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -1,9 +1,10 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"color.h\"\n+#include \"remote.h\"\n \n static const char git_config_set_usage[] =\n-\"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] \n[--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color \nvar [default] | --get-colorbool name [stdout-is-tty]\";\n+\"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] \n[--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color \nvar [default] | --get-colorbool name [stdout-is-tty] | --rewrite-url url\";\n \n static char *key;\n static regex_t *key_regexp;\n@@ -281,6 +282,24 @@ static int get_colorbool(int argc, const char **argv)\n \t}\n }\n \n+static int rewrite_url(int argc, const char **argv)\n+{\n+\t/*\n+\t * git config --rewrite_url <url>\n+\t *\n+\t * returns <url> after rewriting it according to url.*.insteadOf rules.\n+\t */\n+\n+\tif (argc > 1)\n+\t\tusage(git_config_set_usage);\n+\n+\tstruct remote *remote = remote_get(argv[0]);\n+\tif (remote->url_nr != 1)\n+\t\tdie(\"Expected exactly one URL from remote_get()!\");\n+\tprintf(\"%s\\n\", remote->url[0]);\n+\treturn 0;\n+}\n+\n int cmd_config(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n@@ -362,6 +381,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\treturn get_color(argc-2, argv+2);\n \t\t} else if (!strcmp(argv[1], \"--get-colorbool\")) {\n \t\t\treturn get_colorbool(argc-2, argv+2);\n+\t\t} else if (!strcmp(argv[1], \"--rewrite-url\")) {\n+\t\t\treturn rewrite_url(argc-2, argv+2);\n \t\t} else\n \t\t\tbreak;\n \t\targc--;\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86119","messageId":"200808040102.07499.johan@herland.net","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"[PATCH 3/5] Add selftest for new option '--rewrite-url' to 'git config'","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:02:07Z","receivedAt":"2008-08-03T23:02:07Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Simple check that URL rewriting functionality works as expected.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t1300-repo-config.sh |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 64567fb..dcd04c2 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -741,4 +741,18 @@ test_expect_success 'symlinked configuration' '\n \n '\n \n+test_expect_success '--rewrite-url' '\n+\n+\tgit config url.ssh://example.com/foo/.insteadOf http://example.com/ &&\n+\tgit config url.../.insteadOf git://example.com/ &&\n+\ta=$(git config --rewrite-url http://example.com/baz/xyzzy.git) &&\n+\ttest \"zssh://example.com/foo/baz/xyzzy.git\" = \"z$a\" &&\n+\tb=$(git config --rewrite-url git://example.com/baz/xyzzy.git) &&\n+\ttest \"z../baz/xyzzy.git\" = \"z$b\" &&\n+\tc=$(git config --rewrite-url ssh://example.com/foo/baz/xyzzy.git) &&\n+\ttest \"zssh://example.com/foo/baz/xyzzy.git\" = \"z$c\" &&\n+\td=$(git config --rewrite-url rsync://example.com/baz/xyzzy.git) &&\n+\ttest \"zrsync://example.com/baz/xyzzy.git\" = \"z$d\"\n+'\n+\n test_done\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86121","messageId":"200808040102.31430.johan@herland.net","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"[PATCH 4/5] Add documentation on the new --rewrite-url option to 'git config'","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:02:31Z","receivedAt":"2008-08-03T23:02:31Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Signed-off-by: Johan Herland <johan@herland.net>\n---\n Documentation/git-config.txt |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-config.txt b/Documentation/git-config.txt\nindex 28e1861..154c80b 100644\n--- a/Documentation/git-config.txt\n+++ b/Documentation/git-config.txt\n@@ -22,6 +22,7 @@ SYNOPSIS\n 'git config' [<file-option>] [-z|--null] -l | --list\n 'git config' [<file-option>] --get-color name [default]\n 'git config' [<file-option>] --get-colorbool name [stdout-is-tty]\n+'git config' [<file-option>] --rewrite-url url\n \n DESCRIPTION\n -----------\n@@ -157,6 +158,15 @@ See also <<FILES>>.\n \toutput.  The optional `default` parameter is used instead, if\n \tthere is no color configured for `name`.\n \n+--rewrite-url url::\n+\n+\tRewrite `url` according to the longest matching URL rewriting rule\n+\t(see documentation on `url.<base>.insteadOf` for more information\n+\ton URL rewriting rules), and output the resulting URL to the\n+\tstandard output. If there is no matching URL rewriting rule, the\n+\toriginal `url` is printed on the standard output. In either case,\n+\tthe exit code is 0.\n+\n [[FILES]]\n FILES\n -----\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86122","messageId":"200808040102.58275.johan@herland.net","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"[PATCH 5/5] Teach 'git submodule' to rewrite submodule URLs according to super-repo's rules","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:02:58Z","receivedAt":"2008-08-03T23:02:58Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"When a 'url.*.insteadOf' rule in the superrepo matches a submodule URL, we\nshould rewrite the submodule URL accordingly, so that we don't request the\nsubmodule from location that is inaccessible (or unwanted by the user for\nsome other reason).\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n git-submodule.sh           |    6 ++++++\n t/t7400-submodule-basic.sh |    2 +-\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex b40f876..ea2aa3b 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -96,6 +96,12 @@ module_clone()\n \ttest -e \"$path\" &&\n \tdie \"A file already exist at path '$path'\"\n \n+\t# The user may have added url.*.insteadOf rules intending to rewrite\n+\t# submodule URLs. We must explicitly do this rewrite before calling\n+\t# 'git clone', since 'git clone' will not consult the super-repo\n+\t# config and thus never see any url.*.insteadOf rules placed therein.\n+\turl=$(git config --rewrite-url \"$url\")\n+\n \tgit-clone -n \"$url\" \"$path\" ||\n \tdie \"Clone of '$url' into submodule path '$path' failed\"\n }\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex bafc46c..9c56de2 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -209,7 +209,7 @@ test_expect_success 'update --init' '\n \n '\n \n-test_expect_failure 'update --init with url.*.insteadOf' '\n+test_expect_success 'update --init with url.*.insteadOf' '\n \n \trm -rf init &&\n \tgit config -f .gitmodules submodule.example.url \"http://example.com/init2\" &&\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86123","messageId":"200808040104.36603.johan@herland.net","threadId":"14826","inReplyTo":"200808040100.02944.johan@herland.net","subject":"[PATCH 1/5 v2] Add testcase for 'git submodule' with url.*.insteadOf set in the super-repo","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:04:36Z","receivedAt":"2008-08-03T23:04:36Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Currently, setting url.*.insteadOf in the super-repo in order to rewrite\nsubmodule URLs, don't work. When cloning/fetching the submodule, the\nsuper-repo config is never consulted, and thus the url.*.insteadOf rule\nis never seen. This adds a testcase that confirms the current behaviour.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n t/t7400-submodule-basic.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\n\nThe previous patch was whitespace-damaged. Sorry. Trying again.\n\n\n...Johan\n\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex cbc0c34..bafc46c 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -209,4 +209,15 @@ test_expect_success 'update --init' '\n \n '\n \n+test_expect_failure 'update --init with url.*.insteadOf' '\n+\n+\trm -rf init &&\n+\tgit config -f .gitmodules submodule.example.url \"http://example.com/init2\" &&\n+\tgit config --remove-section submodule.example\n+\tgit config \"url.$(pwd)/.insteadOf\" \"http://example.com/\" &&\n+\tgit submodule update --init init &&\n+\ttest -d init/.git\n+\n+'\n+\n test_done\n-- \n1.6.0.rc1.34.g0fe8c\n"},{"id":"86125","messageId":"alpine.DEB.1.00.0808040126170.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14826","inReplyTo":"200808040057.00221.johan@herland.net","subject":"Re: [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-03T23:27:53Z","receivedAt":"2008-08-03T23:27:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 4 Aug 2008, Johan Herland wrote:\n\n> As suggested in a thread some time ago, one could redefine the URL used \n> to fetch submodules by adding a 'url.*.insteadOf' rule prior to the \n> first invocation of 'git submodule update'.\n\nIf I suggested it, but forgot the \"--global\" flag to \"git config\", I \napologize.\n\nCiao,\nDscho\n"},{"id":"86127","messageId":"200808040147.16797.johan@herland.net","threadId":"14826","inReplyTo":"alpine.DEB.1.00.0808040126170.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-03T23:47:16Z","receivedAt":"2008-08-03T23:47:16Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Monday 04 August 2008, Johannes Schindelin wrote:\n> On Mon, 4 Aug 2008, Johan Herland wrote:\n> > As suggested in a thread some time ago, one could redefine the URL used\n> > to fetch submodules by adding a 'url.*.insteadOf' rule prior to the\n> > first invocation of 'git submodule update'.\n>\n> If I suggested it, but forgot the \"--global\" flag to \"git config\", I\n> apologize.\n\nDoes this mean that you don't agree with the rationale for this patch? I.e. \nthat submodule URLs should not be rewritten according to the rules in the \nsuper-repo (but instead require such rules to be set in the user's global \nconfig)?\n\nThere are (at least) two reasons for why I think this should work without \nhaving to use '--global':\n\n1. Consistency: Other git commands in the supermodule does _not_ require the \nURL rewriting rule to reside in the global config. Why should 'git \nsubmodule' be different.\n\n2. I believe there are valid use cases for adding URL rewriting rules to the \nrepo config instead of the global config. You may want to check out Fred's \nversion of project X (including submodules), without making your other \nclones of project X start cloning/fetching from Fred.\n\n\nPuzzled,\n...Johan\n\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"86128","messageId":"7vsktl7itz.fsf@gitster.siamese.dyndns.org","threadId":"14826","inReplyTo":"alpine.DEB.1.00.0808040126170.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-03T23:57:28Z","receivedAt":"2008-08-03T23:57:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Mon, 4 Aug 2008, Johan Herland wrote:\n>\n>> As suggested in a thread some time ago, one could redefine the URL used \n>> to fetch submodules by adding a 'url.*.insteadOf' rule prior to the \n>> first invocation of 'git submodule update'.\n>\n> If I suggested it, but forgot the \"--global\" flag to \"git config\", I \n> apologize.\n\nThat's a nice way to say that the patchset is unnecessary ;-).\n"},{"id":"86135","messageId":"7vwsix5y9w.fsf@gitster.siamese.dyndns.org","threadId":"14826","inReplyTo":"200808040147.16797.johan@herland.net","subject":"Re: [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-04T02:06:51Z","receivedAt":"2008-08-04T02:06:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> 1. Consistency: Other git commands in the supermodule does _not_ require the \n> URL rewriting rule to reside in the global config. Why should 'git \n> submodule' be different.\n\nWhen it comes to \"submodules\", I do not think such consistency argument\nmakes much sense.  \"git submodule\" command crosses module boundary, normal\ncommands don't.  They are naturally different and they should be.\n\nYour kind of consistency means breaking the separation between module\nboundary, doesn't it?\n\nHaving said that...\n\n> 2. I believe there are valid use cases for adding URL rewriting rules to the \n> repo config instead of the global config. You may want to check out Fred's \n> version of project X (including submodules), without making your other \n> clones of project X start cloning/fetching from Fred.\n\nI think you are referring to the example given in an earlier thread to\npeek what your neighbor did between you two, without affecting other\npeople.\n\nPersonally I think it is partly showing the shortcoming of the current\n\"git submodule\" that minimally supports the workflow to follow what the\ncanonical repository does, and partly showing that it is an abuse of that\ninterface to rewrite config file to temporarily switch to peek somewhere\nelse in such a workflow.\n\nLet's step back and think what we would do if there is no submodule\ninvolved.  That is, you usually follow origin, but you temporarily want to\npeek at what Fred did.  How would you do this?\n\n\t$ git fetch $fred $branch_fred_wants_you_to_review\n        $ git checkout FETCH_HEAD ;# this detaches HEAD.\n\nAnd you take a look around.  Perhaps you like the change and decide to\nmerge that to your branch.  Perhaps you create your own branch on top of\nthat state, build a few fix-up commits, and give the result back to Fred.\n\nShouldn't peeking what Fred did in the whole submodule hierarchy be\nessentially the same thing?  That is,\n\n\t$ git submodule for-each-submodule sh -c '\n                git fetch \"$fred/$1\" $branch_fred_wants_you_to_review &&\n                git checkout FETCH_HEAD\n\t' -\n\nwhere \"for-each-submodule\" would iterate over the submodules in the\ncurrent superproject that you are interested in (that is, you actually\nhave corresponding repositories there), and runs any given command with\nthe path to the submodule in that directory.\n\nHmm?\n"},{"id":"86157","messageId":"200808040952.10472.johan@herland.net","threadId":"14826","inReplyTo":"7vwsix5y9w.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-08-04T07:52:10Z","receivedAt":"2008-08-04T07:52:10Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Monday 04 August 2008, Junio C Hamano wrote:\n> Johan Herland <johan@herland.net> writes:\n> > 1. Consistency: Other git commands in the supermodule does _not_\n> > require the URL rewriting rule to reside in the global config. Why\n> > should 'git submodule' be different.\n>\n> When it comes to \"submodules\", I do not think such consistency argument\n> makes much sense.  \"git submodule\" command crosses module boundary,\n> normal commands don't.  They are naturally different and they should be.\n>\n> Your kind of consistency means breaking the separation between module\n> boundary, doesn't it?\n\nTo a certain degree, yes, but (1) only for this specific config rule \n(url.*.insteadOf), and (2) only at the specific point in time when the \nsubmodule is cloned. This means that after the submodule is cloned, it is \nindeed not affected by the super-repo's config. E.g. you can change the \norigin URL of the submodule back to the original (un-rewritten) URL in the \nsubmodule's config, and the super-repo will not try to rewrite it at again.\n\nI believe that the module boundary should not be crossed in general. But \nthis patch only \"crosses\" that boundary before it really exists (i.e. \nbefore the submodule has been cloned into the super-repo). The event of \nintroducing a submodule into a super-repo, is AFAICS the _only_ event where \nI would consider to cross the module boundary (and then only for a good \nreason).\n\n> Having said that...\n>\n> > 2. I believe there are valid use cases for adding URL rewriting rules\n> > to the repo config instead of the global config. You may want to check\n> > out Fred's version of project X (including submodules), without making\n> > your other clones of project X start cloning/fetching from Fred.\n>\n> I think you are referring to the example given in an earlier thread to\n> peek what your neighbor did between you two, without affecting other\n> people.\n\nCorrect.\n\n> Personally I think it is partly showing the shortcoming of the current\n> \"git submodule\" that minimally supports the workflow to follow what the\n> canonical repository does, and partly showing that it is an abuse of that\n> interface to rewrite config file to temporarily switch to peek somewhere\n> else in such a workflow.\n\nIndeed. However, the development of submodules usability seems so slow that \neven though this use case is an ugly workaround, it's one I thought we'd \nhave to live with for some time... [1]\n\n> Let's step back and think what we would do if there is no submodule\n> involved.  That is, you usually follow origin, but you temporarily want\n> to peek at what Fred did.  How would you do this?\n>\n> \t$ git fetch $fred $branch_fred_wants_you_to_review\n> \t$ git checkout FETCH_HEAD ;# this detaches HEAD.\n>\n> And you take a look around.  Perhaps you like the change and decide to\n> merge that to your branch.  Perhaps you create your own branch on top of\n> that state, build a few fix-up commits, and give the result back to Fred.\n>\n> Shouldn't peeking what Fred did in the whole submodule hierarchy be\n> essentially the same thing?  That is,\n>\n> \t$ git submodule for-each-submodule sh -c '\n> \t\tgit fetch \"$fred/$1\" $branch_fred_wants_you_to_review &&\n> \t\tgit checkout FETCH_HEAD\n> \t' -\n>\n> where \"for-each-submodule\" would iterate over the submodules in the\n> current superproject that you are interested in (that is, you actually\n> have corresponding repositories there), and runs any given command with\n> the path to the submodule in that directory.\n>\n> Hmm?\n\nYes, having such functionality in 'git submodule' would be wonderful. \nHowever, implementations of such functionality have been slow in coming, \nand apparently hard to implement without being workflow-agnostic (if I \nremember correctly).\n\nIn light of improvements to 'git submodule', feel free to disregard my patch \nseries (although I still find 'git config --rewrite-url' useful for \ndry-testing my 'url.*.insteadOf' rules...).\n\n\nThanks for providing constructive feedback.\n\n\nHave fun!\n\n...Johan\n\n\n[1]: Maybe 'git submodule' would improve more quickly if we ate our own \ndogfood, i.e. if we included submodules (e.g. gitk and git-gui) in git.git?\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"}]}