{"thread":{"id":"41538","subject":"[PATCH v4 1/3] t/lib-httpd: load mod_unixd","startedAt":"2016-02-26T19:18:46Z","lastAt":"2016-02-27T00:01:08Z","messageCount":8,"participants":["Jacob Keller","Stefan Beller","Jeff King"],"isPatch":true,"patchVersion":4,"patchTotal":3},"messages":[{"id":"279553","messageId":"1456514328-10153-1-git-send-email-jacob.e.keller@intel.com","threadId":"41538","inReplyTo":null,"subject":"[PATCH v4 1/3] t/lib-httpd: load mod_unixd","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-02-26T19:18:46Z","receivedAt":"2016-02-26T19:18:46Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Michael J Gruber <git@drmicha.warpmail.net>\n\nIn contrast to apache 2.2, apache 2.4 does not load mod_unixd in its\ndefault configuration (because there are choices). Thus, with the\ncurrent config, apache 2.4.10 will not be started and the httpd tests\nwill not run on distros with default apache config (RedHat type).\n\nEnable mod_unixd to make the httpd tests run. This does not affect\ndistros negatively which have that config already in their default\n(Debian type). httpd tests will run on these before and after this patch.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\nI am sending this version strictly from PU since I need it to pass the\nhttpd tests.\n\n t/lib-httpd/apache.conf | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf\nindex 7d15e6d44c83..f667e7ce2f33 100644\n--- a/t/lib-httpd/apache.conf\n+++ b/t/lib-httpd/apache.conf\n@@ -64,6 +64,9 @@ LockFile accept.lock\n <IfModule !mod_mpm_prefork.c>\n \tLoadModule mpm_prefork_module modules/mod_mpm_prefork.so\n </IfModule>\n+<IfModule !mod_unixd.c>\n+\tLoadModule unixd_module modules/mod_unixd.so\n+</IfModule>\n </IfVersion>\n \n PassEnv GIT_VALGRIND\n-- \n2.7.1.429.g45cd78e\n"},{"id":"279554","messageId":"1456514328-10153-2-git-send-email-jacob.e.keller@intel.com","threadId":"41538","inReplyTo":"1456514328-10153-1-git-send-email-jacob.e.keller@intel.com","subject":"[PATCH v4 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-02-26T19:18:47Z","receivedAt":"2016-02-26T19:18:47Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\ngit submodule--helper clone usage specified that paths come after the --\nas a sequence. However, the actual implementation does not, and requires\nonly a single path passed in via --path. In addition, argc was\nunchecked. (allowing arbitrary extra arguments that were silently\nignored).\n\nFix the usage description to match implementation. Add an argc check to\nenforce no extra arguments. Fix a bug in the argument passing in\ngit-submodule.sh which would pass --reference and --depth as empty\nstrings when they were unused, resulting in extra argc after parsing\noptions.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n builtin/submodule--helper.c | 5 ++++-\n git-submodule.sh            | 4 ++--\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex f4c3eff179b5..072d9bbd12a8 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \tconst char *const git_submodule_helper_usage[] = {\n \t\tN_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n \t\t   \"[--reference <repository>] [--name <name>] [--url <url>]\"\n-\t\t   \"[--depth <depth>] [--] [<path>...]\"),\n+\t\t   \"[--depth <depth>] [--path <path>]\"),\n \t\tNULL\n \t};\n \n \targc = parse_options(argc, argv, prefix, module_clone_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n+\tif (argc)\n+\t\tusage(*git_submodule_helper_usage);\n+\n \tstrbuf_addf(&sb, \"%s/modules/%s\", get_git_dir(), name);\n \tsm_gitdir = strbuf_detach(&sb, NULL);\n \ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 9bc5c5f94d1d..2dd29b3df0e6 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -347,7 +347,7 @@ Use -f if you really want to add it.\" >&2\n \t\t\t\techo \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n \t\t\tfi\n \t\tfi\n-\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" \"$reference\" \"$depth\" || exit\n+\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n \t\t(\n \t\t\tclear_local_git_env\n \t\t\tcd \"$sm_path\" &&\n@@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?\")\"\n \n \t\tif ! test -d \"$sm_path\"/.git && ! test -f \"$sm_path\"/.git\n \t\tthen\n-\t\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$prefix\" --path \"$sm_path\" --name \"$name\" --url \"$url\" \"$reference\" \"$depth\" || exit\n+\t\t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$prefix\" --path \"$sm_path\" --name \"$name\" --url \"$url\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n \t\t\tcloned_modules=\"$cloned_modules;$name\"\n \t\t\tsubsha1=\n \t\telse\n-- \n2.7.1.429.g45cd78e\n"},{"id":"279555","messageId":"1456514328-10153-3-git-send-email-jacob.e.keller@intel.com","threadId":"41538","inReplyTo":"1456514328-10153-1-git-send-email-jacob.e.keller@intel.com","subject":"[PATCH v4 3/3] git: submodule honor -c credential.* from command line","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2016-02-26T19:18:48Z","receivedAt":"2016-02-26T19:18:48Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nDue to the way that the git-submodule code works, it clears all local\ngit environment variables before entering submodules. This is normally\na good thing since we want to clear settings such as GIT_WORKTREE and\nother variables which would affect the operation of submodule commands.\nHowever, GIT_CONFIG_PARAMETERS is special, and we actually do want to\npreserve these settings. However, we do not want to preserve all\nconfiguration as many things should be left specific to the parent\nproject.\n\nAdd a git submodule--helper function, sanitize-config, which shall be\nused to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs\nexcept a small subset that are known to be safe and necessary.\n\nReplace all the calls to clear_local_git_env with a wrapped function\nthat filters GIT_CONFIG_PARAMETERS using the new helper and then\nrestores it to the filtered subset after clearing the rest of the\nenvironment.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n\nNotes:\n    - v2\n    * Clarify which paramaters are left after the sanitization, and don't seem to\n      indicate it is our goal to extend the list.\n    * add a comment in the submodule_config_ok function indicating the same\n    \n    - v3\n    * Remove extraneous comments\n    * add strbuf_release calls\n    * rename sanitize_local_git_env\n    * remove use of local\n    * add C equivalent of sanitize_config\n    * add a test for the credential passing\n    \n    - v4\n    * use argc check instead of empty options check\n    * fix brain-melting quotes in t7412-submodule--helper.sh\n\n builtin/submodule--helper.c  | 77 +++++++++++++++++++++++++++++++++++++++++++-\n git-submodule.sh             | 36 +++++++++++++--------\n t/t5550-http-fetch-dumb.sh   | 17 ++++++++++\n t/t7412-submodule--helper.sh | 27 ++++++++++++++++\n 4 files changed, 143 insertions(+), 14 deletions(-)\n create mode 100755 t/t7412-submodule--helper.sh\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 072d9bbd12a8..c6c0a3b06e27 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -124,6 +124,64 @@ static int module_name(int argc, const char **argv, const char *prefix)\n \n \treturn 0;\n }\n+\n+/*\n+ * Rules to sanitize configuration variables that are Ok to be passed into\n+ * submodule operations from the parent project using \"-c\". Should only\n+ * include keys which are both (a) safe and (b) necessary for proper\n+ * operation.\n+ */\n+static int submodule_config_ok(const char *var)\n+{\n+\tif (starts_with(var, \"credential.\"))\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n+static int sanitize_submodule_config(const char *var, const char *value, void *data)\n+{\n+\tstruct strbuf quoted = STRBUF_INIT;\n+\tstruct strbuf *out = data;\n+\n+\tif (submodule_config_ok(var)) {\n+\t\tif (out->len)\n+\t\t\tstrbuf_addch(out, ' ');\n+\n+\t\t/*\n+\t\t * The GIT_CONFIG_PARAMETERS parser is a bit picky and\n+\t\t * requires that each var=value pair be quoted as a single\n+\t\t * unit.\n+\t\t */\n+\t\tstrbuf_addstr(&quoted, var);\n+\t\tstrbuf_addch(&quoted, '=');\n+\t\tstrbuf_addstr(&quoted, value);\n+\n+\t\tsq_quote_buf(out, quoted.buf);\n+\t}\n+\n+\tstrbuf_release(&quoted);\n+\n+\treturn 0;\n+}\n+\n+static void prepare_submodule_repo_env(struct argv_array *out)\n+{\n+\tconst char * const *var;\n+\n+\tfor (var = local_repo_env; *var; var++) {\n+\t\tif (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {\n+\t\t\tstruct strbuf sanitized_config = STRBUF_INIT;\n+\t\t\tgit_config_from_parameters(sanitize_submodule_config,\n+\t\t\t\t\t\t   &sanitized_config);\n+\t\t\targv_array_pushf(out, \"%s=%s\", *var, sanitized_config.buf);\n+\t\t\tstrbuf_release(&sanitized_config);\n+\t\t} else {\n+\t\t\targv_array_push(out, *var);\n+\t\t}\n+\t}\n+\n+}\n+\n static int clone_submodule(const char *path, const char *gitdir, const char *url,\n \t\t\t   const char *depth, const char *reference, int quiet)\n {\n@@ -145,7 +203,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url\n \targv_array_push(&cp.args, path);\n \n \tcp.git_cmd = 1;\n-\tcp.env = local_repo_env;\n+\tprepare_submodule_repo_env(&cp.env_array);\n \tcp.no_stdin = 1;\n \n \treturn run_command(&cp);\n@@ -258,6 +316,22 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n+static int module_sanitize_config(int argc, const char **argv, const char *prefix)\n+{\n+\tstruct strbuf sanitized_config = STRBUF_INIT;\n+\n+\tif (argc > 1)\n+\t\tusage(_(\"git submodule--helper sanitize-config\"));\n+\n+\tgit_config_from_parameters(sanitize_submodule_config, &sanitized_config);\n+\tif (sanitized_config.len)\n+\t\tprintf(\"%s\\n\", sanitized_config.buf);\n+\n+\tstrbuf_release(&sanitized_config);\n+\n+\treturn 0;\n+}\n+\n struct cmd_struct {\n \tconst char *cmd;\n \tint (*fn)(int, const char **, const char *);\n@@ -267,6 +341,7 @@ static struct cmd_struct commands[] = {\n \t{\"list\", module_list},\n \t{\"name\", module_name},\n \t{\"clone\", module_clone},\n+\t{\"sanitize-config\", module_sanitize_config},\n };\n \n int cmd_submodule__helper(int argc, const char **argv, const char *prefix)\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2dd29b3df0e6..1f132b489b81 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -192,6 +192,16 @@ isnumber()\n \tn=$(($1 + 0)) 2>/dev/null && test \"$n\" = \"$1\"\n }\n \n+# Sanitize the local git environment for use within a submodule. We\n+# can't simply use clear_local_git_env since we want to preserve some\n+# of the settings from GIT_CONFIG_PARAMETERS.\n+sanitize_submodule_env()\n+{\n+\tsanitized_config=$(git submodule--helper sanitize-config)\n+\tclear_local_git_env\n+\tGIT_CONFIG_PARAMETERS=$sanitized_config\n+}\n+\n #\n # Add a new submodule to the working tree, .gitmodules and the index\n #\n@@ -349,7 +359,7 @@ Use -f if you really want to add it.\" >&2\n \t\tfi\n \t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n \t\t(\n-\t\t\tclear_local_git_env\n+\t\t\tsanitize_submodule_env\n \t\t\tcd \"$sm_path\" &&\n \t\t\t# ash fails to wordsplit ${branch:+-b \"$branch\"...}\n \t\t\tcase \"$branch\" in\n@@ -418,7 +428,7 @@ cmd_foreach()\n \t\t\tname=$(git submodule--helper name \"$sm_path\")\n \t\t\t(\n \t\t\t\tprefix=\"$prefix$sm_path/\"\n-\t\t\t\tclear_local_git_env\n+\t\t\t\tsanitize_submodule_env\n \t\t\t\tcd \"$sm_path\" &&\n \t\t\t\tsm_path=$(relative_path \"$sm_path\") &&\n \t\t\t\t# we make $path available to scripts ...\n@@ -713,7 +723,7 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tcloned_modules=\"$cloned_modules;$name\"\n \t\t\tsubsha1=\n \t\telse\n-\t\t\tsubsha1=$(clear_local_git_env; cd \"$sm_path\" &&\n+\t\t\tsubsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n \t\t\t\tgit rev-parse --verify HEAD) ||\n \t\t\tdie \"$(eval_gettext \"Unable to find current revision in submodule path '\\$displaypath'\")\"\n \t\tfi\n@@ -723,11 +733,11 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tif test -z \"$nofetch\"\n \t\t\tthen\n \t\t\t\t# Fetch remote before determining tracking $sha1\n-\t\t\t\t(clear_local_git_env; cd \"$sm_path\" && git-fetch) ||\n+\t\t\t\t(sanitize_submodule_env; cd \"$sm_path\" && git-fetch) ||\n \t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n \t\t\tfi\n-\t\t\tremote_name=$(clear_local_git_env; cd \"$sm_path\" && get_default_remote)\n-\t\t\tsha1=$(clear_local_git_env; cd \"$sm_path\" &&\n+\t\t\tremote_name=$(sanitize_submodule_env; cd \"$sm_path\" && get_default_remote)\n+\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n \t\t\t\tgit rev-parse --verify \"${remote_name}/${branch}\") ||\n \t\t\tdie \"$(eval_gettext \"Unable to find current ${remote_name}/${branch} revision in submodule path '\\$sm_path'\")\"\n \t\tfi\n@@ -745,7 +755,7 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tthen\n \t\t\t\t# Run fetch only if $sha1 isn't present or it\n \t\t\t\t# is not reachable from a ref.\n-\t\t\t\t(clear_local_git_env; cd \"$sm_path\" &&\n+\t\t\t\t(sanitize_submodule_env; cd \"$sm_path\" &&\n \t\t\t\t\t( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&\n \t\t\t\t\t test -z \"$rev\") || git-fetch)) ||\n \t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$displaypath'\")\"\n@@ -787,7 +797,7 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\t\tdie \"$(eval_gettext \"Invalid update mode '$update_module' for submodule '$name'\")\"\n \t\t\tesac\n \n-\t\t\tif (clear_local_git_env; cd \"$sm_path\" && $command \"$sha1\")\n+\t\t\tif (sanitize_submodule_env; cd \"$sm_path\" && $command \"$sha1\")\n \t\t\tthen\n \t\t\t\tsay \"$say_msg\"\n \t\t\telif test -n \"$must_die_on_failure\"\n@@ -803,7 +813,7 @@ Maybe you want to use 'update --init'?\")\"\n \t\tthen\n \t\t\t(\n \t\t\t\tprefix=\"$prefix$sm_path/\"\n-\t\t\t\tclear_local_git_env\n+\t\t\t\tsanitize_submodule_env\n \t\t\t\tcd \"$sm_path\" &&\n \t\t\t\teval cmd_update\n \t\t\t)\n@@ -841,7 +851,7 @@ Maybe you want to use 'update --init'?\")\"\n \n set_name_rev () {\n \trevname=$( (\n-\t\tclear_local_git_env\n+\t\tsanitize_submodule_env\n \t\tcd \"$1\" && {\n \t\t\tgit describe \"$2\" 2>/dev/null ||\n \t\t\tgit describe --tags \"$2\" 2>/dev/null ||\n@@ -1125,7 +1135,7 @@ cmd_status()\n \t\telse\n \t\t\tif test -z \"$cached\"\n \t\t\tthen\n-\t\t\t\tsha1=$(clear_local_git_env; cd \"$sm_path\" && git rev-parse --verify HEAD)\n+\t\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" && git rev-parse --verify HEAD)\n \t\t\tfi\n \t\t\tset_name_rev \"$sm_path\" \"$sha1\"\n \t\t\tsay \"+$sha1 $displaypath$revname\"\n@@ -1135,7 +1145,7 @@ cmd_status()\n \t\tthen\n \t\t\t(\n \t\t\t\tprefix=\"$displaypath/\"\n-\t\t\t\tclear_local_git_env\n+\t\t\t\tsanitize_submodule_env\n \t\t\t\tcd \"$sm_path\" &&\n \t\t\t\teval cmd_status\n \t\t\t) ||\n@@ -1209,7 +1219,7 @@ cmd_sync()\n \t\t\tif test -e \"$sm_path\"/.git\n \t\t\tthen\n \t\t\t(\n-\t\t\t\tclear_local_git_env\n+\t\t\t\tsanitize_submodule_env\n \t\t\t\tcd \"$sm_path\"\n \t\t\t\tremote=$(get_default_remote)\n \t\t\t\tgit config remote.\"$remote\".url \"$sub_origin_url\"\ndiff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh\nindex 64146352ae20..48e2ab62da7a 100755\n--- a/t/t5550-http-fetch-dumb.sh\n+++ b/t/t5550-http-fetch-dumb.sh\n@@ -91,6 +91,23 @@ test_expect_success 'configured username does not override URL' '\n \texpect_askpass pass user@host\n '\n \n+test_expect_success 'cmdline credential config passes into submodules' '\n+\tgit init super &&\n+\tset_askpass user@host pass@host &&\n+\t(\n+\t\tcd super &&\n+\t\tgit submodule add \"$HTTPD_URL/auth/dumb/repo.git\" sub &&\n+\t\tgit commit -m \"add submodule\"\n+\t) &&\n+\tset_askpass wrong pass@host &&\n+\ttest_must_fail git clone --recursive super super-clone &&\n+\trm -rf super-clone &&\n+\tset_askpass wrong pass@host &&\n+\tgit -c \"credential.$HTTP_URL.username=user@host\" \\\n+\t\tclone --recursive super super-clone &&\n+\texpect_askpass pass user@host\n+'\n+\n test_expect_success 'fetch changes via http' '\n \techo content >>file &&\n \tgit commit -a -m two &&\ndiff --git a/t/t7412-submodule--helper.sh b/t/t7412-submodule--helper.sh\nnew file mode 100755\nindex 000000000000..9d937de8b224\n--- /dev/null\n+++ b/t/t7412-submodule--helper.sh\n@@ -0,0 +1,27 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2016 Jacob Keller\n+#\n+\n+test_description='Basic plumbing support of submodule--helper\n+\n+This test verifies the submodule--helper plumbing command used to implement\n+git-submodule.\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'sanitize-config clears configuration' '\n+\tgit -c user.name=\"Some User\" submodule--helper sanitize-config >actual &&\n+\ttest_must_be_empty actual\n+'\n+\n+test_expect_success 'sanitize-config keeps credential.helper' \"\n+\tgit -c credential.helper=helper submodule--helper sanitize-config >actual &&\n+\tcat >expect <<-EOF &&\n+\t'credential.helper=helper'\n+\tEOF\n+\ttest_cmp expect actual\n+\"\n+\n+test_done\n-- \n2.7.1.429.g45cd78e\n"},{"id":"279556","messageId":"CAGZ79kbD7_CYo9KT185oTxrjqch-otwfG0mWqAV2QiwrC-ch9Q@mail.gmail.com","threadId":"41538","inReplyTo":"1456514328-10153-2-git-send-email-jacob.e.keller@intel.com","subject":"Re: [PATCH v4 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-02-26T19:31:06Z","receivedAt":"2016-02-26T19:31:06Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Feb 26, 2016 at 11:18 AM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n> From: Jacob Keller <jacob.keller@gmail.com>\n>\n> git submodule--helper clone usage specified that paths come after the --\n> as a sequence. However, the actual implementation does not, and requires\n> only a single path passed in via --path. In addition, argc was\n> unchecked. (allowing arbitrary extra arguments that were silently\n> ignored).\n>\n> Fix the usage description to match implementation. Add an argc check to\n> enforce no extra arguments. Fix a bug in the argument passing in\n> git-submodule.sh which would pass --reference and --depth as empty\n> strings when they were unused, resulting in extra argc after parsing\n> options.\n>\n> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> ---\n>  builtin/submodule--helper.c | 5 ++++-\n>  git-submodule.sh            | 4 ++--\n>  2 files changed, 6 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index f4c3eff179b5..072d9bbd12a8 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>         const char *const git_submodule_helper_usage[] = {\n>                 N_(\"git submodule--helper clone [--prefix=<path>] [--quiet] \"\n>                    \"[--reference <repository>] [--name <name>] [--url <url>]\"\n> -                  \"[--depth <depth>] [--] [<path>...]\"),\n> +                  \"[--depth <depth>] [--path <path>]\"),\n\nRight, no extra arguments.\n\n>                 NULL\n>         };\n>\n>         argc = parse_options(argc, argv, prefix, module_clone_options,\n>                              git_submodule_helper_usage, 0);\n>\n> +       if (argc)\n> +               usage(*git_submodule_helper_usage);\n> +\n\nThis is the fix to check for more arguments.\n\n>         strbuf_addf(&sb, \"%s/modules/%s\", get_git_dir(), name);\n>         sm_gitdir = strbuf_detach(&sb, NULL);\n>\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 9bc5c5f94d1d..2dd29b3df0e6 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -347,7 +347,7 @@ Use -f if you really want to add it.\" >&2\n>                                 echo \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n>                         fi\n>                 fi\n> -               git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" \"$reference\" \"$depth\" || exit\n> +               git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n\nBy having this additional fix (i.e. no '--depth', '<empty string>' is\npassed to the\nsubmodule helper, we can improve the submodule helper further\nin clone_submodule we can drop the double check for `depth` and `reference`\n(as well as `gitdir`, that double check is unneeded as of now already),\nby just checking for the pointer to be non  NULL and not further checking\nthe dereferenced pointer.\n\nThat can go in either squashed into this commit or on top of it, either is fine.\n\nThat said:\nReviewed-by: Stefan Beller <sbeller@google.com>\n\n\n>                 (\n>                         clear_local_git_env\n>                         cd \"$sm_path\" &&\n> @@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?\")\"\n>\n>                 if ! test -d \"$sm_path\"/.git && ! test -f \"$sm_path\"/.git\n>                 then\n> -                       git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$prefix\" --path \"$sm_path\" --name \"$name\" --url \"$url\" \"$reference\" \"$depth\" || exit\n> +                       git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$prefix\" --path \"$sm_path\" --name \"$name\" --url \"$url\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n>                         cloned_modules=\"$cloned_modules;$name\"\n>                         subsha1=\n>                 else\n> --\n> 2.7.1.429.g45cd78e\n>\n"},{"id":"279570","messageId":"20160226220553.GA1835@sigill.intra.peff.net","threadId":"41538","inReplyTo":"1456514328-10153-3-git-send-email-jacob.e.keller@intel.com","subject":"Re: [PATCH v4 3/3] git: submodule honor -c credential.* from command line","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-02-26T22:05:54Z","receivedAt":"2016-02-26T22:05:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 26, 2016 at 11:18:48AM -0800, Jacob Keller wrote:\n\n> +test_expect_success 'sanitize-config keeps credential.helper' \"\n> +\tgit -c credential.helper=helper submodule--helper sanitize-config >actual &&\n> +\tcat >expect <<-EOF &&\n> +\t'credential.helper=helper'\n> +\tEOF\n> +\ttest_cmp expect actual\n> +\"\n\nThis can (and should) be \"<<-\\EOF\", right?\n\nI happened to be writing a test with the exact same problem (embedded\nsingle-quotes) today, and realized we have another solution which is\nused elsewhere in the test suite:\n\n  sq=\"'\"\n  test_expect_success '...' '\n\techo \"${sq}credential.helper=helper${sq}\" >expect &&\n\t...\n  '\n\nthat is slightly more verbose, but it does let us keep the main body\ninside single-quotes, without restoring to confusing backslash escaping.\n\n-Peff\n"},{"id":"279571","messageId":"CA+P7+xq8T8BsjfH9hrwULZiyTutt+6-qxqBZbZFHk490my_ofQ@mail.gmail.com","threadId":"41538","inReplyTo":"CAGZ79kbD7_CYo9KT185oTxrjqch-otwfG0mWqAV2QiwrC-ch9Q@mail.gmail.com","subject":"Re: [PATCH v4 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-02-26T22:08:17Z","receivedAt":"2016-02-26T22:08:17Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Feb 26, 2016 at 11:31 AM, Stefan Beller <sbeller@google.com> wrote:\n> On Fri, Feb 26, 2016 at 11:18 AM, Jacob Keller <jacob.e.keller@intel.com> wrote:\n>> From: Jacob Keller <jacob.keller@gmail.com>\n>> -               git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" \"$reference\" \"$depth\" || exit\n>> +               git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" ${reference:+\"$reference\"} ${depth:+\"$depth\"} || exit\n>\n> By having this additional fix (i.e. no '--depth', '<empty string>' is\n> passed to the\n> submodule helper, we can improve the submodule helper further\n> in clone_submodule we can drop the double check for `depth` and `reference`\n> (as well as `gitdir`, that double check is unneeded as of now already),\n> by just checking for the pointer to be non  NULL and not further checking\n> the dereferenced pointer.\n>\n> That can go in either squashed into this commit or on top of it, either is fine.\n>\n> That said:\n> Reviewed-by: Stefan Beller <sbeller@google.com>\n>\n\nTo be clear, what this *actually* does is prevent passing\n\n\"\"\n\nwhen depth or reference are empty. It never passed \"--depth\" \"\"\ntogether, or \"--reference\" \"\". It *does* pass --prefix \"\" sometimes,\nbut not always, from what I could tell when using print debug\nstatements while running the submodule tests.\n\nI am not sure if it ever passes \"--depth\" \"\" in any case, but I don't\nbelieve so.\n\nWhat this final change is needed for is that without it, after\nparse_options, argc is equal 2.\n\nThanks,\nJake\n"},{"id":"279573","messageId":"CA+P7+xqSZGAJD7ryvx2A2qM1wd0rKMmjT2tcBPann33sUUHGcA@mail.gmail.com","threadId":"41538","inReplyTo":"20160226220553.GA1835@sigill.intra.peff.net","subject":"Re: [PATCH v4 3/3] git: submodule honor -c credential.* from command line","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-02-26T22:20:34Z","receivedAt":"2016-02-26T22:20:34Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Feb 26, 2016 at 2:05 PM, Jeff King <peff@peff.net> wrote:\n> On Fri, Feb 26, 2016 at 11:18:48AM -0800, Jacob Keller wrote:\n>\n>> +test_expect_success 'sanitize-config keeps credential.helper' \"\n>> +     git -c credential.helper=helper submodule--helper sanitize-config >actual &&\n>> +     cat >expect <<-EOF &&\n>> +     'credential.helper=helper'\n>> +     EOF\n>> +     test_cmp expect actual\n>> +\"\n>\n> This can (and should) be \"<<-\\EOF\", right?\n>\n\nYes, I actually meant <<-\\EOF but forgot while writing it.\n\n> I happened to be writing a test with the exact same problem (embedded\n> single-quotes) today, and realized we have another solution which is\n> used elsewhere in the test suite:\n>\n>   sq=\"'\"\n>   test_expect_success '...' '\n>         echo \"${sq}credential.helper=helper${sq}\" >expect &&\n>         ...\n>   '\n>\n> that is slightly more verbose, but it does let us keep the main body\n> inside single-quotes, without restoring to confusing backslash escaping.\n>\n\nI think I prefer the double quotes myself but will use this if people prefer?\n\n> -Peff\n"},{"id":"279589","messageId":"CA+P7+xroP8PFKe+zSdT-j9oq+APT6OKOkbzS_DM8HyVjM-v_og@mail.gmail.com","threadId":"41538","inReplyTo":"CA+P7+xqSZGAJD7ryvx2A2qM1wd0rKMmjT2tcBPann33sUUHGcA@mail.gmail.com","subject":"Re: [PATCH v4 3/3] git: submodule honor -c credential.* from command line","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-02-27T00:01:08Z","receivedAt":"2016-02-27T00:01:08Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Feb 26, 2016 at 2:20 PM, Jacob Keller <jacob.keller@gmail.com> wrote:\n>> that is slightly more verbose, but it does let us keep the main body\n>> inside single-quotes, without restoring to confusing backslash escaping.\n>>\n>\n> I think I prefer the double quotes myself but will use this if people prefer?\n>\n>> -Peff\n\nOn second thought, I'd prefer consistency and I think using single\nquotes is probably better, so I'll use this solution in v5.\n\nThanks,\nJake\n"}]}