summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorFredrik Gustafsson <iveqy@iveqy.com>2011-08-20 00:08:47 +0200
committerJunio C Hamano <gitster@pobox.com>2011-08-20 23:03:52 -0700
commitd2b17b3220cbd75b1c8e2aa6cfdc5c121749c97d (patch)
tree730f2d49512177c59d02ce03666d727b2d88dbd6 /transport.c
parent25e5e2bf85c8a2c2c8945935267539940c11020d (diff)
downloadgit-d2b17b3220cbd75b1c8e2aa6cfdc5c121749c97d.tar.gz
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 <iveqy@iveqy.com> Mentored-by: Jens Lehmann <Jens.Lehmann@web.de> Mentored-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/transport.c b/transport.c
index c9c8056f9d..fa279d531f 100644
--- a/transport.c
+++ b/transport.c
@@ -10,6 +10,7 @@
#include "refs.h"
#include "branch.h"
#include "url.h"
+#include "submodule.h"
/* rsync support */
@@ -1041,6 +1042,14 @@ int transport_push(struct transport *transport,
flags & TRANSPORT_PUSH_MIRROR,
flags & TRANSPORT_PUSH_FORCE);
+ if ((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) && !is_bare_repository()) {
+ struct ref *ref = remote_refs;
+ for (; ref; ref = ref->next)
+ if (!is_null_sha1(ref->new_sha1) &&
+ check_submodule_needs_pushing(ref->new_sha1,transport->remote->name))
+ die("There are unpushed submodules, aborting.");
+ }
+
push_ret = transport->push_refs(transport, remote_refs, flags);
err = push_had_errors(remote_refs);
ret = push_ret | err;