Skip to content

Commit 43dc540

Browse files
peffdscho
authored andcommitted
submodule: stop sanitizing config options
The point of having a whitelist of command-line config options to pass to submodules was two-fold: 1. It prevented obvious nonsense like using core.worktree for multiple repos. 2. It could prevent surprise when the user did not mean for the options to leak to the submodules (e.g., http.sslverify=false). For case 1, the answer is mostly "if it hurts, don't do that". For case 2, we can note that any such example has a matching inverted surprise (e.g., a user who meant http.sslverify=true to apply everywhere, but it didn't). So this whitelist is probably not giving us any benefit, and is already creating a hassle as people propose things to put on it. Let's just drop it entirely. Note that we still need to keep a special code path for "prepare the submodule environment", because we still have to take care to pass through $GIT_CONFIG_PARAMETERS (and block the rest of the repo-specific environment variables). We can do this easily from within the submodule shell script, which lets us drop the submodule--helper option entirely (and it's OK to do so because as a "--" program, it is entirely a private implementation detail). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent feaf144 commit 43dc540

File tree

5 files changed

+4
-93
lines changed

5 files changed

+4
-93
lines changed

builtin/submodule--helper.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,6 @@ static int module_clone(int argc, const char **argv, const char *prefix)
249249
return 0;
250250
}
251251

252-
static int module_sanitize_config(int argc, const char **argv, const char *prefix)
253-
{
254-
struct strbuf sanitized_config = STRBUF_INIT;
255-
256-
if (argc > 1)
257-
usage(_("git submodule--helper sanitize-config"));
258-
259-
git_config_from_parameters(sanitize_submodule_config, &sanitized_config);
260-
if (sanitized_config.len)
261-
printf("%s\n", sanitized_config.buf);
262-
263-
strbuf_release(&sanitized_config);
264-
265-
return 0;
266-
}
267-
268252
struct cmd_struct {
269253
const char *cmd;
270254
int (*fn)(int, const char **, const char *);
@@ -274,7 +258,6 @@ static struct cmd_struct commands[] = {
274258
{"list", module_list},
275259
{"name", module_name},
276260
{"clone", module_clone},
277-
{"sanitize-config", module_sanitize_config},
278261
};
279262

280263
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)

git-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ isnumber()
197197
# of the settings from GIT_CONFIG_PARAMETERS.
198198
sanitize_submodule_env()
199199
{
200-
sanitized_config=$(git submodule--helper sanitize-config)
200+
save_config=$GIT_CONFIG_PARAMETERS
201201
clear_local_git_env
202-
GIT_CONFIG_PARAMETERS=$sanitized_config
202+
GIT_CONFIG_PARAMETERS=$save_config
203203
export GIT_CONFIG_PARAMETERS
204204
}
205205

submodule.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,50 +1095,13 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
10951095
strbuf_release(&rel_path);
10961096
free((void *)real_work_tree);
10971097
}
1098-
/*
1099-
* Rules to sanitize configuration variables that are Ok to be passed into
1100-
* submodule operations from the parent project using "-c". Should only
1101-
* include keys which are both (a) safe and (b) necessary for proper
1102-
* operation.
1103-
*/
1104-
static int submodule_config_ok(const char *var)
1105-
{
1106-
if (starts_with(var, "credential."))
1107-
return 1;
1108-
return 0;
1109-
}
1110-
1111-
int sanitize_submodule_config(const char *var, const char *value, void *data)
1112-
{
1113-
struct strbuf *out = data;
1114-
1115-
if (submodule_config_ok(var)) {
1116-
if (out->len)
1117-
strbuf_addch(out, ' ');
1118-
1119-
if (value)
1120-
sq_quotef(out, "%s=%s", var, value);
1121-
else
1122-
sq_quote_buf(out, var);
1123-
}
1124-
1125-
return 0;
1126-
}
11271098

11281099
void prepare_submodule_repo_env(struct argv_array *out)
11291100
{
11301101
const char * const *var;
11311102

11321103
for (var = local_repo_env; *var; var++) {
1133-
if (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {
1134-
struct strbuf sanitized_config = STRBUF_INIT;
1135-
git_config_from_parameters(sanitize_submodule_config,
1136-
&sanitized_config);
1137-
argv_array_pushf(out, "%s=%s", *var, sanitized_config.buf);
1138-
strbuf_release(&sanitized_config);
1139-
} else {
1104+
if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
11401105
argv_array_push(out, *var);
1141-
}
11421106
}
1143-
11441107
}

submodule.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,10 @@ int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_nam
4343
int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
4444
void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
4545

46-
/*
47-
* This function is intended as a callback for use with
48-
* git_config_from_parameters(). It ignores any config options which
49-
* are not suitable for passing along to a submodule, and accumulates the rest
50-
* in "data", which must be a pointer to a strbuf. The end result can
51-
* be put into $GIT_CONFIG_PARAMETERS for passing to a sub-process.
52-
*/
53-
int sanitize_submodule_config(const char *var, const char *value, void *data);
54-
5546
/*
5647
* Prepare the "env_array" parameter of a "struct child_process" for executing
5748
* a submodule by clearing any repo-specific envirionment variables, but
58-
* retaining any config approved by sanitize_submodule_config().
49+
* retaining any config in the environment.
5950
*/
6051
void prepare_submodule_repo_env(struct argv_array *out);
6152

t/t7412-submodule--helper.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)