sequences that match the regular expression are "words", all other
characters are *ignorable* whitespace.
+fetch.recurseSubmodules::
+ A boolean value which changes the behavior for fetch and pull, the
+ default is to not recursively fetch populated sumodules unless
+ configured otherwise.
+
fetch.unpackLimit::
If the number of objects fetched over the git native
transfer is below this
flag lets all tags and their associated objects be
downloaded.
---recurse-submodules::
- Use this option to fetch new commits of all populated submodules too.
+--[no-]recurse-submodules::
+ This option controls if new commits of all populated submodules should
+ be fetched too (see linkgit:git-config[1]).
ifndef::git-pull[]
--submodule-prefix=<path>::
TAGS_SET = 2
};
+enum {
+ RECURSE_SUBMODULES_OFF = 0,
+ RECURSE_SUBMODULES_DEFAULT = 1,
+ RECURSE_SUBMODULES_ON = 2
+};
+
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
-static int progress, recurse_submodules;
+static int progress, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int tags = TAGS_DEFAULT;
static const char *depth;
static const char *upload_pack;
"do not fetch all tags (--no-tags)", TAGS_UNSET),
OPT_BOOLEAN('p', "prune", &prune,
"prune tracking branches no longer on remote"),
- OPT_BOOLEAN(0, "recurse-submodules", &recurse_submodules,
- "control recursive fetching of submodules"),
+ OPT_SET_INT(0, "recurse-submodules", &recurse_submodules,
+ "control recursive fetching of submodules",
+ RECURSE_SUBMODULES_ON),
OPT_BOOLEAN(0, "dry-run", &dry_run,
"dry run"),
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
argv[(*argc)++] = "--force";
if (keep)
argv[(*argc)++] = "--keep";
- if (recurse_submodules)
+ if (recurse_submodules == RECURSE_SUBMODULES_ON)
argv[(*argc)++] = "--recurse-submodules";
if (verbosity >= 2)
argv[(*argc)++] = "-v";
}
}
- if (!result && recurse_submodules) {
+ if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
const char *options[10];
int num_options = 0;
+ /* Set recursion as default when we already are recursing */
+ if (submodule_prefix[0])
+ set_config_fetch_recurse_submodules(1);
gitmodules_config();
git_config(submodule_config, NULL);
add_options_to_argv(&num_options, options);
result = fetch_populated_submodules(num_options, options,
submodule_prefix,
+ recurse_submodules == RECURSE_SUBMODULES_ON,
verbosity < 0);
}
--recurse-submodules)
recurse_submodules=--recurse-submodules
;;
+ --no-recurse-submodules)
+ recurse_submodules=--no-recurse-submodules
+ ;;
--d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
dry_run=--dry-run
;;
struct string_list config_name_for_path;
struct string_list config_ignore_for_name;
+static int config_fetch_recurse_submodules;
static int add_submodule_odb(const char *path)
{
{
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;
}
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;
if (name_for_path)
name = name_for_path->util;
+ if (!ignore_config) {
+ 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);
unsigned char one[20], unsigned char two[20],
unsigned dirty_submodule,
const char *del, const char *add, const char *reset);
+void set_config_fetch_recurse_submodules(int value);
int fetch_populated_submodules(int num_options, const char **options,
- const char *prefix, int quiet);
+ const char *prefix, int ignore_config,
+ int quiet);
unsigned is_submodule_modified(const char *path, int ignore_untracked);
int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
const unsigned char a[20], const unsigned char b[20]);
test_cmp expect.err actual.err
'
+test_expect_success "recurseSubmodules=true propagates into submodules" '
+ add_upstream_commit &&
+ (
+ cd downstream &&
+ git config fetch.recurseSubmodules true
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ test_cmp expect.out actual.out &&
+ test_cmp expect.err actual.err
+'
+
+test_expect_success "--recurse-submodules overrides config in submodule" '
+ add_upstream_commit &&
+ (
+ cd downstream &&
+ (
+ cd submodule &&
+ git config fetch.recurseSubmodules false
+ ) &&
+ git fetch --recurse-submodules >../actual.out 2>../actual.err
+ ) &&
+ test_cmp expect.out actual.out &&
+ test_cmp expect.err actual.err
+'
+
+test_expect_success "--no-recurse-submodules overrides config setting" '
+ add_upstream_commit &&
+ (
+ cd downstream &&
+ git config fetch.recurseSubmodules true
+ git fetch --no-recurse-submodules >../actual.out 2>../actual.err
+ ) &&
+ ! test -s actual.out &&
+ ! test -s actual.err
+'
+
test_done