{"thread":{"id":"20801","subject":"[PATCH] git-submodule and --upload-pack","startedAt":"2009-08-31T13:52:07Z","lastAt":"2009-09-02T12:41:33Z","messageCount":3,"participants":["Giulio Eulisse","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"122187","messageId":"9D7140EC-EAFD-4408-93E3-0E756BA363DA@cern.ch","threadId":"20801","inReplyTo":null,"subject":"[PATCH] git-submodule and --upload-pack","fromName":"Giulio Eulisse","fromEmail":"giulio.eulisse@cern.ch","sentAt":"2009-08-31T13:52:07Z","receivedAt":"2009-08-31T13:52:07Z","isPatch":true,"sender":{"key":"giulio.eulisse@cern.ch","avatar":null},"body":"Ciao,\n\nThere was a thread a while ago aboyt having --upload-pack support for  \ngit-submodule.\n\nGiven that there was no followup (as far as I can tell) and I needed  \npretty much\nthe same functionality I ported Jason's patch to work on top of 1.6.4.2.\n\nComments?\n\nCiao,\nGiulio\n--\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git- \nsubmodule.txt\nindex 683ba1a..50aa930 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -9,8 +9,8 @@ git-submodule - Initialize, update or inspect submodules\n  SYNOPSIS\n  --------\n  [verse]\n-'git submodule' [--quiet] add [-b branch]\n-\t      [--reference <repository>] [--] <repository> <path>\n+'git submodule' [--quiet] add [-b branch]\n+              [-u <git-upload-pack>] [--receive-pack <git-receive- \npack>] [--reference <repository>] [--] <repository> <path>\n  'git submodule' [--quiet] status [--cached] [--] [<path>...]\n  'git submodule' [--quiet] init [--] [<path>...]\n  'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]\n@@ -164,6 +164,19 @@ OPTIONS\n  --branch::\n  \tBranch of repository to add as submodule.\n\n+--upload-pack <upload-pack>::\n+-u <upload-pack>::\n+\tWhen given, and the repository to clone from is accessed\n+\tvia ssh, this specifies a non-default path for the\n+\t'git-upload-pack' program on the remote end.  See\n+\tlinkgit:git-fetch-pack[1].\n+\n+--receive-pack <receive-pack>::\n+\tWhen given, and the repository to clone from is accessed\n+\tvia ssh, this specifies a non-default path for the\n+\t'git-receive-pack' program on the remote end.  See\n+\tlinkgit:git-push[1].\n+\n  --cached::\n  \tThis option is only valid for status and summary commands.  These\n  \tcommands typically use the commit found in the submodule HEAD, but\ndiff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt\nindex 5daf750..bf982a6 100644\n--- a/Documentation/gitmodules.txt\n+++ b/Documentation/gitmodules.txt\n@@ -30,6 +30,14 @@ submodule.<name>.path::\n  submodule.<name>.url::\n  \tDefines an url from where the submodule repository can be cloned.\n\n+submodule.<name>.receivepack::\n+\tThe default program to execute on the remote side when pushing.  See\n+\toption \\--receive-pack of linkgit:git-push[1].\n+\n+submodule.<name>.uploadpack::\n+\tThe default program to execute on the remote side when fetching.  See\n+\toption \\--upload-pack of linkgit:git-fetch-pack[1].\n+\n  submodule.<name>.update::\n  \tDefines what to do when the submodule is updated by the superproject.\n  \tIf 'checkout' (the default), the new commit specified in the\n@@ -41,7 +49,6 @@ submodule.<name>.update::\n  \tThis config option is overridden if 'git submodule update' is given\n  \tthe '--merge' or '--rebase' options.\n\n-\n  EXAMPLES\n  --------\n\n@@ -53,12 +60,16 @@ Consider the following .gitmodules file:\n\n  \t[submodule \"libbar\"]\n  \t\tpath = include/bar\n-\t\turl = git://bar.com/git/lib.git\n+\t\turl = ssh://bar.com/~/git/lib.git\n+\t\tuploadpack = /home/you/bin/git-upload-pack-wrapper\n+\t\treceivepack = /home/you/bin/git-receive-pack-wrapper\n\n\n  This defines two submodules, `libfoo` and `libbar`. These are  \nexpected to\n  be checked out in the paths 'include/foo' and 'include/bar', and for  \nboth\n  submodules an url is specified which can be used for cloning the  \nsubmodules.\n+For `libbar`, packs are retrieved and stored via the upload and receive\n+wrappers, respectively.\n\n  SEE ALSO\n  --------\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ebed711..25edd59 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -82,6 +82,8 @@ module_clone()\n  \tpath=$1\n  \turl=$2\n  \treference=\"$3\"\n+        uploadpack=$4\n+        receivepack=$5\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@@ -97,13 +99,30 @@ module_clone()\n  \ttest -e \"$path\" &&\n  \tdie \"A file already exist at path '$path'\"\n\n+        uploadpackCmd=\"\"\n+\n+        if test \"$uploadpack\"\n+        then\n+          uploadpackCmd=\"--upload-pack $uploadpack\"\n+        fi\n+\n  \tif test -n \"$reference\"\n  \tthen\n-\t\tgit-clone \"$reference\" -n \"$url\" \"$path\"\n+\t\tgit-clone $uploadpackCmd \"$reference\" -n \"$url\" \"$path\"\n  \telse\n-\t\tgit-clone -n \"$url\" \"$path\"\n+\t\tgit-clone $uploadpackCmd -n \"$url\" \"$path\"\n  \tfi ||\n  \tdie \"Clone of '$url' into submodule path '$path' failed\"\n+\tif test \"$uploadpack\"\n+\tthen\n+\t    git config -f \"${path}/.git/config\" remote.origin.uploadpack  \n\"$uploadpack\" ||\n+\t    echo \"  Warn: Failed to set uploadpack for '$url' in submodule  \npath '$path'.\"\n+\tfi\n+\tif test \"$receivepack\"\n+\tthen\n+\t    git config -f \"${path}/.git/config\" remote.origin.receivepack  \n\"$receivepack\" ||\n+\t    echo \"  Warn: Failed to set receivepack for '$url' in submodule  \npath '$path'.\"\n+\tfi\n  }\n\n  #\n@@ -136,6 +155,16 @@ cmd_add()\n  \t\t\treference=\"$1\"\n  \t\t\tshift\n  \t\t\t;;\n+\t\t-u|--upload-pack)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\tuploadpack=$2\n+\t\t\tshift\n+\t\t\t;;\n+\t\t--receive-pack)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\treceivepack=$2\n+\t\t\tshift\n+\t\t\t;;\n  \t\t--)\n  \t\t\tshift\n  \t\t\tbreak\n@@ -206,9 +235,17 @@ cmd_add()\n  \t\t\t;;\n  \t\tesac\n  \t\tgit config submodule.\"$path\".url \"$url\"\n+\t\tif test \"$uploadpack\"\n+\t\t\tthen\n+\t\t    git config submodule.\"$path\".uploadpack \"$uploadpack\"\n+\t\tfi\n+\t\tif test \"$receivepack\"\n+\t\tthen\n+\t\t    git config submodule.\"$path\".receivepack \"$receivepack\"\n+\t\tfi\n  \telse\n\n-\t\tmodule_clone \"$path\" \"$realrepo\" \"$reference\" || exit\n+\t\tmodule_clone \"$path\" \"$realrepo\" \"$reference\" \"$uploadpack\"  \n\"$receivepack\" || exit\n  \t\t(\n  \t\t\tunset GIT_DIR\n  \t\t\tcd \"$path\" &&\n@@ -224,7 +261,19 @@ cmd_add()\n  \tdie \"Failed to add submodule '$path'\"\n\n  \tgit config -f .gitmodules submodule.\"$path\".path \"$path\" &&\n-\tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" &&\n+\tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" ||\n+\tdie \"Failed to register submodule '$path'\"\n+\n+\tif test \"$uploadpack\"\n+        then\n+\t    git config -f .gitmodules submodule.\"$path\".uploadpack  \n\"$uploadpack\" ||\n+\t    die \"Failed to register submodule '$path'\"\n+\tfi\n+\tif test \"$receivepack\"\n+        then\n+\t    git config -f .gitmodules submodule.\"$path\".receivepack  \n\"$receivepack\" ||\n+\t    die \"Failed to register submodule '$path'\"\n+\tfi\n  \tgit add .gitmodules ||\n  \tdie \"Failed to register submodule '$path'\"\n  }\n@@ -299,6 +348,19 @@ cmd_init()\n  \t\tgit config submodule.\"$name\".url \"$url\" ||\n  \t\tdie \"Failed to register url for submodule path '$path'\"\n\n+\t\tuploadpack=$(git config -f .gitmodules submodule.\"$name\".uploadpack)\n+\t\treceivepack=$(git config -f .gitmodules  \nsubmodule.\"$name\".receivepack)\n+\t\tif test \"$uploadpack\"\n+\t\tthen\n+\t\t    git config submodule.\"$name\".uploadpack \"$uploadpack\" ||\n+\t\t    echo \"  Warn: Failed to set uploadpack for '$url' in submodule  \npath '$path'.\"\n+\t\tfi\n+\t\tif test \"$receivepack\"\n+\t\tthen\n+\t\t    git config submodule.\"$name\".receivepack \"$receivepack\" ||\n+\t\t    echo \"  Warn: Failed to set receivepack for '$url' in submodule  \npath '$path'.\"\n+\t\tfi\n+\n  \t\tupd=\"$(git config -f .gitmodules submodule.\"$name\".update)\"\n  \t\ttest -z \"$upd\" ||\n  \t\tgit config submodule.\"$name\".update \"$upd\" ||\n@@ -384,7 +446,8 @@ cmd_update()\n\n  \t\tif ! test -d \"$path\"/.git -o -f \"$path\"/.git\n  \t\tthen\n-\t\t\tmodule_clone \"$path\" \"$url\" \"$reference\"|| exit\n+\t\t\tmodule_clone \"$path\" \"$url\" \"$reference\" \"$(git config  \nsubmodule.\"$name\".uploadpack)\" \\\n+                            \"$(git config  \nsubmodule.\"$name\".receivepack)\" || exit\n  \t\t\tsubsha1=\n  \t\telse\n  \t\t\tsubsha1=$(unset GIT_DIR; cd \"$path\" &&\n@@ -738,6 +801,18 @@ cmd_sync()\n  \t\t\tremote=$(get_default_remote)\n  \t\t\tsay \"Synchronizing submodule url for '$name'\"\n  \t\t\tgit config remote.\"$remote\".url \"$url\"\n+\t\t\tuploadpack=$(git config -f .gitmodules submodule.\"$name\".uploadpack)\n+\t\t\treceivepack=$(git config -f .gitmodules  \nsubmodule.\"$name\".receivepack)\n+\t\t\tif test \"$uploadpack\"\n+\t\t\tthen\n+\t\t\t    git config submodule.\"$name\".uploadpack \"$uploadpack\" ||\n+\t\t\t    echo \"  Warn: Failed to set uploadpack for '$url' in submodule  \npath '$name'.\"\n+\t\t\tfi\n+\t\t\tif test \"$receivepack\"\n+\t\t\tthen\n+\t\t\t    git config submodule.\"$name\".receivepack \"$receivepack\" ||\n+\t\t\t    echo \"  Warn: Failed to set receivepack for '$url' in  \nsubmodule path '$name'.\"\n+\t\t\tfi\n  \t\t)\n  \t\tfi\n  \tdone\n"},{"id":"122214","messageId":"7vk50jtud8.fsf@alter.siamese.dyndns.org","threadId":"20801","inReplyTo":"9D7140EC-EAFD-4408-93E3-0E756BA363DA@cern.ch","subject":"Re: [PATCH] git-submodule and --upload-pack","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-31T23:51:31Z","receivedAt":"2009-08-31T23:51:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Giulio Eulisse <Giulio.Eulisse@cern.ch> writes:\n\n> There was a thread a while ago aboyt having --upload-pack support for\n> git-submodule.\n>\n> Given that there was no followup (as far as I can tell) and I needed\n> pretty much\n> the same functionality I ported Jason's patch to work on top of 1.6.4.2.\n\nThanks.\n\nCan you point at the original patch with a usable commit log message, in\nthe gmane archive (i.e. http://thread.gmane.org/...) if possible?  I\ndo not think we have that patch queued anywhere even in 'pu'.\n\nGiven that it looks like a new feature, I do not think it would be\nappropriate for any of the future 1.6.4.X series, but if it is useful we\nmay want to have it in the upcoming 1.6.5 release.\n\n> Comments?\n\nSee below.\n\n> diff --git a/Documentation/git-submodule.txt b/Documentation/git- \n> submodule.txt\n\nThe patch is linewrapped and will not be applicable.  But I'll comment on\nthe contents to save a round-trip.\n\n> diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt\n> index 5daf750..bf982a6 100644\n> --- a/Documentation/gitmodules.txt\n> +++ b/Documentation/gitmodules.txt\n> @@ -30,6 +30,14 @@ submodule.<name>.path::\n>  submodule.<name>.url::\n>  \tDefines an url from where the submodule repository can be cloned.\n>\n> +submodule.<name>.receivepack::\n> +\tThe default program to execute on the remote side when pushing.  See\n> +\toption \\--receive-pack of linkgit:git-push[1].\n> +\n> +submodule.<name>.uploadpack::\n> +\tThe default program to execute on the remote side when fetching.  See\n> +\toption \\--upload-pack of linkgit:git-fetch-pack[1].\n\nThis placement of description in the documentation and variables in the\nnamespace quite sane, as these are properties of the remote site, and they\nbelong together with submodule.<name>.url.\n\n> @@ -53,12 +60,16 @@ Consider the following .gitmodules file:\n>\n>  \t[submodule \"libbar\"]\n>  \t\tpath = include/bar\n> -\t\turl = git://bar.com/git/lib.git\n> +\t\turl = ssh://bar.com/~/git/lib.git\n> +\t\tuploadpack = /home/you/bin/git-upload-pack-wrapper\n> +\t\treceivepack = /home/you/bin/git-receive-pack-wrapper\n> ...\n> +For `libbar`, packs are retrieved and stored via the upload and receive\n> +wrappers, respectively.\n\nUsing a custom wrapper in this example feels very misleading.  The option\nis primarily meant as a workaround for a broken or hard-to-modify sshd\nsettings that does not allow you to include the directory you installed\nupload-pack/receive-pack to the PATH environment when the ssh session is\nnot interactive.\n\n> @@ -97,13 +99,30 @@ module_clone()\n>  \ttest -e \"$path\" &&\n>  \tdie \"A file already exist at path '$path'\"\n>\n> +        uploadpackCmd=\"\"\n> +\n> +        if test \"$uploadpack\"\n> +        then\n> +          uploadpackCmd=\"--upload-pack $uploadpack\"\n\nCan the value of uploadpack contain a shell IFS?  This is a rhetorical\nquestion---read on.\n\n> +        fi\n> +\n>  \tif test -n \"$reference\"\n>  \tthen\n> -\t\tgit-clone \"$reference\" -n \"$url\" \"$path\"\n> +\t\tgit-clone $uploadpackCmd \"$reference\" -n \"$url\" \"$path\"\n\nWithout using uploadpackCmd and risking to trash IFS characters in the\nvariable, you can do something like:\n\n    git clone ${uploadpack+--upload-pack \"$uploadpack\"} ...\n\nI would prefer the code not to set variable \"uploadpack\" when nothing is\nspecified, instead of setting it to an empty string like this patch does,\nbut if you are going to use an empty string as a signal that no uploadpack\nis specified, then you would need a colon between 'k'and '+' in the above.\n\n> @@ -738,6 +801,18 @@ cmd_sync()\n>  \t\t\tremote=$(get_default_remote)\n>  \t\t\tsay \"Synchronizing submodule url for '$name'\"\n>  \t\t\tgit config remote.\"$remote\".url \"$url\"\n> +\t\t\tuploadpack=$(git config -f .gitmodules submodule.\"$name\".uploadpack)\n> +\t\t\treceivepack=$(git config -f .gitmodules\n> submodule.\"$name\".receivepack)\n> +\t\t\tif test \"$uploadpack\"\n> +\t\t\tthen\n> +\t\t\t    git config submodule.\"$name\".uploadpack \"$uploadpack\" ||\n> +\t\t\t    echo \"  Warn: Failed to set uploadpack for\n> $url' in submodule  path '$name'.\"\n> +\t\t\tfi\n> +\t\t\tif test \"$receivepack\"\n> +\t\t\tthen\n> +\t\t\t    git config submodule.\"$name\".receivepack \"$receivepack\" ||\n> +\t\t\t    echo \"  Warn: Failed to set receivepack\n> for '$url' in  submodule path '$name'.\"\n> +\t\t\tfi\n>  \t\t)\n\nI do not agree with this part, nor what the \"cmd_init\" does.\n\nHaving URL/uploadpack/receivepack 3-tuple in the tracked .gitmodules is\nsensible, as that is how the project expresses its recommendations to\npeople who clone the toplevel project.\n\nHowever, after the top-level project is cloned and the submodules are\npopulated in the work tree of the person who cloned, I think these values\nshould be propagated to $path/.git/config, i.e. the configuration file of\nthe submodule checkout.\n\nInside cmd_update(), there is this code snippet:\n\n\tif test -z \"$nofetch\"\n\tthen\n\t\t(unset GIT_DIR; cd \"$path\" &&\n\t\t\tgit-fetch) ||\n\t\tdie \"Unable to fetch in submodule path '$path'\"\n\tfi\n\nAnd the patch does not touch it.  For this git-fetch to honour the custom\nuploadpack your user configured, remote.origin.uploadpack variable in the\nconfiguration file of the submodule checkout needs to be updated, because\nthis fetch will not (and should not) look at the configuration file of the\nsuperproject.\n\nYou _could_ also copy them to submodule.$name.$var of the top-level\nproject if you really wanted to, but I do not think doing so serves any\nuseful purpose.\n"},{"id":"122307","messageId":"C58D88DD-1AB7-4727-ABDA-9AC0DEA53A3D@cern.ch","threadId":"20801","inReplyTo":"7vk50jtud8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-submodule and --upload-pack","fromName":"Giulio Eulisse","fromEmail":"giulio.eulisse@cern.ch","sentAt":"2009-09-02T12:41:33Z","receivedAt":"2009-09-02T12:41:33Z","isPatch":true,"sender":{"key":"giulio.eulisse@cern.ch","avatar":null},"body":">> There was a thread a while ago aboyt having --upload-pack support for\n>> git-submodule.\n>>\n>> Given that there was no followup (as far as I can tell) and I needed\n>> pretty much\n>> the same functionality I ported Jason's patch to work on top of  \n>> 1.6.4.2.\n>\n> Thanks.\n>\n> Can you point at the original patch with a usable commit log  \n> message, in\n> the gmane archive (i.e. http://thread.gmane.org/...) if possible?  I\n> do not think we have that patch queued anywhere even in 'pu'.\n\nCiao,\nsorry for the mangled patch... Looks like Mail.app did something  \nweird...\n\nhttp://article.gmane.org/gmane.comp.version-control.git/104188/match=git+submodule+upload+pack\n\n\n> Given that it looks like a new feature, I do not think it would be\n> appropriate for any of the future 1.6.4.X series, but if it is  \n> useful we\n> may want to have it in the upcoming 1.6.5 release.\n[...]\n\nOk. I will try to follow your suggestion and post an updated patch.\n\nCiao,\nGiulio\n"}]}