doesn't, producing the GIT_ERROR_NET / "this operation is only valid for push" error.
I think this is because ls_remotes() explicitly calls connect(..., GIT_DIRECTION_FETCH), and fetch() implicitly calls disconnect() (within git_remote_fetch()). If fetch() is not called between ls_remotes() and push(), git_remote_push() encounters an existing connection with FETCH direction, and returns an error (from git_smart__get_push_stream()).
This could be addressed in several ways: either by disconnecting explicitly in ls_remotes(), or maybe by changing the implementation of connect_or_reset_options() and the functions it calls to handle the case where direction is changing.
The sequence of calls
works, while
doesn't, producing the GIT_ERROR_NET / "this operation is only valid for push" error.
I think this is because ls_remotes() explicitly calls connect(..., GIT_DIRECTION_FETCH), and fetch() implicitly calls disconnect() (within git_remote_fetch()). If fetch() is not called between ls_remotes() and push(), git_remote_push() encounters an existing connection with FETCH direction, and returns an error (from git_smart__get_push_stream()).
This could be addressed in several ways: either by disconnecting explicitly in ls_remotes(), or maybe by changing the implementation of connect_or_reset_options() and the functions it calls to handle the case where direction is changing.