i18n: git-add "The following paths are ignored" message
[gitweb.git] / submodule.c
index 4d9b774cd107b5e9225c28620d2a2dc9efb665cc..6f1c10722f744f4a27f18dae4867b15ecbf57d49 100644 (file)
@@ -10,7 +10,9 @@
 #include "string-list.h"
 
 struct string_list config_name_for_path;
+struct string_list config_fetch_recurse_submodules_for_name;
 struct string_list config_ignore_for_name;
+static int config_fetch_recurse_submodules;
 
 static int add_submodule_odb(const char *path)
 {
@@ -67,6 +69,10 @@ int submodule_config(const char *var, const char *value, void *cb)
 {
        if (!prefixcmp(var, "submodule."))
                return parse_submodule_config_option(var, value);
+       else if (!strcmp(var, "fetch.recursesubmodules")) {
+               config_fetch_recurse_submodules = git_config_bool(var, value);
+               return 0;
+       }
        return 0;
 }
 
@@ -100,6 +106,14 @@ int parse_submodule_config_option(const char *var, const char *value)
                        config = string_list_append(&config_name_for_path, xstrdup(value));
                config->util = strbuf_detach(&submodname, NULL);
                strbuf_release(&submodname);
+       } else if ((len > 23) && !strcmp(var + len - 23, ".fetchrecursesubmodules")) {
+               strbuf_add(&submodname, var, len - 23);
+               config = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, submodname.buf);
+               if (!config)
+                       config = string_list_append(&config_fetch_recurse_submodules_for_name,
+                                                   strbuf_detach(&submodname, NULL));
+               config->util = git_config_bool(var, value) ? (void *)1 : NULL;
+               strbuf_release(&submodname);
        } else if ((len > 7) && !strcmp(var + len - 7, ".ignore")) {
                if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
                    strcmp(value, "all") && strcmp(value, "none")) {
@@ -229,8 +243,14 @@ void show_submodule_summary(FILE *f, const char *path,
        strbuf_release(&sb);
 }
 
+void set_config_fetch_recurse_submodules(int value)
+{
+       config_fetch_recurse_submodules = value;
+}
+
 int fetch_populated_submodules(int num_options, const char **options,
-                              const char *prefix, int quiet)
+                              const char *prefix, int ignore_config,
+                              int quiet)
 {
        int i, result = 0, argc = 0;
        struct child_process cp;
@@ -244,7 +264,8 @@ int fetch_populated_submodules(int num_options, const char **options,
                if (read_cache() < 0)
                        die("index file corrupt");
 
-       argv = xcalloc(num_options + 5, sizeof(const char *));
+       /* 4: "fetch" (options) "--submodule-prefix" prefix NULL */
+       argv = xcalloc(num_options + 4, sizeof(const char *));
        argv[argc++] = "fetch";
        for (i = 0; i < num_options; i++)
                argv[argc++] = options[i];
@@ -271,6 +292,18 @@ int fetch_populated_submodules(int num_options, const char **options,
                if (name_for_path)
                        name = name_for_path->util;
 
+               if (!ignore_config) {
+                       struct string_list_item *fetch_recurse_submodules_option;
+                       fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
+                       if (fetch_recurse_submodules_option) {
+                               if (!fetch_recurse_submodules_option->util)
+                                       continue;
+                       } else {
+                               if (!config_fetch_recurse_submodules)
+                                       continue;
+                       }
+               }
+
                strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
                strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf);
                strbuf_addf(&submodule_prefix, "%s%s/", prefix, ce->name);