From a762e51ef2a39b0c326a1529dbe7f4cb303960db Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Thu, 29 Mar 2012 09:21:23 +0200 Subject: Refactor submodule push check to use string list instead of integer This allows us to tell the user which submodules have not been pushed. Additionally this is helpful when we want to automatically try to push submodules that have not been pushed. Signed-off-by: Heiko Voigt Signed-off-by: Junio C Hamano --- transport.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'transport.c') diff --git a/transport.c b/transport.c index cac0c065f..abde8f60d 100644 --- a/transport.c +++ b/transport.c @@ -11,6 +11,7 @@ #include "branch.h" #include "url.h" #include "submodule.h" +#include "string-list.h" /* rsync support */ @@ -1000,6 +1001,20 @@ void transport_set_verbosity(struct transport *transport, int verbosity, transport->progress = force_progress || (verbosity >= 0 && isatty(2)); } +static void die_with_unpushed_submodules(struct string_list *needs_pushing) +{ + int i; + + fprintf(stderr, "The following submodule paths contain changes that can\n" + "not be found on any remote:\n"); + for (i = 0; i < needs_pushing->nr; i++) + printf(" %s\n", needs_pushing->items[i].string); + + string_list_clear(needs_pushing, 0); + + die("Aborting."); +} + int transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags, int *nonfastforward) @@ -1040,10 +1055,15 @@ int transport_push(struct transport *transport, if ((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) && !is_bare_repository()) { struct ref *ref = remote_refs; + struct string_list needs_pushing; + + memset(&needs_pushing, 0, sizeof(struct string_list)); + needs_pushing.strdup_strings = 1; 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."); + find_unpushed_submodules(ref->new_sha1, + transport->remote->name, &needs_pushing)) + die_with_unpushed_submodules(&needs_pushing); } push_ret = transport->push_refs(transport, remote_refs, flags); -- cgit v1.2.1