git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3] push: add recurseSubmodules config option
@ 2015-12-01 11:49 Mike Crowe
  2015-12-02  0:40 ` Jeff King
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Crowe @ 2015-12-01 11:49 UTC (permalink / raw)
  To: git; +Cc: Mike Crowe

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,
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@mcrowe.com>
---
Changes in v3:

 * Incorporate feedback from Junio C Hamano:

 ** Declare recurse_submodules variable on a separate line.

 ** Accept multiple --recurse-submodules options on the command line
    and the last one wins.

 * Add extra tests for multiple --recurse-submodules options on
   command line and improve existing tests slightly.

Changes in v2:
                                                                                      
 * Incorporate feedback from Eric Sunshine:                                           
                                                                                      
 ** push.recurseSubmodules config option now supports 'no' value.                     
                                                                                      
 ** --no-recurse-submodules is now a synonym for                                      
    --recurse-submodules=no.                                                          
                                                                                      
 ** use "git -c" rather than "git config" in tests to avoid leaving                   
    config options set if a test fails.                                               
                                                                                      
 * Fix several && chain failures in tests noticed by Stefan Beller.                   
                                                                                      
 * Minor tweaks to documentation                                                      
                                                                                      
 * Fix minor naming issues in tests         

 Documentation/config.txt       |  14 ++++
 Documentation/git-push.txt     |  24 +++---
 builtin/push.c                 |  35 ++++----
 submodule-config.c             |  29 +++++++
 submodule-config.h             |   1 +
 submodule.h                    |   1 +
 t/t5531-deep-submodule-push.sh | 182 ++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 259 insertions(+), 27 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index b4b0194..8c02e43 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2226,6 +2226,20 @@ push.gpgSign::
 	override a value from a lower-priority config file. An explicit
 	command-line flag always overrides this config option.
 
+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. If the value
+	is 'no' then default behavior of ignoring submodules when pushing
+	is retained. You may override this configuration at time of push by
+	specifying '--recurse-submodules=check|on-demand|no'.
+
 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
index 85a4d7d..4c775bc 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -257,16 +257,20 @@ origin +master` to force a push to the `master` branch). See the
 	is specified. This flag forces progress status even if the
 	standard error stream is not directed to a terminal.
 
---recurse-submodules=check|on-demand::
-	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
-	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 'on-demand' is used
-	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.
+--no-recurse-submodules::
+--recurse-submodules=check|on-demand|no::
+	May be used to 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 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 'on-demand' is used
+	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' or using '--no-recurse-submodules' can be used to override the
+	push.recurseSubmodules configuration variable when no submodule
+	recursion is required.
 
 --[no-]verify::
 	Toggle the pre-push hook (see linkgit:githooks[5]).  The
diff --git a/builtin/push.c b/builtin/push.c
index 3bda430..cc29277 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -9,6 +9,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "submodule.h"
+#include "submodule-config.h"
 #include "send-pack.h"
 
 static const char * const push_usage[] = {
@@ -21,6 +22,7 @@ static int deleterefs;
 static const char *receivepack;
 static int verbosity;
 static int progress = -1;
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
 
 static struct push_cas_option cas;
 
@@ -452,22 +454,14 @@ static int do_push(const char *repo, int flags)
 static int option_parse_recurse_submodules(const struct option *opt,
 				   const char *arg, int unset)
 {
-	int *flags = opt->value;
+	int *recurse_submodules = opt->value;
 
-	if (*flags & (TRANSPORT_RECURSE_SUBMODULES_CHECK |
-		      TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND))
-		die("%s can only be used once.", opt->long_name);
-
-	if (arg) {
-		if (!strcmp(arg, "check"))
-			*flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
-		else if (!strcmp(arg, "on-demand"))
-			*flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
-		else
-			die("bad %s argument: %s", opt->long_name, arg);
-	} else
-		die("option %s needs an argument (check|on-demand)",
-				opt->long_name);
+	if (unset)
+		*recurse_submodules = RECURSE_SUBMODULES_OFF;
+	else if (arg)
+		*recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
+	else
+		die("%s missing parameter", opt->long_name);
 
 	return 0;
 }
@@ -522,6 +516,10 @@ static int git_push_config(const char *k, const char *v, void *cb)
 					return error("Invalid value for '%s'", k);
 			}
 		}
+	} else if (!strcmp(k, "push.recursesubmodules")) {
+		const char *value;
+		if (!git_config_get_value("push.recursesubmodules", &value))
+			recurse_submodules = parse_push_recurse_submodules_arg(k, value);
 	}
 
 	return git_default_config(k, v, NULL);
@@ -549,7 +547,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		  0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
 		  N_("require old value of ref to be at this value"),
 		  PARSE_OPT_OPTARG, parseopt_push_cas_option },
-		{ OPTION_CALLBACK, 0, "recurse-submodules", &flags, "check|on-demand",
+		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("check|on-demand|no"),
 			N_("control recursive pushing of submodules"),
 			PARSE_OPT_OPTARG, option_parse_recurse_submodules },
 		OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
@@ -580,6 +578,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	if (deleterefs && argc < 2)
 		die(_("--delete doesn't make sense without any refs"));
 
+	if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
+		flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
+	else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
+		flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
+
 	if (tags)
 		add_refspec("refs/tags/*");
 
diff --git a/submodule-config.c b/submodule-config.c
index afe0ea8..fe8ceab 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -228,6 +228,35 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
 	return parse_fetch_recurse(opt, arg, 1);
 }
 
+static int parse_push_recurse(const char *opt, const char *arg,
+			       int die_on_error)
+{
+	switch (git_config_maybe_bool(opt, arg)) {
+	case 1:
+		/* There's no simple "on" value when pushing */
+		if (die_on_error)
+			die("bad %s argument: %s", opt, arg);
+		else
+			return RECURSE_SUBMODULES_ERROR;
+	case 0:
+		return RECURSE_SUBMODULES_OFF;
+	default:
+		if (!strcmp(arg, "on-demand"))
+			return RECURSE_SUBMODULES_ON_DEMAND;
+		else if (!strcmp(arg, "check"))
+			return RECURSE_SUBMODULES_CHECK;
+		else if (die_on_error)
+			die("bad %s argument: %s", opt, arg);
+		else
+			return RECURSE_SUBMODULES_ERROR;
+	}
+}
+
+int parse_push_recurse_submodules_arg(const char *opt, const char *arg)
+{
+	return parse_push_recurse(opt, arg, 1);
+}
+
 static void warn_multiple_config(const unsigned char *commit_sha1,
 				 const char *name, const char *option)
 {
diff --git a/submodule-config.h b/submodule-config.h
index 9061e4e..9bfa65a 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -19,6 +19,7 @@ struct submodule {
 };
 
 int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
+int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
 int parse_submodule_config_option(const char *var, const char *value);
 const struct submodule *submodule_from_name(const unsigned char *commit_sha1,
 		const char *name);
diff --git a/submodule.h b/submodule.h
index 5507c3d..ddff512 100644
--- a/submodule.h
+++ b/submodule.h
@@ -5,6 +5,7 @@ struct diff_options;
 struct argv_array;
 
 enum {
+	RECURSE_SUBMODULES_CHECK = -4,
 	RECURSE_SUBMODULES_ERROR = -3,
 	RECURSE_SUBMODULES_NONE = -2,
 	RECURSE_SUBMODULES_ON_DEMAND = -1,
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 6507487..9a637f5 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -64,7 +64,12 @@ 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..
+		test_must_fail git -c push.recurseSubmodules=check push ../pub.git master
 	)
 '
 
@@ -79,6 +84,181 @@ 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 on command line' '
+	(
+		cd work/gar/bage &&
+		>recurse-on-demand-on-command-line &&
+		git add recurse-on-demand-on-command-line &&
+		git commit -m "Recurse on-demand on command line junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on-demand on command line for gar/bage" &&
+		git push --recurse-submodules=on-demand ../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 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 from config for gar/bage" &&
+		git -c push.recurseSubmodules=on-demand 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 cmdline overrides config' '
+	(
+		cd work/gar/bage &&
+		>recurse-check-on-command-line-overriding-config &&
+		git add recurse-check-on-command-line-overriding-config &&
+		git commit -m "Recurse on command-line overridiing config junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on command-line overriding config for gar/bage" &&
+		test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master &&
+		# Check that the supermodule commit did not get there
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master^ &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+		# Now try the reverse which should succeed
+		git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		(cd gar/bage && git diff --quiet origin/master master)
+	)
+'
+
+test_expect_success 'push recurse-submodules on cmdline overrides earlier cmdline' '
+	(
+		cd work/gar/bage &&
+		>recurse-check-on-command-line-overriding-earlier-command-line &&
+		git add recurse-check-on-command-line-overriding-earlier-command-line &&
+		git commit -m "Recurse on command-line overridiing earlier command-line junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" &&
+		test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master &&
+		# Check that the supermodule commit did not get there
+		git fetch ../pub.git &&
+		git diff FETCH_HEAD master^ &&
+		git diff --quiet FETCH_HEAD master^ &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+		# But the options in the other order should push the submodule
+		git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master &&
+		# Check that the submodule commit did get there
+		git fetch ../pub.git &&
+		(cd gar/bage && git diff --quiet origin/master master)
+	)
+'
+
+test_expect_success 'push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
+	(
+		cd work/gar/bage &&
+		>recurse-on-demand-on-command-line-overriding-config &&
+		git add recurse-on-demand-on-command-line-overriding-config &&
+		git commit -m "Recurse on-demand on command-line overriding config junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on-demand on command-line overriding config for gar/bage" &&
+		git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../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
+		cd gar/bage &&
+		git diff --quiet origin/master master
+	)
+'
+
+test_expect_success 'push succeeds if submodule commit disabling recursion from cmdline overriding config' '
+	(
+		cd work/gar/bage &&
+		>recurse-disable-on-command-line-overriding-config &&
+		git add recurse-disable-on-command-line-overriding-config &&
+		git commit -m "Recurse disable on command-line overriding config junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse disable on command-line overriding config for gar/bage" &&
+		git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git master &&
+		# Check that the supermodule commit got there
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		# But that the submodule commit did not
+		( cd gar/bage && git diff --quiet origin/master master^ ) &&
+		# Now push it to avoid confusing future tests
+		git push --recurse-submodules=on-demand ../pub.git master
+	)
+'
+
+test_expect_success 'push succeeds if submodule commit disabling recursion from cmdline (alternative form) overriding config' '
+	(
+		cd work/gar/bage &&
+		>recurse-disable-on-command-line-alt-overriding-config &&
+		git add recurse-disable-on-command-line-alt-overriding-config &&
+		git commit -m "Recurse disable on command-line alternative overriding config junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse disable on command-line alternative overriding config for gar/bage" &&
+		git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git master &&
+		# Check that the supermodule commit got there
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		# But that the submodule commit did not
+		( cd gar/bage && git diff --quiet origin/master master^ ) &&
+		# Now push it to avoid confusing future tests
+		git push --recurse-submodules=on-demand ../pub.git master
+	)
+'
+
+test_expect_success 'push fails if recurse submodules option passed as yes' '
+	(
+		cd work/gar/bage &&
+		>recurse-push-fails-if-recurse-submodules-passed-as-yes &&
+		git add recurse-push-fails-if-recurse-submodules-passed-as-yes &&
+		git commit -m "Recurse push fails if recurse submodules option passed as yes"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse push fails if recurse submodules option passed as yes for gar/bage" &&
+		test_must_fail git push --recurse-submodules=yes ../pub.git master &&
+		test_must_fail git -c push.recurseSubmodules=yes push ../pub.git master &&
+		git push --recurse-submodules=on-demand ../pub.git master
+	)
+'
+
 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
 	(
 		cd work/gar/bage &&
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] push: add recurseSubmodules config option
  2015-12-01 11:49 [PATCH v3] push: add recurseSubmodules config option Mike Crowe
@ 2015-12-02  0:40 ` Jeff King
  2015-12-02  9:54   ` Mike Crowe
  0 siblings, 1 reply; 16+ messages in thread
From: Jeff King @ 2015-12-02  0:40 UTC (permalink / raw)
  To: Mike Crowe; +Cc: git

On Tue, Dec 01, 2015 at 11:49:43AM +0000, Mike Crowe 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,
> 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@mcrowe.com>
> ---
> Changes in v3:

Hrm, I merged v2 of this to 'next' last week.

The options at this point are either to revert that and re-start the
topic, or just make the further changes a patch on top. Thoughts?

-Peff

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] push: add recurseSubmodules config option
  2015-12-02  0:40 ` Jeff King
@ 2015-12-02  9:54   ` Mike Crowe
  2015-12-02  9:56     ` [PATCH] push: Improve --recurse-submodules support Mike Crowe
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Crowe @ 2015-12-02  9:54 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Tuesday 01 December 2015 at 19:40:32 -0500, Jeff King wrote:
> On Tue, Dec 01, 2015 at 11:49:43AM +0000, Mike Crowe 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,
> > 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@mcrowe.com>
> > ---
> > Changes in v3:
> 
> Hrm, I merged v2 of this to 'next' last week.

Thanks! Sorry I didn't spot that.

> The options at this point are either to revert that and re-start the
> topic, or just make the further changes a patch on top. Thoughts?

I don't mind which you choose to do. I'll reply to this message with the
incremental patch in case you decide you need it. Please let me know if
you'd like me to split it further since the patch modifies a test that is
otherwise unrelated to the rest of the change.

Mike.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] push: Improve --recurse-submodules support
  2015-12-02  9:54   ` Mike Crowe
@ 2015-12-02  9:56     ` Mike Crowe
  2015-12-02 23:21       ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Crowe @ 2015-12-02  9:56 UTC (permalink / raw)
  To: git; +Cc: Mike Crowe, Jeff King

b33a15b08131514b593015cb3e719faf9db20208 added support for the
push.recurseSubmodules config option. After it was merged Junio C Hamano
suggested some improvements:

 - Declare recurse_submodules on a separate line.

 - Accept multiple --recurse-submodules options on command line with the
   last one winning. (This simplified the implementation too.)

Also slightly improve one of the tests added in
b33a15b08131514b593015cb3e719faf9db20208.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
---

 builtin/push.c                 | 12 +++---------
 t/t5531-deep-submodule-push.sh | 36 +++++++++++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index f9b59b4..cc29277 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -21,7 +21,8 @@ static int thin = 1;
 static int deleterefs;
 static const char *receivepack;
 static int verbosity;
-static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
+static int progress = -1;
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
 
 static struct push_cas_option cas;
 
@@ -455,9 +456,6 @@ static int option_parse_recurse_submodules(const struct option *opt,
 {
 	int *recurse_submodules = opt->value;
 
-	if (*recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
-		die("%s can only be used once.", opt->long_name);
-
 	if (unset)
 		*recurse_submodules = RECURSE_SUBMODULES_OFF;
 	else if (arg)
@@ -532,7 +530,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	int flags = 0;
 	int tags = 0;
 	int push_cert = -1;
-	int recurse_submodules_from_cmdline = RECURSE_SUBMODULES_DEFAULT;
 	int rc;
 	const char *repo = NULL;	/* default repository */
 	struct option options[] = {
@@ -550,7 +547,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		  0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
 		  N_("require old value of ref to be at this value"),
 		  PARSE_OPT_OPTARG, parseopt_push_cas_option },
-		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules_from_cmdline, N_("check|on-demand|no"),
+		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("check|on-demand|no"),
 			N_("control recursive pushing of submodules"),
 			PARSE_OPT_OPTARG, option_parse_recurse_submodules },
 		OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
@@ -581,9 +578,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	if (deleterefs && argc < 2)
 		die(_("--delete doesn't make sense without any refs"));
 
-	if (recurse_submodules_from_cmdline != RECURSE_SUBMODULES_DEFAULT)
-		recurse_submodules = recurse_submodules_from_cmdline;
-
 	if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
 		flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
 	else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 9fda7b0..9a637f5 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -126,7 +126,7 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
 	)
 '
 
-test_expect_success 'push fails if submodule commit not on remote using check from cmdline overriding config' '
+test_expect_success 'push recurse-submodules cmdline overrides config' '
 	(
 		cd work/gar/bage &&
 		>recurse-check-on-command-line-overriding-config &&
@@ -142,8 +142,38 @@ test_expect_success 'push fails if submodule commit not on remote using check fr
 		git fetch ../pub.git &&
 		git diff --quiet FETCH_HEAD master^ &&
 		# Check that the submodule commit did not get there
-		cd gar/bage &&
-		git diff --quiet origin/master master^
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+		# Now try the reverse which should succeed
+		git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		(cd gar/bage && git diff --quiet origin/master master)
+	)
+'
+
+test_expect_success 'push recurse-submodules on cmdline overrides earlier cmdline' '
+	(
+		cd work/gar/bage &&
+		>recurse-check-on-command-line-overriding-earlier-command-line &&
+		git add recurse-check-on-command-line-overriding-earlier-command-line &&
+		git commit -m "Recurse on command-line overridiing earlier command-line junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" &&
+		test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master &&
+		# Check that the supermodule commit did not get there
+		git fetch ../pub.git &&
+		git diff FETCH_HEAD master^ &&
+		git diff --quiet FETCH_HEAD master^ &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+		# But the options in the other order should push the submodule
+		git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master &&
+		# Check that the submodule commit did get there
+		git fetch ../pub.git &&
+		(cd gar/bage && git diff --quiet origin/master master)
 	)
 '
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] push: Improve --recurse-submodules support
  2015-12-02  9:56     ` [PATCH] push: Improve --recurse-submodules support Mike Crowe
@ 2015-12-02 23:21       ` Junio C Hamano
  2015-12-03 13:10         ` Mike Crowe
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2015-12-02 23:21 UTC (permalink / raw)
  To: Mike Crowe; +Cc: git, Jeff King

Mike Crowe <mac@mcrowe.com> writes:

> b33a15b08131514b593015cb3e719faf9db20208 added support for the
> push.recurseSubmodules config option. After it was merged Junio C Hamano
> suggested some improvements:
>
>  - Declare recurse_submodules on a separate line.
>
>  - Accept multiple --recurse-submodules options on command line with the
>    last one winning. (This simplified the implementation too.)
>
> Also slightly improve one of the tests added in
> b33a15b08131514b593015cb3e719faf9db20208.

The above is overly verbose about how the commit materialized,
compared to the description of the merit of this update.

    push: fix --recurse-submodules breakage

    When b33a15b0 (push: add recurseSubmodules config option,
    2015-11-17) added push.recurseSubmodules configuration option,
    it also changed the command line parsing to allow
    --no-recurse-submodules to override configured default.
    However, the parsing of configuration variables and command line
    options did not follow the usual "last one wins" convention.
    Fix this.

    Also fix the declaration of the new file-scope global variable
    to put it on a separate line on its own.

or something?

Also describe what "slightly improve" really means.  What did the
old one not test that should have been tested?

Thanks.

> diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
> index 9fda7b0..9a637f5 100755
> --- a/t/t5531-deep-submodule-push.sh
> +++ b/t/t5531-deep-submodule-push.sh
> @@ -126,7 +126,7 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
>  	)
>  '
>  
> -test_expect_success 'push fails if submodule commit not on remote using check from cmdline overriding config' '
> +test_expect_success 'push recurse-submodules cmdline overrides config' '
>  	(
>  		cd work/gar/bage &&
>  		>recurse-check-on-command-line-overriding-config &&
> @@ -142,8 +142,38 @@ test_expect_success 'push fails if submodule commit not on remote using check fr
>  		git fetch ../pub.git &&
>  		git diff --quiet FETCH_HEAD master^ &&
>  		# Check that the submodule commit did not get there
> -		cd gar/bage &&
> -		git diff --quiet origin/master master^
> +		(cd gar/bage && git diff --quiet origin/master master^) &&

These days, you can do:

		git -C gar/bage --quiet origin/master master^

instead.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] push: Improve --recurse-submodules support
  2015-12-02 23:21       ` Junio C Hamano
@ 2015-12-03 13:10         ` Mike Crowe
  2015-12-03 13:10           ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Mike Crowe
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Crowe @ 2015-12-03 13:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jeff King

On Wednesday 02 December 2015 at 15:21:13 -0800, Junio C Hamano wrote:
> Mike Crowe <mac@mcrowe.com> writes:
> 
> > b33a15b08131514b593015cb3e719faf9db20208 added support for the
> > push.recurseSubmodules config option. After it was merged Junio C Hamano
> > suggested some improvements:
> >
> >  - Declare recurse_submodules on a separate line.
> >
> >  - Accept multiple --recurse-submodules options on command line with the
> >    last one winning. (This simplified the implementation too.)
> >
> > Also slightly improve one of the tests added in
> > b33a15b08131514b593015cb3e719faf9db20208.
> 
> The above is overly verbose about how the commit materialized,
> compared to the description of the merit of this update.
> 
>     push: fix --recurse-submodules breakage
>
>     When b33a15b0 (push: add recurseSubmodules config option,
>     2015-11-17) added push.recurseSubmodules configuration option,
>     it also changed the command line parsing to allow
>     --no-recurse-submodules to override configured default.
>
>     However, the parsing of configuration variables and command line
>     options did not follow the usual "last one wins" convention.
>     Fix this.

That's not quite true.

The check for conflicting options was added back in 2012 by eb21c732 when
--recurse-submodules=on-demand support was originally implemented. b33a15b0
treated that as correct and maintained the behaviour.

> 
>     Also fix the declaration of the new file-scope global variable
>     to put it on a separate line on its own.
> 
> or something?

Thanks for the better wording. Hopefully I've included enough of the right
bits in the updated patches that follow.

> Also describe what "slightly improve" really means.  What did the
> old one not test that should have been tested?

In attempting to describe this change I've found that both of the tests had
failings so I have improved them too.

Thanks.

Mike.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config
  2015-12-03 13:10         ` Mike Crowe
@ 2015-12-03 13:10           ` Mike Crowe
  2015-12-03 13:10             ` [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules Mike Crowe
  2015-12-16 20:48             ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Stefan Beller
  0 siblings, 2 replies; 16+ messages in thread
From: Mike Crowe @ 2015-12-03 13:10 UTC (permalink / raw)
  To: git, Junio C Hamano; +Cc: Mike Crowe, Jeff King

t5531 only checked that the push.recurseSubmodules config option was
overridden by passing --recurse-submodules=check on the command line.
Add new tests for overriding with --recurse-submodules=no,
--no-recurse-submodules and --recurse-submodules=push too.

Also correct minor typo in test commit message.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
---
 t/t5531-deep-submodule-push.sh | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 9fda7b0..721be32 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -126,24 +126,48 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
 	)
 '
 
-test_expect_success 'push fails if submodule commit not on remote using check from cmdline overriding config' '
+test_expect_success 'push recurse-submodules on command line overrides config' '
 	(
 		cd work/gar/bage &&
 		>recurse-check-on-command-line-overriding-config &&
 		git add recurse-check-on-command-line-overriding-config &&
-		git commit -m "Recurse on command-line overridiing config junk"
+		git commit -m "Recurse on command-line overriding config junk"
 	) &&
 	(
 		cd work &&
 		git add gar/bage &&
 		git commit -m "Recurse on command-line overriding config for gar/bage" &&
+
+		# Ensure that we can override on-demand in the config
+		# to just check submodules
 		test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master &&
 		# Check that the supermodule commit did not get there
 		git fetch ../pub.git &&
 		git diff --quiet FETCH_HEAD master^ &&
 		# Check that the submodule commit did not get there
-		cd gar/bage &&
-		git diff --quiet origin/master master^
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# Ensure that we can override check in the config to
+		# disable submodule recursion entirely
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+		git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git master &&
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# Ensure that we can override check in the config to
+		# disable submodule recursion entirely (alternative form)
+		git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git master &&
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# Ensure that we can override check in the config to
+		# push the submodule too
+		git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		(cd gar/bage && git diff --quiet origin/master master)
 	)
 '
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules
  2015-12-03 13:10           ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Mike Crowe
@ 2015-12-03 13:10             ` Mike Crowe
  2015-12-04 21:04               ` Junio C Hamano
  2015-12-10 23:31               ` Stefan Beller
  2015-12-16 20:48             ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Stefan Beller
  1 sibling, 2 replies; 16+ messages in thread
From: Mike Crowe @ 2015-12-03 13:10 UTC (permalink / raw)
  To: git, Junio C Hamano; +Cc: Mike Crowe, Jeff King

Use the "last one wins" convention for --recurse-submodules rather than
treating conflicting options as an error.

Also, fix the declaration of the file-scope recurse_submodules global
variable to put it on a separate line.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
---
 builtin/push.c                 | 12 +++---------
 t/t5531-deep-submodule-push.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index f9b59b4..cc29277 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -21,7 +21,8 @@ static int thin = 1;
 static int deleterefs;
 static const char *receivepack;
 static int verbosity;
-static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
+static int progress = -1;
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
 
 static struct push_cas_option cas;
 
@@ -455,9 +456,6 @@ static int option_parse_recurse_submodules(const struct option *opt,
 {
 	int *recurse_submodules = opt->value;
 
-	if (*recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
-		die("%s can only be used once.", opt->long_name);
-
 	if (unset)
 		*recurse_submodules = RECURSE_SUBMODULES_OFF;
 	else if (arg)
@@ -532,7 +530,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	int flags = 0;
 	int tags = 0;
 	int push_cert = -1;
-	int recurse_submodules_from_cmdline = RECURSE_SUBMODULES_DEFAULT;
 	int rc;
 	const char *repo = NULL;	/* default repository */
 	struct option options[] = {
@@ -550,7 +547,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		  0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
 		  N_("require old value of ref to be at this value"),
 		  PARSE_OPT_OPTARG, parseopt_push_cas_option },
-		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules_from_cmdline, N_("check|on-demand|no"),
+		{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("check|on-demand|no"),
 			N_("control recursive pushing of submodules"),
 			PARSE_OPT_OPTARG, option_parse_recurse_submodules },
 		OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
@@ -581,9 +578,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	if (deleterefs && argc < 2)
 		die(_("--delete doesn't make sense without any refs"));
 
-	if (recurse_submodules_from_cmdline != RECURSE_SUBMODULES_DEFAULT)
-		recurse_submodules = recurse_submodules_from_cmdline;
-
 	if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
 		flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
 	else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 721be32..198ce84 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -171,6 +171,47 @@ test_expect_success 'push recurse-submodules on command line overrides config' '
 	)
 '
 
+test_expect_success 'push recurse-submodules last one wins on command line' '
+	(
+		cd work/gar/bage &&
+		>recurse-check-on-command-line-overriding-earlier-command-line &&
+		git add recurse-check-on-command-line-overriding-earlier-command-line &&
+		git commit -m "Recurse on command-line overridiing earlier command-line junk"
+	) &&
+	(
+		cd work &&
+		git add gar/bage &&
+		git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" &&
+
+		# should result in "check"
+		test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master &&
+		# Check that the supermodule commit did not get there
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master^ &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# should result in "no"
+		git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git master &&
+		# Check that the supermodule commit did get there
+		git fetch ../pub.git &&
+		git diff --quiet FETCH_HEAD master &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# should result in "no"
+		git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master &&
+		# Check that the submodule commit did not get there
+		(cd gar/bage && git diff --quiet origin/master master^) &&
+
+		# But the options in the other order should push the submodule
+		git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master &&
+		# Check that the submodule commit did get there
+		git fetch ../pub.git &&
+		(cd gar/bage && git diff --quiet origin/master master)
+	)
+'
+
 test_expect_success 'push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
 	(
 		cd work/gar/bage &&
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules
  2015-12-03 13:10             ` [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules Mike Crowe
@ 2015-12-04 21:04               ` Junio C Hamano
  2015-12-10 23:31               ` Stefan Beller
  1 sibling, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2015-12-04 21:04 UTC (permalink / raw)
  To: Mike Crowe; +Cc: git, Jeff King

Thanks, will queue.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules
  2015-12-03 13:10             ` [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules Mike Crowe
  2015-12-04 21:04               ` Junio C Hamano
@ 2015-12-10 23:31               ` Stefan Beller
  2015-12-10 23:38                 ` Junio C Hamano
  1 sibling, 1 reply; 16+ messages in thread
From: Stefan Beller @ 2015-12-10 23:31 UTC (permalink / raw)
  To: Mike Crowe; +Cc: git@vger.kernel.org, Junio C Hamano, Jeff King

On Thu, Dec 3, 2015 at 5:10 AM, Mike Crowe <mac@mcrowe.com> wrote:
> Use the "last one wins" convention for --recurse-submodules rather than
> treating conflicting options as an error.
>
> Also, fix the declaration of the file-scope recurse_submodules global
> variable to put it on a separate line.
>
> Signed-off-by: Mike Crowe <mac@mcrowe.com>
> ---
>  builtin/push.c                 | 12 +++---------
>  t/t5531-deep-submodule-push.sh | 41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+), 9 deletions(-)
>
> diff --git a/builtin/push.c b/builtin/push.c
> index f9b59b4..cc29277 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -21,7 +21,8 @@ static int thin = 1;
>  static int deleterefs;
>  static const char *receivepack;
>  static int verbosity;
> -static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
> +static int progress = -1;
> +static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
>
>  static struct push_cas_option cas;
>
> @@ -455,9 +456,6 @@ static int option_parse_recurse_submodules(const struct option *opt,
>  {
>         int *recurse_submodules = opt->value;
>
> -       if (*recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
> -               die("%s can only be used once.", opt->long_name);
> -
>         if (unset)
>                 *recurse_submodules = RECURSE_SUBMODULES_OFF;
>         else if (arg)
> @@ -532,7 +530,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>         int flags = 0;
>         int tags = 0;
>         int push_cert = -1;
> -       int recurse_submodules_from_cmdline = RECURSE_SUBMODULES_DEFAULT;
>         int rc;
>         const char *repo = NULL;        /* default repository */
>         struct option options[] = {
> @@ -550,7 +547,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>                   0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
>                   N_("require old value of ref to be at this value"),
>                   PARSE_OPT_OPTARG, parseopt_push_cas_option },
> -               { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules_from_cmdline, N_("check|on-demand|no"),
> +               { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("check|on-demand|no"),
>                         N_("control recursive pushing of submodules"),
>                         PARSE_OPT_OPTARG, option_parse_recurse_submodules },
>                 OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
> @@ -581,9 +578,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>         if (deleterefs && argc < 2)
>                 die(_("--delete doesn't make sense without any refs"));
>
> -       if (recurse_submodules_from_cmdline != RECURSE_SUBMODULES_DEFAULT)
> -               recurse_submodules = recurse_submodules_from_cmdline;
> -
>         if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
>                 flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
>         else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
> diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
> index 721be32..198ce84 100755
> --- a/t/t5531-deep-submodule-push.sh
> +++ b/t/t5531-deep-submodule-push.sh
> @@ -171,6 +171,47 @@ test_expect_success 'push recurse-submodules on command line overrides config' '
>         )
>  '
>
> +test_expect_success 'push recurse-submodules last one wins on command line' '
> +       (
> +               cd work/gar/bage &&
> +               >recurse-check-on-command-line-overriding-earlier-command-line &&
> +               git add recurse-check-on-command-line-overriding-earlier-command-line &&
> +               git commit -m "Recurse on command-line overridiing earlier command-line junk"
> +       ) &&
> +       (
> +               cd work &&
> +               git add gar/bage &&
> +               git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" &&
> +
> +               # should result in "check"
> +               test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master &&
> +               # Check that the supermodule commit did not get there
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master^ &&
> +               # Check that the submodule commit did not get there
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # should result in "no"
> +               git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git master &&
> +               # Check that the supermodule commit did get there
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master &&
> +               # Check that the submodule commit did not get there
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # should result in "no"
> +               git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master &&
> +               # Check that the submodule commit did not get there

Do we want to check here that the supermodule commit did get there,
instead of only checking the submodule?
I just wonder why we stop checking the superproject starting here, so
either it makes sense to drop
that check before or continue to check the superproject check here, no?

> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # But the options in the other order should push the submodule
> +               git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master &&
> +               # Check that the submodule commit did get there
> +               git fetch ../pub.git &&
> +               (cd gar/bage && git diff --quiet origin/master master)
> +       )
> +'
> +
>  test_expect_success 'push succeeds if submodule commit not on remote using on-demand from cmdline overriding config' '
>         (
>                 cd work/gar/bage &&
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules
  2015-12-10 23:31               ` Stefan Beller
@ 2015-12-10 23:38                 ` Junio C Hamano
  2015-12-10 23:44                   ` Stefan Beller
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2015-12-10 23:38 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Mike Crowe, git@vger.kernel.org, Jeff King

Stefan Beller <sbeller@google.com> writes:

>> +               git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master &&
>> +               # Check that the submodule commit did not get there
>
> Do we want to check here that the supermodule commit did get there,
> instead of only checking the submodule?

Hmm, your point is that when the push succeeds, (1) the command
should return with 0 status, (2) the branch in the superproject
should update to the right commit, and (3) none of the submodule
should be affected, and the current test does not check the second
one?

I think that makes sense, in somewhat a paranoid way ;-).

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules
  2015-12-10 23:38                 ` Junio C Hamano
@ 2015-12-10 23:44                   ` Stefan Beller
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Beller @ 2015-12-10 23:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Mike Crowe, git@vger.kernel.org, Jeff King

On Thu, Dec 10, 2015 at 3:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>>> +               git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master &&
>>> +               # Check that the submodule commit did not get there
>>
>> Do we want to check here that the supermodule commit did get there,
>> instead of only checking the submodule?
>
> Hmm, your point is that when the push succeeds, (1) the command
> should return with 0 status, (2) the branch in the superproject
> should update to the right commit, and (3) none of the submodule
> should be affected, and the current test does not check the second
> one?
>
> I think that makes sense, in somewhat a paranoid way ;-).

I was just comparing to the case before,
where we had

> +               # Check that the supermodule commit did get there
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master &&

which I just skimmed over and mistakenly thought it would be the same check as
before (checking the superproject did *not* get there).

So looking at it, the superprojects history would need no update,
the commit stays the same, so no need check for it to stay the same.

So, sorry for the noise.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config
  2015-12-03 13:10           ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Mike Crowe
  2015-12-03 13:10             ` [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules Mike Crowe
@ 2015-12-16 20:48             ` Stefan Beller
  2015-12-16 22:41               ` Junio C Hamano
  1 sibling, 1 reply; 16+ messages in thread
From: Stefan Beller @ 2015-12-16 20:48 UTC (permalink / raw)
  To: Mike Crowe; +Cc: git@vger.kernel.org, Junio C Hamano, Jeff King

On Thu, Dec 3, 2015 at 5:10 AM, Mike Crowe <mac@mcrowe.com> wrote:
> t5531 only checked that the push.recurseSubmodules config option was
> overridden by passing --recurse-submodules=check on the command line.
> Add new tests for overriding with --recurse-submodules=no,
> --no-recurse-submodules and --recurse-submodules=push too.
>
> Also correct minor typo in test commit message.
>
> Signed-off-by: Mike Crowe <mac@mcrowe.com>

This looks good to me.

Thanks,
Stefan


> ---
>  t/t5531-deep-submodule-push.sh | 32 ++++++++++++++++++++++++++++----
>  1 file changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
> index 9fda7b0..721be32 100755
> --- a/t/t5531-deep-submodule-push.sh
> +++ b/t/t5531-deep-submodule-push.sh
> @@ -126,24 +126,48 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
>         )
>  '
>
> -test_expect_success 'push fails if submodule commit not on remote using check from cmdline overriding config' '
> +test_expect_success 'push recurse-submodules on command line overrides config' '
>         (
>                 cd work/gar/bage &&
>                 >recurse-check-on-command-line-overriding-config &&
>                 git add recurse-check-on-command-line-overriding-config &&
> -               git commit -m "Recurse on command-line overridiing config junk"
> +               git commit -m "Recurse on command-line overriding config junk"
>         ) &&
>         (
>                 cd work &&
>                 git add gar/bage &&
>                 git commit -m "Recurse on command-line overriding config for gar/bage" &&
> +
> +               # Ensure that we can override on-demand in the config
> +               # to just check submodules
>                 test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master &&
>                 # Check that the supermodule commit did not get there
>                 git fetch ../pub.git &&
>                 git diff --quiet FETCH_HEAD master^ &&
>                 # Check that the submodule commit did not get there
> -               cd gar/bage &&
> -               git diff --quiet origin/master master^
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # Ensure that we can override check in the config to
> +               # disable submodule recursion entirely
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +               git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git master &&
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master &&
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # Ensure that we can override check in the config to
> +               # disable submodule recursion entirely (alternative form)
> +               git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git master &&
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master &&
> +               (cd gar/bage && git diff --quiet origin/master master^) &&
> +
> +               # Ensure that we can override check in the config to
> +               # push the submodule too
> +               git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master &&
> +               git fetch ../pub.git &&
> +               git diff --quiet FETCH_HEAD master &&
> +               (cd gar/bage && git diff --quiet origin/master master)
>         )
>  '
>
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config
  2015-12-16 20:48             ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Stefan Beller
@ 2015-12-16 22:41               ` Junio C Hamano
  2015-12-16 22:46                 ` Stefan Beller
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2015-12-16 22:41 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Mike Crowe, git@vger.kernel.org, Jeff King

Stefan Beller <sbeller@google.com> writes:

> On Thu, Dec 3, 2015 at 5:10 AM, Mike Crowe <mac@mcrowe.com> wrote:
>> t5531 only checked that the push.recurseSubmodules config option was
>> overridden by passing --recurse-submodules=check on the command line.
>> Add new tests for overriding with --recurse-submodules=no,
>> --no-recurse-submodules and --recurse-submodules=push too.
>>
>> Also correct minor typo in test commit message.
>>
>> Signed-off-by: Mike Crowe <mac@mcrowe.com>
>
> This looks good to me.
>
> Thanks,
> Stefan

Thanks.  Does "This" refer to 1/2 alone or the whole series?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config
  2015-12-16 22:41               ` Junio C Hamano
@ 2015-12-16 22:46                 ` Stefan Beller
  2015-12-17 16:41                   ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: Stefan Beller @ 2015-12-16 22:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Mike Crowe, git@vger.kernel.org, Jeff King

On Wed, Dec 16, 2015 at 2:41 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> On Thu, Dec 3, 2015 at 5:10 AM, Mike Crowe <mac@mcrowe.com> wrote:
>>> t5531 only checked that the push.recurseSubmodules config option was
>>> overridden by passing --recurse-submodules=check on the command line.
>>> Add new tests for overriding with --recurse-submodules=no,
>>> --no-recurse-submodules and --recurse-submodules=push too.
>>>
>>> Also correct minor typo in test commit message.
>>>
>>> Signed-off-by: Mike Crowe <mac@mcrowe.com>
>>
>> This looks good to me.
>>
>> Thanks,
>> Stefan
>
> Thanks.  Does "This" refer to 1/2 alone or the whole series?

Yes. :)

"This" is applicable to both patches. We had the discussion on 2/2 about me
misreading a line a few days earlier, but apart from that it looked good, too.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config
  2015-12-16 22:46                 ` Stefan Beller
@ 2015-12-17 16:41                   ` Junio C Hamano
  0 siblings, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2015-12-17 16:41 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Mike Crowe, git@vger.kernel.org, Jeff King

Stefan Beller <sbeller@google.com> writes:

>>> This looks good to me.
>>>
>> Thanks.  Does "This" refer to 1/2 alone or the whole series?
>
> Yes. :)
>
> "This" is applicable to both patches. We had the discussion on 2/2 about me
> misreading a line a few days earlier, but apart from that it looked good, too.

Thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-17 16:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 11:49 [PATCH v3] push: add recurseSubmodules config option Mike Crowe
2015-12-02  0:40 ` Jeff King
2015-12-02  9:54   ` Mike Crowe
2015-12-02  9:56     ` [PATCH] push: Improve --recurse-submodules support Mike Crowe
2015-12-02 23:21       ` Junio C Hamano
2015-12-03 13:10         ` Mike Crowe
2015-12-03 13:10           ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Mike Crowe
2015-12-03 13:10             ` [PATCH 2/2] push: Use "last one wins" convention for --recurse-submodules Mike Crowe
2015-12-04 21:04               ` Junio C Hamano
2015-12-10 23:31               ` Stefan Beller
2015-12-10 23:38                 ` Junio C Hamano
2015-12-10 23:44                   ` Stefan Beller
2015-12-16 20:48             ` [PATCH 1/2] push: Fully test --recurse-submodules on command line overrides config Stefan Beller
2015-12-16 22:41               ` Junio C Hamano
2015-12-16 22:46                 ` Stefan Beller
2015-12-17 16:41                   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).