summaryrefslogtreecommitdiff
path: root/src/remote.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-08-27 10:59:51 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-08-29 10:39:28 -0400
commit72df17c659619707e4e5f27b2a51db60848a1d04 (patch)
treea89dda4f75833c96669446c94fd7e0ff56f19fff /src/remote.c
parent672406773e677e69dba0ccf1c6a116cb2886b60a (diff)
downloadlibgit2-72df17c659619707e4e5f27b2a51db60848a1d04.tar.gz
remote: introduce git_remote_ready_cb
Introduce a new callback that fires when the remote is ready to connect.
Diffstat (limited to 'src/remote.c')
-rw-r--r--src/remote.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/remote.c b/src/remote.c
index 236f39aba..8050e65f3 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -709,11 +709,19 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
GIT_ASSERT_ARG(remote);
GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
- if (direction == GIT_DIRECTION_FETCH) {
+ if (callbacks && callbacks->remote_ready) {
+ int status = callbacks->remote_ready(remote, direction, callbacks->payload);
+
+ if (status != 0 && status != GIT_PASSTHROUGH) {
+ git_error_set_after_callback_function(status, "git_remote_ready_cb");
+ return status;
+ }
+ }
+
+ if (direction == GIT_DIRECTION_FETCH)
url = remote->url;
- } else if (direction == GIT_DIRECTION_PUSH) {
+ else if (direction == GIT_DIRECTION_PUSH)
url = remote->pushurl ? remote->pushurl : remote->url;
- }
if (!url) {
git_error_set(GIT_ERROR_INVALID,
@@ -722,6 +730,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
return GIT_EINVALID;
}
+
return resolve_url(url_out, url, direction, callbacks);
}