{"thread":{"id":"11857","subject":"[PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","startedAt":"2008-02-03T17:31:00Z","lastAt":"2008-02-04T21:49:32Z","messageCount":19,"participants":["Mark Levedahl","Johannes Schindelin","Steffen Prohaska","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"67234","messageId":"1202059867-1184-1-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":null,"subject":"[PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:00Z","receivedAt":"2008-02-03T17:31:00Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"(sigh, someday I'll get this command line email addressing stuff\nsorted out - resending as I mangled Junio's email)\n\nThis patch series was inspired by several issues dealing with\nmultiple remotes and submodules. The tests added as the last\npatch demonstrate the specific use pattern to be supported,\nand that does not work currently.\n\n1 - user A creates a project on server \"frotz\" with a submodule.\n2 - user B clones the project, forks it, adds a submodule, and\npublishes the fork on server \"fork\"\n\nuser A adds the fork to his working tree, via git remote add +\ngit fetch. The desire is that:\n1 - git submodule init + git submodule update include the new\nsubmdule added in the fork.\n2 - The top-level project and all submodules use the same\nremote nickname to refer to the same server.\n\nBreakage in 1.5.4 without this patch series is in several places:\n\n1 - git submodule does not follow the top-level project's\nbranch.<name>.remote in fetching, so does not try to clone\nthe new submodule from remoe \"fork\" where the fork exists.\n2 - If 1 were fixed, git submodule still invokes clone without \"-o\n<remotenick>\" when cloning, so each submodule would have \"origin\"\npoint to a different remote.\n3 - If 2 were fixed, submodule update leaves submodules on detached\nheads, so the remotes machinery cannot supply a remote name, and thus\n\"origin\" is used for further updates. As origin may not be defined,\n(e.g., for the submodule fetched from \"fork\" this also fails.)\n\nThe underlying design issue is the assumption that all projects\nrevolve around a single server, so that *the* server can be called\n\"origin\" without confusion.  Given a project with multiple servers and\nno one server being *the* server, origin cannot be usefully defined.\nAbsent submodules, the remotes machinery largely masks this: origin is\nreferred to only as the default remote and it is easy to avoid using\nthe default remote.  With submodules, this becomes more of an issue.\n\nFollowing this patch series, the following is true:\n\n1) The existing workflow of top-level and all sub-modules always\ncloned from and interacting with a single default remote\nnick-named \"origin\" is unchanged.\n2) Via clone -o <nick> (or git confit core.origin <nick>), the\ndefault remote is changed from origin to <nick>, and that default\nis used instead of origin everywhere.\n3) git-submodule uses the top-level's branch.<name>.remote to\nchoose which remote to fetch from, uses that in all submodules,\nincluding defining that in existing submodules whose url is\nrelative (../* or ./*) indicating the submodule is maintained on\nsame server as top-level.\n\nThe penultimate patch addresses a basic usability issue, allowing\naddition of a submodule in place in a project, rather than requiring\nit be cloned from a remote.  This hole in the porcelain became evident\nin creating a test (t7401) for this series.\nsubmodules except by cloning).\n"},{"id":"67236","messageId":"1202059867-1184-2-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-1-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 1/7] Teach remote machinery about core.origin config variable","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:01Z","receivedAt":"2008-02-03T17:31:01Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"This introduces a new configuration variable, core.origin, that\ndefines the name of the default remote to be used. Traditionally, this\nis \"origin\", and could be overridden for a given branch. This change\nintroduces a way to redefine the default as desired and have that honored\nregardless of the currently checked out head (e.g., core.origin is\nused when on a detached head or any other non-tracking branch).\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n Documentation/config.txt |    6 ++++++\n git-parse-remote.sh      |    5 +++--\n remote.c                 |   11 ++++++++++-\n 3 files changed, 19 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4e222f1..a890f5d 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -291,6 +291,12 @@ core.editor::\n \t`GIT_EDITOR` environment, `core.editor`, `VISUAL` and\n \t`EDITOR` environment variables and then finally `vi`.\n \n+core.origin::\n+\tThe name of the remote used by default for fetch / pull. If unset,\n+\torigin is assumed. This value is used whenever the current branch\n+\thas no corresponding branch.<name>.remote, such as when working on\n+\ta detached head.\n+\n core.pager::\n \tThe command that git will use to paginate output.  Can be overridden\n \twith the `GIT_PAGER` environment variable.\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 695a409..c7ac7c7 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -56,8 +56,9 @@ get_remote_url () {\n \n get_default_remote () {\n \tcurr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')\n-\torigin=$(git config --get \"branch.$curr_branch.remote\")\n-\techo ${origin:-origin}\n+\tgit config --get \"branch.$curr_branch.remote\" ||\n+\tgit config --get \"core.origin\" ||\n+\techo origin\n }\n \n get_remote_default_refs_for_push () {\ndiff --git a/remote.c b/remote.c\nindex 0e00680..302d499 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -10,6 +10,7 @@ static int allocated_branches;\n \n static struct branch *current_branch;\n static const char *default_remote_name;\n+static const char *core_origin;\n \n #define BUF_SIZE (2048)\n static char buffer[BUF_SIZE];\n@@ -233,6 +234,11 @@ static int handle_config(const char *key, const char *value)\n \t\t\tadd_merge(branch, xstrdup(value));\n \t\treturn 0;\n \t}\n+\tif (!strcmp(key, \"core.origin\")) {\n+\t\tif (value)\n+\t\t\tcore_origin = xstrdup(value);\n+\t\treturn 0;\n+\t}\n \tif (prefixcmp(key,  \"remote.\"))\n \t\treturn 0;\n \tname = key + 7;\n@@ -291,7 +297,6 @@ static void read_config(void)\n \tint flag;\n \tif (default_remote_name) // did this already\n \t\treturn;\n-\tdefault_remote_name = xstrdup(\"origin\");\n \tcurrent_branch = NULL;\n \thead_ref = resolve_ref(\"HEAD\", sha1, 0, &flag);\n \tif (head_ref && (flag & REF_ISSYMREF) &&\n@@ -300,6 +305,10 @@ static void read_config(void)\n \t\t\tmake_branch(head_ref + strlen(\"refs/heads/\"), 0);\n \t}\n \tgit_config(handle_config);\n+\tif (!default_remote_name) {\n+\t\tdefault_remote_name = core_origin ?\n+\t\tcore_origin : xstrdup(\"origin\");\n+\t}\n }\n \n struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)\n-- \n1.5.4.18.g43c18\n"},{"id":"67235","messageId":"1202059867-1184-3-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-2-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 2/7] git-remote - Unset core.origin when deleting the default remote","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:02Z","receivedAt":"2008-02-03T17:31:02Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-remote.perl |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/git-remote.perl b/git-remote.perl\nindex d13e4c1..75d2371 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -328,6 +328,11 @@ sub rm_remote {\n \n \t$git->command('config', '--remove-section', \"remote.$name\");\n \n+\tmy $defremote = $git->config(\"core.origin\");\n+\tif (defined $defremote && $defremote eq $name) {\n+\t       $git->command(\"config\", \"--unset\", \"core.origin\");\n+\t}\n+\n \teval {\n \t    my @trackers = $git->command('config', '--get-regexp',\n \t\t\t'branch.*.remote', $name);\n-- \n1.5.4.18.g43c18\n"},{"id":"67239","messageId":"1202059867-1184-4-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-3-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 3/7] git-clone - Set remotes.origin config variable","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:03Z","receivedAt":"2008-02-03T17:31:03Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"This records the users choice of default remote name (by default \"origin\")\nas given by the -o option.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n Documentation/git-clone.txt |    3 ++-\n git-clone.sh                |    1 +\n 2 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 2341881..f15aecd 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -103,7 +103,8 @@ OPTIONS\n --origin <name>::\n -o <name>::\n \tInstead of using the remote name 'origin' to keep track\n-\tof the upstream repository, use <name> instead.\n+\tof the upstream repository, use <name> instead. The name\n+\tis recorded in the core.origin config variable.\n \n --upload-pack <upload-pack>::\n -u <upload-pack>::\ndiff --git a/git-clone.sh b/git-clone.sh\nindex b4e858c..7208d68 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -242,6 +242,7 @@ fi &&\n export GIT_DIR &&\n GIT_CONFIG=\"$GIT_DIR/config\" git-init $quiet ${template+\"$template\"} || usage\n \n+git config core.origin $origin\n if test -n \"$bare\"\n then\n \tGIT_CONFIG=\"$GIT_DIR/config\" git config core.bare true\n-- \n1.5.4.18.g43c18\n"},{"id":"67238","messageId":"1202059867-1184-5-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-4-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 4/7] git-submodule - Possibly inherit parent's default remote on init/clone","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:04Z","receivedAt":"2008-02-03T17:31:04Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"For submodules defined relative to their parent, it is likely that the\nparent's defined default remote is correct for the child as well. This\nallows use of remote names other than \"origin\", important as managed\nsubmodules are typically checked out on a detached head and therefore\nsubmodule-update invokes git-fetch using the default remote. Without this\nchange, submodules effectively had to have a default remote of \"origin.\"\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n Documentation/git-submodule.txt |    8 +++++---\n git-submodule.sh                |   20 ++++++++++++++------\n 2 files changed, 19 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex e818e6e..b04b107 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -37,9 +37,11 @@ status::\n \n init::\n \tInitialize the submodules, i.e. register in .git/config each submodule\n-\tname and url found in .gitmodules. The key used in .git/config is\n-\t`submodule.$name.url`. This command does not alter existing information\n-\tin .git/config.\n+\tname and url found in .gitmodules, along with the default remote origin.\n+\tFor submodules using a relative url, the default remote is inherited\n+\tfrom the parent project, for absolute urls the default \"origin\" is used.\n+\tThe key used in .git/config is submodule.$name.url`. This command does\n+\tnot alter existing information in .git/config.\n \n update::\n \tUpdate the registered submodules, i.e. clone missing submodules and\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex a6aaf40..bb0d265 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -7,6 +7,7 @@\n USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update] [--] [<path>...]'\n OPTIONS_SPEC=\n . git-sh-setup\n+. git-parse-remote\n require_work_tree\n \n command=\n@@ -40,9 +41,7 @@ get_repo_base() {\n # Resolve relative url by appending to parent's url\n resolve_relative_url ()\n {\n-\tbranch=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n-\tremote=\"$(git config branch.${branch#refs/heads/}.remote)\"\n-\tremote=\"${remote:-origin}\"\n+\tremote=\"$(get_default_remote)\"\n \tremoteurl=\"$(git config remote.$remote.url)\" ||\n \t\tdie \"remote ($remote) does not have a url in .git/config\"\n \turl=\"$1\"\n@@ -92,6 +91,7 @@ module_clone()\n {\n \tpath=$1\n \turl=$2\n+\torigin=$3\n \n \t# If there already is a directory at the submodule path,\n \t# expect it to be empty (since that is the default checkout\n@@ -107,7 +107,7 @@ module_clone()\n \ttest -e \"$path\" &&\n \tdie \"A file already exist at path '$path'\"\n \n-\tgit-clone -n \"$url\" \"$path\" ||\n+\tgit-clone -n -o \"$origin\" \"$url\" \"$path\" ||\n \tdie \"Clone of '$url' into submodule path '$path' failed\"\n }\n \n@@ -156,10 +156,12 @@ cmd_add()\n \tcase \"$repo\" in\n \t./*|../*)\n \t\t# dereference source url relative to parent's url\n+\t\torigin=$(get_default_remote)\n \t\trealrepo=\"$(resolve_relative_url $repo)\" ;;\n \t*)\n \t\t# Turn the source into an absolute path if\n \t\t# it is local\n+\t\torigin=origin\n \t\tif base=$(get_repo_base \"$repo\"); then\n \t\t\trepo=\"$base\"\n \t\tfi\n@@ -180,7 +182,7 @@ cmd_add()\n \tgit ls-files --error-unmatch \"$path\" > /dev/null 2>&1 &&\n \tdie \"'$path' already exists in the index\"\n \n-\tmodule_clone \"$path\" \"$realrepo\" || exit\n+\tmodule_clone \"$path\" \"$realrepo\" \"$origin\" || exit\n \t(unset GIT_DIR; cd \"$path\" && git checkout -q ${branch:+-b \"$branch\" \"origin/$branch\"}) ||\n \tdie \"Unable to checkout submodule '$path'\"\n \tgit add \"$path\" ||\n@@ -236,9 +238,14 @@ cmd_init()\n \t\tcase \"$url\" in\n \t\t./*|../*)\n \t\t\turl=\"$(resolve_relative_url \"$url\")\"\n+\t\t\torigin=$(get_default_remote)\n+\t\t\t;;\n+\t\t*)\n+\t\t\torigin=origin\n \t\t\t;;\n \t\tesac\n \n+\t\tgit config submodule.\"$name\".origin \"$origin\" &&\n \t\tgit config submodule.\"$name\".url \"$url\" ||\n \t\tdie \"Failed to register url for submodule path '$path'\"\n \n@@ -287,10 +294,11 @@ cmd_update()\n \t\t\tsay \"Submodule path '$path' not initialized\"\n \t\t\tcontinue\n \t\tfi\n+\t\torigin=$(git config submodule.\"$name\".origin || echo origin)\n \n \t\tif ! test -d \"$path\"/.git\n \t\tthen\n-\t\t\tmodule_clone \"$path\" \"$url\" || exit\n+\t\t\tmodule_clone \"$path\" \"$url\" \"$origin\" || exit\n \t\t\tsubsha1=\n \t\telse\n \t\t\tsubsha1=$(unset GIT_DIR; cd \"$path\" &&\n-- \n1.5.4.18.g43c18\n"},{"id":"67237","messageId":"1202059867-1184-6-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-5-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 5/7] Teach git-submodule to use top-level remote when updating subprojects","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:05Z","receivedAt":"2008-02-03T17:31:05Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Modules that are defined using relative urls to the master project are\nassumed to be completely owned by the project. When running\n\"submodule update\" from the top level, it is reasonable that the entire\nproject exists at the remote given by top-level branch.<name>.remote.\nUsing the remote machinery, this remote can be different for each\nbranch and can be different than the current defaults in each submodule.\n\nThis teaches submodule to:\n\n1) Possibly define the current master's remote in each submodule, using\nthe same relative url used by submodule init.\n2) Fetch each submodule's updates from the master's remote.\n\nSubmodules defined using absolute urls (not relative to the parent) are\nnot touched by this logic. Such modules are assumed to be independent\nof the master project so submodule can do no better than to fetch from\ntheir currently defined default remotes as already done.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n git-submodule.sh |   20 +++++++++++++++++++-\n 1 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bb0d265..8f31ebe 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -255,6 +255,8 @@ cmd_init()\n \n #\n # Update each submodule path to correct revision, using clone and checkout as needed\n+# For owned submodules (defined using relative url), we use master project's remote\n+# and define that in each submodule if not already there\n #\n # $@ = requested paths (default to all)\n #\n@@ -281,6 +283,7 @@ cmd_update()\n \t\tshift\n \tdone\n \n+\tmaster_remote=$(get_default_remote)\n \tgit ls-files --stage -- \"$@\" | grep -e '^160000 ' |\n \twhile read mode sha1 stage path\n \tdo\n@@ -306,9 +309,24 @@ cmd_update()\n \t\t\tdie \"Unable to find current revision in submodule path '$path'\"\n \t\tfi\n \n+\t\tbaseurl=\"$(GIT_CONFIG=.gitmodules git config submodule.\"$name\".url)\"\n+\t\tcase \"$baseurl\" in\n+\t\t./*|../*)\n+\t\t\tfetch_remote=$master_remote\n+\t\t\t(unset GIT_DIR ; cd \"$path\" && git config remote.\"$fetch_remote\".url > nul) ||\n+\t\t\t(\n+\t\t\t\tabsurl=\"$(resolve_relative_url $baseurl)\"\n+\t\t\t\tunset GIT_DIR; cd \"$path\" && git remote add \"$master_remote\" \"$absurl\"\n+\t\t\t) || die \"Unable to define remote '$fetch_remote' in submodule path '$path'\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\tfetch_remote=\n+\t\t\t;;\n+\t\tesac\n+\n \t\tif test \"$subsha1\" != \"$sha1\"\n \t\tthen\n-\t\t\t(unset GIT_DIR; cd \"$path\" && git-fetch &&\n+\t\t\t(unset GIT_DIR; cd \"$path\" && git-fetch $fetch_remote &&\n \t\t\t\tgit-checkout -q \"$sha1\") ||\n \t\t\tdie \"Unable to checkout '$sha1' in submodule path '$path'\"\n \n-- \n1.5.4.18.g43c18\n"},{"id":"67241","messageId":"1202059867-1184-7-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-6-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 6/7] git-submodule - Allow adding a submodule in-place","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:06Z","receivedAt":"2008-02-03T17:31:06Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"When working in top-level directory, it is natural to create a new\nsubmodule in a subdirectory, then add that submodule to top-level in\nplace. This allows \"git submodule add <intended url> subdir\" to add\nthe existing subdir to the current project. The presumption is the user\nwill later push / clone the subdir to the <intended url> so that future\nsubmodule init / updates will work.\n\nAbsent this patch, \"git submodule add\" insists upon cloning the subdir\nfrom the remote, which is fine for adding an existing project in but\nless useful when adding a new submodule from scratch to an existing\nproject. This functionality remains, and the clone is attempted if the\nsubdir does not already exist as a valid git repo.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n\nfix submodule again\n---\n Documentation/git-submodule.txt |    5 ++-\n git-submodule.sh                |   56 +++++++++++++++++++++++---------------\n 2 files changed, 37 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex b04b107..8ea3fc3 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -18,8 +18,9 @@ COMMANDS\n --------\n add::\n \tAdd the given repository as a submodule at the given path\n-\tto the changeset to be committed next.  In particular, the\n-\trepository is cloned at the specified path, added to the\n+\tto the changeset to be committed next.  If path is a valid\n+\trepository within the project, it is added as is. Otherwise,\n+\trepository is cloned at the specified path. path is added to the\n \tchangeset and registered in .gitmodules.   If no path is\n \tspecified, the path is deduced from the repository specification.\n \tIf the repository url begins with ./ or ../, it is stored as\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8f31ebe..47b5664 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -44,6 +44,7 @@ resolve_relative_url ()\n \tremote=\"$(get_default_remote)\"\n \tremoteurl=\"$(git config remote.$remote.url)\" ||\n \t\tdie \"remote ($remote) does not have a url in .git/config\"\n+\tremoteurl=\"${remoteurl%/.git}\"\n \turl=\"$1\"\n \twhile test -n \"$url\"\n \tdo\n@@ -153,22 +154,6 @@ cmd_add()\n \t\tusage\n \tfi\n \n-\tcase \"$repo\" in\n-\t./*|../*)\n-\t\t# dereference source url relative to parent's url\n-\t\torigin=$(get_default_remote)\n-\t\trealrepo=\"$(resolve_relative_url $repo)\" ;;\n-\t*)\n-\t\t# Turn the source into an absolute path if\n-\t\t# it is local\n-\t\torigin=origin\n-\t\tif base=$(get_repo_base \"$repo\"); then\n-\t\t\trepo=\"$base\"\n-\t\tfi\n-\t\trealrepo=$repo\n-\t\t;;\n-\tesac\n-\n \t# Guess path from repo if not specified or strip trailing slashes\n \tif test -z \"$path\"; then\n \t\tpath=$(echo \"$repo\" | sed -e 's|/*$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n@@ -176,15 +161,42 @@ cmd_add()\n \t\tpath=$(echo \"$path\" | sed -e 's|/*$||')\n \tfi\n \n-\ttest -e \"$path\" &&\n-\tdie \"'$path' already exists\"\n-\n \tgit ls-files --error-unmatch \"$path\" > /dev/null 2>&1 &&\n \tdie \"'$path' already exists in the index\"\n \n-\tmodule_clone \"$path\" \"$realrepo\" \"$origin\" || exit\n-\t(unset GIT_DIR; cd \"$path\" && git checkout -q ${branch:+-b \"$branch\" \"origin/$branch\"}) ||\n-\tdie \"Unable to checkout submodule '$path'\"\n+\t# perhaps the path exists and is already a git repo, else clone it\n+\tif test -e \"$path\"\n+\tthen\n+\t\tif test -d \"$path/.git\" &&\n+\t\ttest \"$(unset GIT_DIR; cd $path; git rev-parse --git-dir)\" = \".git\"\n+\t\tthen\n+\t\t\techo \"Adding existing repo at '$path' to the index\"\n+\t\telse\n+\t\t\tdie \"'$path' already exists and is not a valid git repo\"\n+\t\tfi\n+\telse\n+\t\tcase \"$repo\" in\n+\t\t./*|../*)\n+\t\t\t# dereference source url relative to parent's url\n+\t\t\torigin=$(get_default_remote)\n+\t\t\trealrepo=\"$(resolve_relative_url $repo)\" ;;\n+\t\t*)\n+\t\t\t# Turn the source into an absolute path if\n+\t\t\t# it is local\n+\t\t\torigin=origin\n+\t\t\tif base=$(get_repo_base \"$repo\")\n+\t\t\tthen\n+\t\t\t\trepo=\"$base\"\n+\t\t\tfi\n+\t\t\trealrepo=$repo\n+\t\t\t;;\n+\t\tesac\n+\n+\t\tmodule_clone \"$path\" \"$realrepo\" \"$origin\" || exit\n+\t\t(unset GIT_DIR; cd \"$path\" && git checkout -q ${branch:+-b \"$branch\" \"origin/$branch\"}) ||\n+\t\tdie \"Unable to checkout submodule '$path'\"\n+\tfi\n+\n \tgit add \"$path\" ||\n \tdie \"Failed to add submodule '$path'\"\n \n-- \n1.5.4.18.g43c18\n"},{"id":"67240","messageId":"1202059867-1184-8-git-send-email-mlevedahl@gmail.com","threadId":"11857","inReplyTo":"1202059867-1184-7-git-send-email-mlevedahl@gmail.com","subject":"[PATCH 7/7] Add t/t7401 - test submodule interaction with remotes machinery","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-03T17:31:07Z","receivedAt":"2008-02-03T17:31:07Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"This adds a sequence of tests to assure that the following two sequences\nwork:\n\n\tgit clone -o frotz <someurl> foo\n\tcd foo\n\tgit submodule init\n\tgit submodule update\n\nThis should result in the master and subproject having \"frotz\" as the\nname of the default remote (and origin undefined).\n\nThen, in the same working directory\n\tgit remote add fork <some url>\n\tgit fetch fork\n\tgit checkout --track -b fork fork/<somebranch>\n\tgit submodule init\n\tgit submodule update\n\nwill retrive new submodules from remote \"fork\", and define fork in the\nexisting modules. Origin remains undefined.\n\nNote: this latter case is a clear motivation for overriding \"origin\": after\nthe second test, the various submodules would have different ideas of\nremote \"origin\": these would point to different servers. This would\nentirely prevent the top-level branch.<name>.remote machinery from\ncontrolling the project as there is no uniform naming of remotes.\n\nSigned-off-by: Mark Levedahl <mlevedahl@gmail.com>\n---\n t/t7401-submodule-remote.sh |  104 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 104 insertions(+), 0 deletions(-)\n create mode 100755 t/t7401-submodule-remote.sh\n\ndiff --git a/t/t7401-submodule-remote.sh b/t/t7401-submodule-remote.sh\nnew file mode 100755\nindex 0000000..1a793db\n--- /dev/null\n+++ b/t/t7401-submodule-remote.sh\n@@ -0,0 +1,104 @@\n+#!/bin/sh\n+\n+test_description='Porcelain support for submodules with multiple remotes\n+\n+This test verifies operation of submodules using multiple remotes and\n+differing remote per top-level branch.  This includes ability to name the\n+default something other than origin, to follow the top-level\n+remote.<branch>, and to propagate definition of new remotes down to\n+submodules as needed.\n+'\n+\n+. ./test-lib.sh\n+\n+# the standard tests all work with one repo, but we need several..\n+rm -rf .git\n+\n+test_expect_success 'Prepare master repository with 1 submodule' '\n+\t(\n+\tmkdir master &&\n+\tcd master &&\n+\tgit init &&\n+\techo \"on master\" > master.txt &&\n+\tgit add master.txt &&\n+\tgit commit -m \"Add master.txt\" &&\n+\tmkdir submod1 &&\n+\tcd submod1 &&\n+\tgit init &&\n+\techo \"submod1\" > submod1.txt &&\n+\tgit add submod1.txt &&\n+\tgit commit -m \"Added submod1.txt\" &&\n+\tcd .. &&\n+\tgit submodule add ./submod1 submod1 &&\n+\tgit commit -m \"Added submodule submod1\"\n+\t)\n+'\n+\n+test_expect_success 'Clone master as fork' '\n+\t(\n+\tgit clone master fork &&\n+\tcd fork &&\n+\ttest \"$(git remote)\" = \"origin\" &&\n+\tgit submodule init &&\n+\tgit submodule update &&\n+\ttest -e submod1/.git\n+\t)\n+'\n+\n+test_expect_success 'Add second submodule in fork' '\n+\t(\n+\tcd fork &&\n+\tmkdir submod2 &&\n+\tcd submod2 &&\n+\tgit init &&\n+\techo \"submod2\" > submod2.txt &&\n+\tgit add submod2.txt &&\n+\tgit commit -m \"Added submod2.txt\" &&\n+\tcd .. &&\n+\tgit submodule add ./submod2 submod2 &&\n+\tgit commit -m \"Added submodule submod2 on fork\"\n+\t)\n+'\n+\n+test_expect_success 'Clone master using frotz instead of origin' '\n+\t(\n+\tgit clone -o frotz master worker &&\n+\tcd worker &&\n+\ttest \"$(git remote)\" = \"frotz\"\n+\t)\n+'\n+\n+test_expect_success 'Get submodules using frotz instead of origin' '\n+\t(\n+\tcd worker &&\n+\tgit submodule init &&\n+\tgit submodule update &&\n+\ttest -e submod1/.git &&\n+\tcd submod1 &&\n+\ttest \"$(git remote)\" = \"frotz\"\n+\t)\n+'\n+\n+test_expect_success 'Update using fork to get additional submodule' '\n+\t(\n+\tcd worker &&\n+\tgit remote add fork $(pwd)/../fork &&\n+\tgit fetch fork &&\n+\tgit checkout --track -b fork_master fork/master &&\n+\tgit submodule init &&\n+\tgit submodule update &&\n+\ttest -e submod2/.git &&\n+\tcd submod2 &&\n+\ttest \"$(git remote)\" = \"fork\" &&\n+\tcd ../submod1 &&\n+\tremotes1=$(git remote) &&\n+\tcase $remotes1 in\n+\t\tfork*frotz|frotz*fork)\n+\t\t\ttrue ;;\n+\t\t*)\n+\t\t\tfalse ;;\n+\tesac\n+\t)\n+'\n+\n+test_done\n-- \n1.5.4.18.g43c18\n"},{"id":"67271","messageId":"alpine.LSU.1.00.0802032237320.7372@racer.site","threadId":"11857","inReplyTo":"1202059867-1184-1-git-send-email-mlevedahl@gmail.com","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-03T22:43:43Z","receivedAt":"2008-02-03T22:43:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 3 Feb 2008, Mark Levedahl wrote:\n\n> This patch series was inspired by several issues dealing with multiple \n> remotes and submodules. The tests added as the last patch demonstrate \n> the specific use pattern to be supported, and that does not work \n> currently.\n\nIt seems that everytime you send a new patch series, it gets longer/more \ncomplicated/affects more and more of git.\n\nAs far as I understood, your problem was _purely_ a submodule issue.  I \nfind it utterly unnerving that you keep trying to sneak in _anything_ \nunrelated to submodules.\n\nSuch as the origin issue.\n\nI am getting pretty angry that you keep trying to complicating things in \nthat area!  origin is origin is origin.  It is the default remote.  It is \nwhat you can change to fetch from somewhere else _by default_.  So I \nabsolutely detest your changes in that regard, who help _noboy_ except \npeople who like confusion.\n\nSo just change remote.origin.url, but do not mess up our nice source code.\n\nIf your issue is with git-submodule, then fix _that_, and do not \"fix\" \n_anything_ else.\n\nThankyouverymuch,\nDscho\n"},{"id":"67315","messageId":"47A68C01.9000600@gmail.com","threadId":"11857","inReplyTo":"alpine.LSU.1.00.0802032237320.7372@racer.site","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-04T03:52:33Z","receivedAt":"2008-02-04T03:52:33Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Johannes Schindelin wrote:\n> Hi,\n>\n> As far as I understood, your problem was _purely_ a submodule issue.  I \n> find it utterly unnerving that you keep trying to sneak in _anything_ \n> unrelated to submodules.\n>   \nIt is not purely about submodules, but in fact about a centralized \nconcept (named \"origin\") disrupting a distributed workflow using \nsubmodules in a distributed version control system.\n> I am getting pretty angry that you keep trying to complicating things in \n> that area!  \nIt is easy to substitute emotion for sound technical arguments. Please \ndon't, it helps no one.\n\nMark\n"},{"id":"67319","messageId":"A3A63507-41CA-4FE0-BE77-BF6987E87AD2@zib.de","threadId":"11857","inReplyTo":"alpine.LSU.1.00.0802032237320.7372@racer.site","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-02-04T05:19:40Z","receivedAt":"2008-02-04T05:19:40Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Feb 3, 2008, at 11:43 PM, Johannes Schindelin wrote:\n\n> On Sun, 3 Feb 2008, Mark Levedahl wrote:\n>\n>> This patch series was inspired by several issues dealing with  \n>> multiple\n>> remotes and submodules. The tests added as the last patch demonstrate\n>> the specific use pattern to be supported, and that does not work\n>> currently.\n>\n> It seems that everytime you send a new patch series, it gets longer/ \n> more\n> complicated/affects more and more of git.\n>\n> As far as I understood, your problem was _purely_ a submodule  \n> issue.  I\n> find it utterly unnerving that you keep trying to sneak in _anything_\n> unrelated to submodules.\n>\n> Such as the origin issue.\n\nAs fas as I understood, Mark's usage of submodules might have\nrevealed a deficiency in the current handling of origin.\n\nMark described a distributed workflow that actively uses more than\na single server to store repositories and these different servers\nare not pure replicates of each other.  As a consequence the name\nof the server has a meaning for the users and therefore the workflow\nmakes this explicit by never using \"origin\" but instead use\ndescriptive names for the remotes.  He described situations when\npeople want to speak about what they have in their repositories\nand want to describe where they pulled from.  I can well imaging\nthat the result of everyone saying \"I pulled from origin\" can cause\ngreat confusion if origin means different things; and therefore it\nis a reasonable choice to completely avoid origin.\n\nPartly because of this explanation by Mark and the problems he\ndescribed, I decided against using submodules, but instead merged\nall the submodules that I originally planned to keep separate into\na single monolithic repository.  I expect that a single repository\nworks well because this is what the Linux kernel uses.\n\n\n> I am getting pretty angry that you keep trying to complicating  \n> things in\n> that area!  origin is origin is origin.  It is the default remote.   \n> It is\n> what you can change to fetch from somewhere else _by default_.  So I\n> absolutely detest your changes in that regard, who help _noboy_ except\n> people who like confusion.\n>\n> So just change remote.origin.url, but do not mess up our nice  \n> source code.\n>\n> If your issue is with git-submodule, then fix _that_, and do not \"fix\"\n> _anything_ else.\n\nIf I understood Mark correctly, this would not solve his problem\nbecause he wants to *avoid* origin; and his arguments make sense\nto me.  Unfortunately I cannot contribute any real world\nexperience, because I chose to abandoned the idea of using\nsubmodules.\n\nHowever, this does not mean that I'll never use submodules.\nActually I am pretty sure submodules could become very helpful\nend of March; and I should also support multiple servers at that\ntime.  So I would be happy if the use case described by Mark was\nwell supported by git.\n\n\tSteffen\n"},{"id":"67366","messageId":"alpine.LSU.1.00.0802041443420.7372@racer.site","threadId":"11857","inReplyTo":"47A68C01.9000600@gmail.com","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-04T14:48:12Z","receivedAt":"2008-02-04T14:48:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 3 Feb 2008, Mark Levedahl wrote:\n\n> Johannes Schindelin wrote:\n> \n> > As far as I understood, your problem was _purely_ a submodule issue.  \n> > I find it utterly unnerving that you keep trying to sneak in \n> > _anything_ unrelated to submodules.\n>\n> It is not purely about submodules, but in fact about a centralized \n> concept (named \"origin\") disrupting a distributed workflow using \n> submodules in a distributed version control system.\n\nThe \"origin\" concept has nothing to do with a centralised concept.  It is \nthere _purely_ for convenience.  If you want to fetch/pull from somewhere, \nyou _have_ to specify from where, _except_ if you use the default.\n\nSo your argument here is absolutely bogus.\n\n> > I am getting pretty angry that you keep trying to complicating things \n> > in that area!\n>\n> It is easy to substitute emotion for sound technical arguments. Please \n> don't, it helps no one.\n\nI take it very personal if you ignore me and my arguments, so please \ndon't.  My apologies for answering emotionally.  (I could even say that it \nis easier to ignore sound technical arguments than to substitute emotion \nfor them.)\n\nMy recommendation: fix submodule, and submodule only.  For your specific \nneeds.  Hint: you do not need to introduce core.origin for that (as \nshould have become totally obvious by now).\n\nShould something like core.origin still be an issue (which I doubt, for \nthe same reason you do not change the _name_ of the environment variable \n$HOME), we can still continue discussing that.\n\nHth,\nDscho\n"},{"id":"67368","messageId":"alpine.LSU.1.00.0802041449300.7372@racer.site","threadId":"11857","inReplyTo":"A3A63507-41CA-4FE0-BE77-BF6987E87AD2@zib.de","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-04T14:55:26Z","receivedAt":"2008-02-04T14:55:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 4 Feb 2008, Steffen Prohaska wrote:\n\n> On Feb 3, 2008, at 11:43 PM, Johannes Schindelin wrote:\n> \n> > If your issue is with git-submodule, then fix _that_, and do not \"fix\" \n> > _anything_ else.\n> \n> If I understood Mark correctly, this would not solve his problem\n> because he wants to *avoid* origin;\n\nSo he should *avoid* origin.  Not redefine it.\n\nFor example, if you want to update your submodules from their respective \n\"bollywog\" remotes, it is perfectly fine with me to introduce a notion\n\n\t$ git submodule update --from bollywog\n\nIf you do not want to fetch from here one time, and from there the next, \nthen there is _simply_ _no_ _point_ in pointing to another remote _name_.\n\nYou cannot put multiple urls into .gitmodules _anyway_, so they _have_ to \nbe modified locally, and then the people can look up their remote urls.\n\nPutting in another layer of indirection, which can very well be \nunsynchronised is what I am strongly in \"unfavour\" of.\n\nFrankly, I am puzzled how long this discussion drags on.  If I would not \nbe concerned about the loss of simplicity of git's core _and concepts_, I \nwould not even bother to respond.\n\nCiao,\nDscho\n"},{"id":"67386","messageId":"30e4a070802040924g550671ccsb11108c71c99e378@mail.gmail.com","threadId":"11857","inReplyTo":"alpine.LSU.1.00.0802041443420.7372@racer.site","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2008-02-04T17:24:32Z","receivedAt":"2008-02-04T17:24:32Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"On Feb 4, 2008 9:48 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n>\n> Should something like core.origin still be an issue (which I doubt, for\n> the same reason you do not change the _name_ of the environment variable\n> $HOME), we can still continue discussing that.\n>\n> Hth,\n> Dscho\n>\n>\nBIG difference here:\n$HOME = <name> of home directory, <name> is arbitrary. Files there are\nfound as $HOME/<foo> or <name>/foo, they are the same, and I am free\nto set HOME=<arbitrary name>.\n\nCurrently\n$ORIGIN=origin, i.e., the default is *named* origin, not the default\nname is given by $ORIGIN.\n\nWhy does this matter? git stores the remote's branches under\nrefs/remotes/<name>/*. If name=$ORIGIN, I am happy, but the problem is\n$ORIGIN=origin, and you argue (strongly) that it MUST be origin. Thus,\nbranches from server \"frotz\" *might* be in refs/remotes/frotz/*, or\nthey *might* be in refs/remotes/origin/*, and that is the root of the\nproblem.\n\nBy the same argument, you have hardcoded in your shell that $HOME=/home, right?\n\nMark\n"},{"id":"67395","messageId":"alpine.LSU.1.00.0802041813110.7372@racer.site","threadId":"11857","inReplyTo":"30e4a070802040924g550671ccsb11108c71c99e378@mail.gmail.com","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-04T18:15:32Z","receivedAt":"2008-02-04T18:15:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 4 Feb 2008, Mark Levedahl wrote:\n\n> On Feb 4, 2008 9:48 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>\n> > Should something like core.origin still be an issue (which I doubt, \n> > for the same reason you do not change the _name_ of the environment \n> > variable $HOME), we can still continue discussing that.\n\nActually, I said more things.  Things about fixing git-submodule first, so \nthat you can ask it to update via different remotes than \"origin\".  And \nthen try to argue for the rest.\n\n> BIG difference here:\n> $HOME = <name> of home directory, <name> is arbitrary. Files there are\n> found as $HOME/<foo> or <name>/foo, they are the same, and I am free\n> to set HOME=<arbitrary name>.\n> \n> Currently\n> $ORIGIN=origin, i.e., the default is *named* origin, not the default\n> name is given by $ORIGIN.\n\n\"origin\" is just the name of the default origin, holding the remote URL.  \nJust like \"HOME\" is just the name of the variable holding the home \ndirectory.\n\nBut really.  Fix git-submodule first.\n\nCiao,\nDscho\n"},{"id":"67409","messageId":"7vbq6wjxx1.fsf@gitster.siamese.dyndns.org","threadId":"11857","inReplyTo":"30e4a070802040924g550671ccsb11108c71c99e378@mail.gmail.com","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-04T19:59:06Z","receivedAt":"2008-02-04T19:59:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Mark Levedahl\" <mlevedahl@gmail.com> writes:\n\n> BIG difference here:\n> $HOME = <name> of home directory, <name> is arbitrary. Files there are\n> found as $HOME/<foo> or <name>/foo, they are the same, and I am free\n> to set HOME=<arbitrary name>.\n\nI think you misunderstood Dscho's $HOME analogy.\n\nFor example, the value of HOME environment variable is used as a\nshorthand to where you go to when you say\n\n\t$ cd\n\nEverybody is happy that the variable is called HOME, and nobody\nwould complain that the shell does not have another mechanism to\nlet you have this in your .bashrc\n\n\t#!/bin/bash\n\tHOMEENVVAR=BASE\n\tBASE=/home/mark\n        export HOMEENVVAR BASE\n\nand make the parameterless \"cd\" honor the environment variable\nnamed with HOMEENVVER (in this case, BASE) instead.\n\nRemote shorthand is exactly like a variable name.  We say \"git\npull origin\" and do not say \"git pull $origin\", but that is just\na syntax issue.  And \"git pull\" and friends are defined to\ndefault to the value of the origin 'variable' exactly like \"cd\"\nis defined to default to the value of the HOME variable.\n\nI would agree 100% with Dscho on this point, if we did not have\n\"clone -o\".\n\n\"clone -o\" is like the above HOMEENVVAR variable.  It lets you\nrename what name other than origin is used to name what the\norigin 'variable' usually names, or at least pretends to let you\ndo so.  But its effect may not extend far enough and if there is\nsuch inconsistency, that is a bug worth fixing.  For example, I\nthink \"git fetch\" is Ok for basic use, because \"clone -o\" writes\nbranch.master.remote in .git/config that points to the name you\ngave instead of 'origin', but there may be places that do use\nhardwired 'origin' and nothing else.\n\nAnd that is the only reason I am still responding to this\nthread.\n\nIf a supermodule wants a specific remote to be used in a\nsubmodule, it should not default to 'origin' but it should name\nthat specific remote explicitly.  Even if we added the mechanism\nthat looks like HOMEENVVAR to tell commands other than \"git\nfetch\" to default to something other than 'origin', I do not\nthink such a use of submodule should depend on that fallback.  I\nstill haven't dismissed Dscho's argument that submodule related\nissues should be handled inside git-submodule for that reason.\n\nWe could remove support for \"clone -o\" and consistently use\n'origin' as the default everywhere and completely remove the\nhalf-baked HOMEENVVAR lookalike.  I do not think such a move is\na good idea, but the point is that the solution to your\nsubmodule problem should work even if we did so.  If the\nsupermodule and a set of submodules are configured to use a\nspecific remote that is not 'origin', it should use that\nspecific remote by _naming_ it, not relying on where the\nfallback value is taken by other unrelated parts of the system,\nno?\n"},{"id":"67418","messageId":"alpine.LSU.1.00.0802042027470.8543@racer.site","threadId":"11857","inReplyTo":"7vbq6wjxx1.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-04T20:47:26Z","receivedAt":"2008-02-04T20:47:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 4 Feb 2008, Junio C Hamano wrote:\n\n> I would agree 100% with Dscho on this point, if we did not have \"clone \n> -o\".\n\nAFAICT \"clone -o\" was meant _only_ for this scenario:\n\nYou have a slow connection, but someone can provide you with a thumb \ndrive, having the current repository.\n\nYou clone it from the thumb drive, but of course you want to use your \n(slow) connection for subsequent updates (i.e. you want to have a \ndifferent default remote).\n\nWhat you do is\n\n\t$ git clone -o thumbdrive /media/usbdisk/that-repository.git/\n\nThen, to be able to update from your preferred remote quickly, you add the \nproper remote:\n\n\t$ git remote add --fetch origin git://git.kernel.org/shlub.git/\n\nIn my understanding, this scenario is the only reason to live for clone's \n-o option, and it would be actively wrong for it to change the _name_ of \nthe default remote to \"thumbdrive\".\n\nNow, Steffen understood that Mark tries to avoid the use of \"origin\".  \nBut why, then, does he wish for _the same_ kettle, but call it chair?\n\nI mean, I can understand if you want to update your submodules from \nanother server.  What I do then, is to go into that subdirectory, fetch \nfrom that other server, and that's it.\n\nI can even understand that you have to update your submodules sometimes \nfrom here, sometimes from there.\n\nFine.  You just add remotes for the different servers, cd into the \nsubmodules, and fetch from them.\n\nI could even see (but not use it myself) that you want to fetch a set of \nsubmodules from server A on Mondays, from server B on Tuesdays, and from \nserver C on Wednesdays, and want to have a nice shortcut for that.  Of \ncourse, I'd use aliases.  But I can see that people want a \"--remote\" \noption to \"git submodule update\".\n\nHowever, what I cannot see _at all_ is that you have a default remote in a \nset (or all) submodules, and wish to change a perfectly fine terminology \n[*1*].\n\nI cannot see why you want to have a default remote to fetch from, and not \ncall it \"origin\", which would keep things easy and simple.  \"What is the \nremote called that 'git fetch' fetches from, by default?\" -- \"origin\".\n\nSimple.  Nice.  Consistent.\n\nMy understanding is that a patch is needed for _git-submodule_, to support \nthat workflow (the one with servers A, B and C), even if I would not use \nthat option.\n\nWhat we do not need is to confuse git users, what with all those \ncomplaints that git is too complicated.\n\nHopefully I finally made myself clear.\n\nCiao,\nDscho\n\n*1*: I heard the argument put forth that giving the default remote a \ndifferent name, so that people know what server they pull from.  That's \njust, uh, unbelievable.  If it is the default remote the user is fetching \nfrom, all the user will call is \"git fetch\", and not even _know_ the \nnickname.\n\nBesides, if you call it \"berlin\", the _url_ can still point to \ngit://git.beijing.cn/great-wall.git/.\n\nAnother besides: if you ask the user to look up the nickname of the \ndefault remote, you can as well ask the user to look up the url of \n\"origin\".\n\nThere is _no need_ to complicate git for a workflow that could be solved \nin a more elegant and less error-prone way to begin with.\n\nP.S.: sorry for this long mail.  I usually like to make a concise point.  \nBut in this discussion, it got me misunderstood, ignored, or both.\n"},{"id":"67432","messageId":"7v1w7sjt7n.fsf@gitster.siamese.dyndns.org","threadId":"11857","inReplyTo":"alpine.LSU.1.00.0802042027470.8543@racer.site","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-04T21:40:44Z","receivedAt":"2008-02-04T21:40:44Z","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> AFAICT \"clone -o\" was meant _only_ for this scenario:\n>\n> You have a slow connection, but someone can provide you with a thumb \n> drive, having the current repository.\n>\n> You clone it from the thumb drive, but of course you want to use your \n> (slow) connection for subsequent updates (i.e. you want to have a \n> different default remote).\n>\n> What you do is\n>\n> \t$ git clone -o thumbdrive /media/usbdisk/that-repository.git/\n>\n> Then, to be able to update from your preferred remote quickly, you add the \n> proper remote:\n>\n> \t$ git remote add --fetch origin git://git.kernel.org/shlub.git/\n>\n> In my understanding, this scenario is the only reason to live for clone's \n> -o option, and it would be actively wrong for it to change the _name_ of \n> the default remote to \"thumbdrive\".\n\nThen we should fix \"git-clone\".\n\nIf you do the first command, I am reasonably sure that you would\nget:\n\n\t[branch \"master\"]\n        \tremote = thumbdrive\n\nin your .git/config.  You may want to occasionally go back to\nthumbdrive for sneakernetting, so I do not think we should\nremove [remote \"thumbdrive\"] section the clone would leave, but\nthe above \"master branch would interact with thumbdrive\nrepository\" should not be there.\n\nAnd that corrected behaviour and the intended use of -o should\nbe documented.\n"},{"id":"67433","messageId":"alpine.LSU.1.00.0802042149030.8543@racer.site","threadId":"11857","inReplyTo":"7v1w7sjt7n.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0 of 7] [resend] - Improve handling remotes, origin, submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-04T21:49:32Z","receivedAt":"2008-02-04T21:49:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 4 Feb 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > AFAICT \"clone -o\" was meant _only_ for this scenario:\n> >\n> > You have a slow connection, but someone can provide you with a thumb \n> > drive, having the current repository.\n> >\n> > You clone it from the thumb drive, but of course you want to use your \n> > (slow) connection for subsequent updates (i.e. you want to have a \n> > different default remote).\n> >\n> > What you do is\n> >\n> > \t$ git clone -o thumbdrive /media/usbdisk/that-repository.git/\n> >\n> > Then, to be able to update from your preferred remote quickly, you add \n> > the proper remote:\n> >\n> > \t$ git remote add --fetch origin git://git.kernel.org/shlub.git/\n> >\n> > In my understanding, this scenario is the only reason to live for \n> > clone's -o option, and it would be actively wrong for it to change the \n> > _name_ of the default remote to \"thumbdrive\".\n> \n> Then we should fix \"git-clone\".\n> \n> If you do the first command, I am reasonably sure that you would get:\n> \n> \t[branch \"master\"]\n>         \tremote = thumbdrive\n> \n> in your .git/config.  You may want to occasionally go back to thumbdrive \n> for sneakernetting, so I do not think we should remove [remote \n> \"thumbdrive\"] section the clone would leave, but the above \"master \n> branch would interact with thumbdrive repository\" should not be there.\n> \n> And that corrected behaviour and the intended use of -o should be \n> documented.\n\nFully agree.  It is now point 38 on my ever-growing TODO list.\n\nCiao,\nDscho\n"}]}