builtin/push.c: respect 'submodule.recurse' option
authorStefan Beller <sbeller@google.com>
Thu, 1 Jun 2017 00:30:49 +0000 (17:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Jun 2017 01:36:36 +0000 (10:36 +0900)
The closest mapping from the boolean 'submodule.recurse' set to "yes"
to the variety of submodule push modes is "on-demand", so implement that.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c
t/t5531-deep-submodule-push.sh
index a597759d8fac205f41c406d0a0e32f9240941190..258648d5fd685f4284b3a2bbc0def0076a670b28 100644 (file)
@@ -498,6 +498,10 @@ static int git_push_config(const char *k, const char *v, void *cb)
                const char *value;
                if (!git_config_get_value("push.recursesubmodules", &value))
                        recurse_submodules = parse_push_recurse_submodules_arg(k, value);
+       } else if (!strcmp(k, "submodule.recurse")) {
+               int val = git_config_bool(k, v) ?
+                       RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF;
+               recurse_submodules = val;
        }
 
        return git_default_config(k, v, NULL);
index 57ba3226288cadbbe8af569d13217f5b2c17af90..712c595fd83a32df11ef92cf86684dd14e2e6e5a 100755 (executable)
@@ -126,6 +126,27 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
        )
 '
 
+test_expect_success 'push succeeds if submodule commit not on remote but using auto-on-demand via submodule.recurse config' '
+       (
+               cd work/gar/bage &&
+               >recurse-on-demand-from-submodule-recurse-config &&
+               git add recurse-on-demand-from-submodule-recurse-config &&
+               git commit -m "Recurse submodule.recurse from config junk"
+       ) &&
+       (
+               cd work &&
+               git add gar/bage &&
+               git commit -m "Recurse submodule.recurse from config for gar/bage" &&
+               git -c submodule.recurse push ../pub.git master &&
+               # Check that the supermodule commit got there
+               git fetch ../pub.git &&
+               git diff --quiet FETCH_HEAD master &&
+               # Check that the submodule commit got there too
+               cd gar/bage &&
+               git diff --quiet origin/master master
+       )
+'
+
 test_expect_success 'push recurse-submodules on command line overrides config' '
        (
                cd work/gar/bage &&