@matheusbsbs / matheus-bagliano / commits / 1fb2550202
Fork 0

config: teach the fetch.recurseSubmodules option the 'on-demand' value

To enable the user to change the default behavior of "git fetch" and "git pull" regarding submodule recursion add the new "on-demand" value which has just been added to the "--recurse-submodules" command line option. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jens Lehmann committed Mar 6, 2011 at 23:11 UTC 1fb2550202d6f88d90121624c1fac0b81ff8c33f
3 files changed +36 -4
Documentation/config.txt
+7 -3
@@ -900,9 +900,13 @@ diff.wordRegex::
900 characters are *ignorable* whitespace.
901
902 fetch.recurseSubmodules::
903 - A boolean value which changes the behavior for fetch and pull, the
904 - default is to not recursively fetch populated submodules unless
905 - configured otherwise.
903 + This option can be either set to a boolean value or to 'on-demand'.
904 + Setting it to a boolean changes the behavior of fetch and pull to
905 + unconditionally recurse into submodules when set to true or to not
906 + recurse at all when set to false. When set to 'on-demand' (the default
907 + value), fetch and pull will only recurse into a populated submodule
908 + when its superproject retrieves a commit that updates the submodule's
909 + reference.
910
911 fetch.unpackLimit::
912 If the number of objects fetched over the git native
submodule.c
+1 -1
@@ -71,7 +71,7 @@ int submodule_config(const char *var, const char *value, void *cb)
71 if (!prefixcmp(var, "submodule."))
72 return parse_submodule_config_option(var, value);
73 else if (!strcmp(var, "fetch.recursesubmodules")) {
74 - config_fetch_recurse_submodules = git_config_bool(var, value);
74 + config_fetch_recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
75 return 0;
76 }
77 return 0;
t/t5526-fetch-submodules.sh
+28
@@ -372,4 +372,32 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul
372 test_cmp expect.err.file actual.err
373 '
374
375 +test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config" '
376 + (
377 + cd downstream &&
378 + git fetch --recurse-submodules
379 + ) &&
380 + add_upstream_commit &&
381 + git config --global fetch.recurseSubmodules false &&
382 + head1=$(git rev-parse --short HEAD) &&
383 + git add submodule &&
384 + git commit -m "new submodule" &&
385 + head2=$(git rev-parse --short HEAD) &&
386 + echo "From $pwd/." > expect.err.2 &&
387 + echo " $head1..$head2 master -> origin/master" >> expect.err.2
388 + head -2 expect.err >> expect.err.2 &&
389 + (
390 + cd downstream &&
391 + git config fetch.recurseSubmodules on-demand &&
392 + git fetch >../actual.out 2>../actual.err
393 + ) &&
394 + git config --global --unset fetch.recurseSubmodules &&
395 + (
396 + cd downstream &&
397 + git config --unset fetch.recurseSubmodules
398 + ) &&
399 + test_cmp expect.out.sub actual.out &&
400 + test_cmp expect.err.2 actual.err
401 +'
402 +
403 test_done