diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-10-11 12:25:50 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-09 00:01:58 +0100 |
commit | 64e3e6d43acbbf6cc8f8a4c612547c5a575c4031 (patch) | |
tree | 18c5db63b5253a0a1261abc0a9cde9dc3ab51ebb /src/remote.c | |
parent | 6eb9e39ce03e4db1fb39ff9fa8ed771463fca1bd (diff) | |
download | libgit2-cmn/remote-push.tar.gz |
remote: use configured push refspecs if none are givencmn/remote-push
If the user does not pass any refspecs to push, try to use those
configured via the configuration or via add_push().
Diffstat (limited to 'src/remote.c')
-rw-r--r-- | src/remote.c | 16 |
1 files changed, 13 insertions, 3 deletions
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; |