From 0301c821c5cd124733accfbff0ddbf7f0b0ee9fb Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Nov 2016 10:46:04 -0800 Subject: push: fix --dry-run to not push submodules Teach push to respect the --dry-run option when configured to recursively push submodules 'on-demand'. This is done by passing the --dry-run flag to the child process which performs a push for a submodules when performing a dry-run. In order to preserve good user experience, the additional check for unpushed submodules is skipped during a dry-run when --recurse-submodules=on-demand. The check is skipped because the submodule pushes were performed as dry-runs and this check would always fail as the submodules would still need to be pushed. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- transport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'transport.c') diff --git a/transport.c b/transport.c index c3fdd5d25..e0651a5bf 100644 --- a/transport.c +++ b/transport.c @@ -921,15 +921,18 @@ int transport_push(struct transport *transport, if (!is_null_oid(&ref->new_oid)) sha1_array_append(&commits, ref->new_oid.hash); - if (!push_unpushed_submodules(&commits, transport->remote->name)) { + if (!push_unpushed_submodules(&commits, + transport->remote->name, + pretend)) { sha1_array_clear(&commits); die("Failed to push all needed submodules!"); } sha1_array_clear(&commits); } - if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND | - TRANSPORT_RECURSE_SUBMODULES_CHECK)) && !is_bare_repository()) { + if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) || + ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && + !pretend)) && !is_bare_repository()) { struct ref *ref = remote_refs; struct string_list needs_pushing = STRING_LIST_INIT_DUP; struct sha1_array commits = SHA1_ARRAY_INIT; -- cgit v1.2.1