On Mon, Nov 16, 2015 at 8:24 AM, Mike Crowe <mac@xxxxxxxxxx> wrote: > The --recurse-submodules command line parameter has existed for some > time but it has no config file equivalent. > > Following the style of the corresponding parameter for git fetch, let's > invent push.recurseSubmodules to provide a default for this > parameter. This also requires the addition of --recurse-submodules=no to > allow the configuration to be overridden on the command line when > required. > > The most straightforward way to implement this appears to be to make > push use code in submodule-config in a similar way to fetch. > > Signed-off-by: Mike Crowe <mac@xxxxxxxxxx> > --- > diff --git a/Documentation/config.txt b/Documentation/config.txt > @@ -2226,6 +2226,19 @@ push.gpgSign:: > +push.recurseSubmodules:: > + Make sure all submodule commits used by the revisions to be pushed > + are available on a remote-tracking branch. If the value is 'check' > + then Git will verify that all submodule commits that changed in the > + revisions to be pushed are available on at least one remote of the > + submodule. If any commits are missing the push will be aborted and > + exit with non-zero status. If the value is 'on-demand' then all > + submodules that changed in the revisions to be pushed will be > + pushed. If on-demand was not able to push all necessary revisions > + it will also be aborted and exit with non-zero status. You may > + override this configuration at time of push by specifying > + '--recurse-submodules=check|on-demand|no'. Does this configuration variable also support 'no' as a value? If so, then it probably ought to be documented. If not, shouldn't it do so to allow a configuration file to override a 'check' or 'on-demand' value specified in a more global git configuration file? > rebase.stat:: > Whether to show a diffstat of what changed upstream since the last > rebase. False by default. > diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt > @@ -257,7 +257,7 @@ origin +master` to force a push to the `master` branch). See the > ---recurse-submodules=check|on-demand:: > +--recurse-submodules=check|on-demand|no:: > Make sure all submodule commits used by the revisions to be > pushed are available on a remote-tracking branch. If 'check' is > used Git will verify that all submodule commits that changed in > @@ -267,6 +267,8 @@ origin +master` to force a push to the `master` branch). See the > all submodules that changed in the revisions to be pushed will > be pushed. If on-demand was not able to push all necessary > revisions it will also be aborted and exit with non-zero status. > + A value of 'no' is used to override the push.recurseSubmodules > + variable when no submodule recursion is required. Does this deserve a --no-recurse-submodules alias for consistency with how other options are turned off? > --[no-]verify:: > Toggle the pre-push hook (see linkgit:githooks[5]). The > diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh > @@ -64,7 +64,15 @@ test_expect_success 'push fails if submodule commit not on remote' ' > cd work && > git add gar/bage && > git commit -m "Third commit for gar/bage" && > - test_must_fail git push --recurse-submodules=check ../pub.git master > + # the push should fail with --recurse-submodules=check > + # on the command line... > + test_must_fail git push --recurse-submodules=check ../pub.git master && > + > + # ...or if specified in the configuration.. > + git config push.recurseSubmodules check && > + test_must_fail git push ../pub.git master && > + > + git config --unset push.recurseSubmodules If something above this line fails, then 'git config --unset' will not be invoked, so the expected cleanup won't happen. Typically, to ensure cleanup, you'd use test_config(), however that function doesn't work in subshells. Probably the easiest fix, in this case, is to set the config variable as a one-shot and drop 'git config' and 'git config --unset' altogether: test_must_fail git -c push.recurseSubmodules check \ push ../pub.git master > ) > ' > > @@ -79,6 +87,119 @@ test_expect_success 'push succeeds after commit was pushed to remote' ' > +test_expect_success 'push succeeds if submodule commit not on remote but using on-demand from config' ' > + ( > + cd work/gar/bage && > + >recurse-on-demand-from-config && > + git add recurse-on-demand-from-config && > + git commit -m "Recurse on-demand from config junk" > + ) && > + ( > + cd work && > + git add gar/bage && > + git commit -m "Recurse on-demand on command line for gar/bage" && > + git config push.recurseSubmodules on-demand && > + git push ../pub.git master && > + git config --unset push.recurseSubmodules && Ditto regarding 'git config --unset' cleanup not being run there is a failure above this. Same for following tests. > + # 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 > + ) > +' -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html