12
#include "parse-options.h"
13
#include "sigchain.h"
14
#include "transport.h"
15
+#include "submodule.h"
16
17
static const char * const builtin_fetch_usage[] = {
18
"git fetch [<options>] [<repository> [<refspec>...]]",
29
};
30
31
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
31
-static int progress;
32
+static int progress, recurse_submodules;
33
static int tags = TAGS_DEFAULT;
34
static const char *depth;
35
static const char *upload_pack;
36
static struct strbuf default_rla = STRBUF_INIT;
37
static struct transport *transport;
38
+static const char *submodule_prefix = "";
39
40
static struct option builtin_fetch_options[] = {
41
OPT__VERBOSITY(&verbosity),
55
"do not fetch all tags (--no-tags)", TAGS_UNSET),
56
OPT_BOOLEAN('p', "prune", &prune,
57
"prune tracking branches no longer on remote"),
58
+ OPT_BOOLEAN(0, "recurse-submodules", &recurse_submodules,
59
+ "control recursive fetching of submodules"),
60
OPT_BOOLEAN(0, "dry-run", &dry_run,
61
"dry run"),
62
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
65
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
66
OPT_STRING(0, "depth", &depth, "DEPTH",
67
"deepen history of shallow clone"),
68
+ { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "DIR",
69
+ "prepend this to submodule path output", PARSE_OPT_HIDDEN },
70
OPT_END()
71
};
72
783
return 1;
784
}
785
780
-static int fetch_multiple(struct string_list *list)
786
+static void add_options_to_argv(int *argc, const char **argv)
787
{
782
- int i, result = 0;
783
- const char *argv[11] = { "fetch", "--append" };
784
- int argc = 2;
785
-
788
if (dry_run)
787
- argv[argc++] = "--dry-run";
789
+ argv[(*argc)++] = "--dry-run";
790
if (prune)
789
- argv[argc++] = "--prune";
791
+ argv[(*argc)++] = "--prune";
792
if (update_head_ok)
791
- argv[argc++] = "--update-head-ok";
793
+ argv[(*argc)++] = "--update-head-ok";
794
if (force)
793
- argv[argc++] = "--force";
795
+ argv[(*argc)++] = "--force";
796
if (keep)
795
- argv[argc++] = "--keep";
797
+ argv[(*argc)++] = "--keep";
798
+ if (recurse_submodules)
799
+ argv[(*argc)++] = "--recurse-submodules";
800
if (verbosity >= 2)
797
- argv[argc++] = "-v";
801
+ argv[(*argc)++] = "-v";
802
if (verbosity >= 1)
799
- argv[argc++] = "-v";
803
+ argv[(*argc)++] = "-v";
804
else if (verbosity < 0)
801
- argv[argc++] = "-q";
805
+ argv[(*argc)++] = "-q";
806
+
807
+}
808
+
809
+static int fetch_multiple(struct string_list *list)
810
+{
811
+ int i, result = 0;
812
+ const char *argv[12] = { "fetch", "--append" };
813
+ int argc = 2;
814
+
815
+ add_options_to_argv(&argc, argv);
816
817
if (!append && !dry_run) {
818
int errcode = truncate_fetch_head();
933
}
934
}
935
936
+ if (!result && recurse_submodules) {
937
+ const char *options[10];
938
+ int num_options = 0;
939
+ gitmodules_config();
940
+ git_config(submodule_config, NULL);
941
+ add_options_to_argv(&num_options, options);
942
+ result = fetch_populated_submodules(num_options, options,
943
+ submodule_prefix,
944
+ verbosity < 0);
945
+ }
946
+
947
/* All names were strdup()ed or strndup()ed */
948
list.strdup_strings = 1;
949
string_list_clear(&list, 0);