From 64e3e6d43acbbf6cc8f8a4c612547c5a575c4031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 11 Oct 2014 12:25:50 +0200 Subject: remote: use configured push refspecs if none are given If the user does not pass any refspecs to push, try to use those configured via the configuration or via add_push(). --- src/remote.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/remote.c b/src/remote.c index 524d5a3d4..4cfae108b 100644 --- a/src/remote.c +++ b/src/remote.c @@ -2119,6 +2119,7 @@ int git_remote_push(git_remote *remote, git_strarray *refspecs, const git_push_o size_t i; git_push *push = NULL; git_remote_callbacks *cbs; + git_refspec *spec; assert(remote && refspecs); @@ -2131,9 +2132,18 @@ int git_remote_push(git_remote *remote, git_strarray *refspecs, const git_push_o if (opts && (error = git_push_set_options(push, opts)) < 0) goto cleanup; - for (i = 0; i < refspecs->count; i++) { - if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0) - goto cleanup; + if (refspecs && refspecs->count > 0) { + for (i = 0; i < refspecs->count; i++) { + if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0) + goto cleanup; + } + } else { + git_vector_foreach(&remote->refspecs, i, spec) { + if (!spec->push) + continue; + if ((error = git_push_add_refspec(push, spec->string)) < 0) + goto cleanup; + } } cbs = &remote->callbacks; -- cgit v1.2.1