|
32 | 32 | #include "advice.h"
|
33 | 33 | #include "branch.h"
|
34 | 34 | #include "list-objects-filter-options.h"
|
| 35 | +#include "wildmatch.h" |
| 36 | +#include "strbuf.h" |
35 | 37 |
|
36 | 38 | #define OPT_QUIET (1 << 0)
|
37 | 39 | #define OPT_CACHED (1 << 1)
|
@@ -3328,6 +3330,9 @@ static void configure_added_submodule(struct add_data *add_data)
|
3328 | 3330 | char *key;
|
3329 | 3331 | struct child_process add_submod = CHILD_PROCESS_INIT;
|
3330 | 3332 | struct child_process add_gitmodules = CHILD_PROCESS_INIT;
|
| 3333 | + const struct string_list *values; |
| 3334 | + size_t i; |
| 3335 | + int matched = 0; |
3331 | 3336 |
|
3332 | 3337 | key = xstrfmt("submodule.%s.url", add_data->sm_name);
|
3333 | 3338 | git_config_set_gently(key, add_data->realrepo);
|
@@ -3370,20 +3375,25 @@ static void configure_added_submodule(struct add_data *add_data)
|
3370 | 3375 | * is_submodule_active(), since that function needs to find
|
3371 | 3376 | * out the value of "submodule.active" again anyway.
|
3372 | 3377 | */
|
3373 |
| - if (!git_config_get("submodule.active")) { |
3374 |
| - /* |
3375 |
| - * If the submodule being added isn't already covered by the |
3376 |
| - * current configured pathspec, set the submodule's active flag |
3377 |
| - */ |
3378 |
| - if (!is_submodule_active(the_repository, add_data->sm_path)) { |
3379 |
| - key = xstrfmt("submodule.%s.active", add_data->sm_name); |
3380 |
| - git_config_set_gently(key, "true"); |
3381 |
| - free(key); |
3382 |
| - } |
3383 |
| - } else { |
| 3378 | + if (git_config_get("submodule.active") || /* key absent */ |
| 3379 | + git_config_get_string_multi("submodule.active", &values)) { |
| 3380 | + /* submodule.active is missing -> force-enable */ |
3384 | 3381 | key = xstrfmt("submodule.%s.active", add_data->sm_name);
|
3385 | 3382 | git_config_set_gently(key, "true");
|
3386 | 3383 | free(key);
|
| 3384 | + } else { |
| 3385 | + for (i = 0; i < values->nr; i++) { |
| 3386 | + const char *pat = values->items[i].string; |
| 3387 | + if (!wildmatch(pat, add_data->sm_path, 0)) { /* match found */ |
| 3388 | + matched = 1; |
| 3389 | + break; |
| 3390 | + } |
| 3391 | + } |
| 3392 | + if (!matched) { /* no pattern matched -> force-enable */ |
| 3393 | + key = xstrfmt("submodule.%s.active", add_data->sm_name); |
| 3394 | + git_config_set_gently(key, "true"); |
| 3395 | + free(key); |
| 3396 | + } |
3387 | 3397 | }
|
3388 | 3398 | }
|
3389 | 3399 |
|
|
0 commit comments