path: root/builtin/push.c
diff options
authorFredrik Gustafsson <>2011-08-19 22:08:47 (GMT)
committerJunio C Hamano <>2011-08-21 06:03:52 (GMT)
commitd2b17b3220cbd75b1c8e2aa6cfdc5c121749c97d (patch)
tree730f2d49512177c59d02ce03666d727b2d88dbd6 /builtin/push.c
parent25e5e2bf85c8a2c2c8945935267539940c11020d (diff)
push: Don't push a repository with unpushed submodules
When working with submodules it is easy to forget to push a submodule to the server but pushing a super-project that contains a commit for that submodule. The result is that the superproject points at a submodule commit that is not available on the server. This adds the option --recurse-submodules=check to push. When using this option git will check that all submodule commits that are about to be pushed are present on a remote of the submodule. To be able to use a combined diff, disabling a diff callback has been removed from combined-diff.c. Signed-off-by: Fredrik Gustafsson <> Mentored-by: Jens Lehmann <> Mentored-by: Heiko Voigt <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/push.c')
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 9cebf9e..35cce53 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -8,6 +8,7 @@
#include "remote.h"
#include "transport.h"
#include "parse-options.h"
+#include "submodule.h"
static const char * const push_usage[] = {
"git push [<options>] [<repository> [<refspec>...]]",
@@ -219,6 +220,21 @@ static int do_push(const char *repo, int flags)
return !!errs;
+static int option_parse_recurse_submodules(const struct option *opt,
+ const char *arg, int unset)
+ int *flags = opt->value;
+ if (arg) {
+ if (!strcmp(arg, "check"))
+ else
+ die("bad %s argument: %s", opt->long_name, arg);
+ } else
+ die("option %s needs an argument (check)", opt->long_name);
+ return 0;
int cmd_push(int argc, const char **argv, const char *prefix)
int flags = 0;
@@ -236,6 +252,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT_BIT('n' , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
OPT_BIT( 0, "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN),
OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
+ { OPTION_CALLBACK, 0, "recurse-submodules", &flags, "check",
+ "controls recursive pushing of submodules",
+ PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),