pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

"this operation is only valid for push"

Open trivee opened this issue 2 years ago • 1 comments

The sequence of calls

remote.ls_remotes(...) remote.fetch(...) remote.push(...)

works, while

remote.ls_remotes(...) remote.push(...)

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.

trivee avatar Feb 03 '23 22:02 trivee

The same issue here without calling ls-remotes, just push to origin remote after cloning repository.

krautcat avatar Apr 08 '24 04:04 krautcat