libgit2 icon indicating copy to clipboard operation
libgit2 copied to clipboard

add callback before a remote connects and add a callback before a remote will be disconnected

Open Murmele opened this issue 2 years ago • 6 comments

Problem Description: When updating submodules, the remote of the submodule is not visible outside of the submodule (submodule is a private type and therefore not intended to be used outside). So in that case it is not possible to abort an update operation by aborting the remote connection.

Benefit: If during the submodule update (fetch, ...) a callback will be called, outside of the submodule the remote is available. This remote can be stored and if the application wants to abort the operation it just stops the operation on that remote.

from #5730 In this particular case, I added the connect/disconnect callbacks because I needed to remember the remote to cancel the transfer later on. This is most important in submodule update, which looks up the remotes internally. Without this, there isn't a way to cancel the transfers initiated by submodule update.

Murmele avatar May 09 '22 14:05 Murmele

TODO: Maybe it is possible to just define the disconnect and the remote_ready_cb can be used instead of the connect

Murmele avatar May 09 '22 14:05 Murmele

Why git_remote_ready_cb remote_ready; is not defined as GIT_CALLBACK()?

Murmele avatar May 09 '22 15:05 Murmele

Why git_remote_ready_cb remote_ready; is not defined as GIT_CALLBACK()?

It is - https://github.com/libgit2/libgit2/blob/258df9c18d4876ad59a2cfa9d78a313f867d633e/include/git2/remote.h#L538 ? 🤔

ethomson avatar May 09 '22 15:05 ethomson

Why git_remote_ready_cb remote_ready; is not defined as GIT_CALLBACK()?

It is -

https://github.com/libgit2/libgit2/blob/258df9c18d4876ad59a2cfa9d78a313f867d633e/include/git2/remote.h#L538 ? 🤔

Ah I haven't seen this thanks. Is this the way it should be added to the struct? So I will change it for my callbacks too

Murmele avatar May 09 '22 17:05 Murmele

Current error in the tests: "remote error: The unauthenticated git protocol on port 9418 is no longer supported. Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information. "

TODO: use a different repo, because fetching libgit2 takes quite long.

@ethomson which repo do you propose?

Murmele avatar May 10 '22 18:05 Murmele

@ethomson

Murmele avatar Jun 12 '22 06:06 Murmele