int git_remote_dup(git_remote **dest, git_remote *source) { int error = 0; git_strarray refspecs = { 0 }; git_remote *remote = git__calloc(1, sizeof(git_remote)); GITERR_CHECK_ALLOC(remote); if (source->name != NULL) { remote->name = git__strdup(source->name); GITERR_CHECK_ALLOC(remote->name); } if (source->url != NULL) { remote->url = git__strdup(source->url); GITERR_CHECK_ALLOC(remote->url); } if (source->pushurl != NULL) { remote->pushurl = git__strdup(source->pushurl); GITERR_CHECK_ALLOC(remote->pushurl); } remote->transport_cb = source->transport_cb; remote->transport_cb_payload = source->transport_cb_payload; remote->repo = source->repo; remote->download_tags = source->download_tags; remote->check_cert = source->check_cert; remote->update_fetchhead = source->update_fetchhead; if (git_vector_init(&remote->refs, 32, NULL) < 0 || git_vector_init(&remote->refspecs, 2, NULL) < 0 || git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { error = -1; goto cleanup; } if ((error = git_remote_get_fetch_refspecs(&refspecs, source)) < 0 || (error = git_remote_set_fetch_refspecs(remote, &refspecs)) < 0) goto cleanup; git_strarray_free(&refspecs); if ((error = git_remote_get_push_refspecs(&refspecs, source)) < 0 || (error = git_remote_set_push_refspecs(remote, &refspecs)) < 0) goto cleanup; *dest = remote; cleanup: git_strarray_free(&refspecs); if (error < 0) git__free(remote); return error; }
int Remote_push_refspecs__set__(Remote *self, PyObject *py_list) { int err; git_strarray push_refspecs; if (get_strarraygit_from_pylist(&push_refspecs, py_list) != 0) return -1; err = git_remote_set_push_refspecs(self->remote, &push_refspecs); git_strarray_free(&push_refspecs); if (err < 0) { Error_set(err); return -1; } return 0; }