Skip to content

Commit 7d08801

Browse files
committed
Revert "remote: introduce git_remote_ready_cb"
This reverts commit 72df17c.
1 parent b7bad55 commit 7d08801

File tree

4 files changed

+4
-74
lines changed

4 files changed

+4
-74
lines changed

include/git2/remote.h

-17
Original file line numberDiff line numberDiff line change
@@ -516,18 +516,6 @@ typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, cons
516516
typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *url, int direction, void *payload);
517517
#endif
518518

519-
/**
520-
* Callback invoked immediately before we attempt to connect to the
521-
* given url. Callers may change the URL before the connection by
522-
* calling `git_remote_set_instance_url` in the callback.
523-
*
524-
* @param remote The remote to be connected
525-
* @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
526-
* @param payload Payload provided by the caller
527-
* @return 0 on success, or an error
528-
*/
529-
typedef int GIT_CALLBACK(git_remote_ready_cb)(git_remote *remote, int direction, void *payload);
530-
531519
/**
532520
* The callback settings structure
533521
*
@@ -612,11 +600,6 @@ struct git_remote_callbacks {
612600
*/
613601
git_transport_cb transport;
614602

615-
/**
616-
* Callback when the remote is ready to connect.
617-
*/
618-
git_remote_ready_cb remote_ready;
619-
620603
/**
621604
* This will be passed to each of the callbacks in this struct
622605
* as the last parameter.

src/remote.c

+3-12
Original file line numberDiff line numberDiff line change
@@ -722,19 +722,11 @@ int git_remote__urlfordirection(
722722
GIT_ASSERT_ARG(remote);
723723
GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
724724

725-
if (callbacks && callbacks->remote_ready) {
726-
int status = callbacks->remote_ready(remote, direction, callbacks->payload);
727-
728-
if (status != 0 && status != GIT_PASSTHROUGH) {
729-
git_error_set_after_callback_function(status, "git_remote_ready_cb");
730-
return status;
731-
}
732-
}
733-
734-
if (direction == GIT_DIRECTION_FETCH)
725+
if (direction == GIT_DIRECTION_FETCH) {
735726
url = remote->url;
736-
else if (direction == GIT_DIRECTION_PUSH)
727+
} else if (direction == GIT_DIRECTION_PUSH) {
737728
url = remote->pushurl ? remote->pushurl : remote->url;
729+
}
738730

739731
if (!url) {
740732
git_error_set(GIT_ERROR_INVALID,
@@ -743,7 +735,6 @@ int git_remote__urlfordirection(
743735
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
744736
return GIT_EINVALID;
745737
}
746-
747738
return resolve_url(url_out, url, direction, callbacks);
748739
}
749740

tests/network/remote/remotes.c

-44
Original file line numberDiff line numberDiff line change
@@ -56,49 +56,6 @@ void test_network_remote_remotes__parsing(void)
5656
git_buf_dispose(&url);
5757
}
5858

59-
static int remote_ready_callback(git_remote *remote, int direction, void *payload)
60-
{
61-
if (direction == GIT_DIRECTION_PUSH) {
62-
const char *url = git_remote_pushurl(remote);
63-
64-
cl_assert_equal_p(url, NULL);;
65-
cl_assert_equal_s(payload, "payload");
66-
return git_remote_set_instance_pushurl(remote, "push_url");
67-
}
68-
69-
if (direction == GIT_DIRECTION_FETCH) {
70-
const char *url = git_remote_url(remote);
71-
72-
cl_assert_equal_s(url, "git://github.com/libgit2/libgit2");
73-
cl_assert_equal_s(payload, "payload");
74-
return git_remote_set_instance_url(remote, "fetch_url");
75-
}
76-
77-
return -1;
78-
}
79-
80-
void test_network_remote_remotes__remote_ready(void)
81-
{
82-
git_buf url = GIT_BUF_INIT;
83-
84-
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
85-
callbacks.remote_ready = remote_ready_callback;
86-
callbacks.payload = "payload";
87-
88-
cl_assert_equal_s(git_remote_name(_remote), "test");
89-
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
90-
cl_assert(git_remote_pushurl(_remote) == NULL);
91-
92-
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, &callbacks));
93-
cl_assert_equal_s(url.ptr, "fetch_url");
94-
95-
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
96-
cl_assert_equal_s(url.ptr, "push_url");
97-
98-
git_buf_dispose(&url);
99-
}
100-
101-
#ifndef GIT_DEPRECATE_HARD
10259
static int urlresolve_callback(git_buf *url_resolved, const char *url, int direction, void *payload)
10360
{
10461
cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0);
@@ -112,7 +69,6 @@ static int urlresolve_callback(git_buf *url_resolved, const char *url, int direc
11269

11370
return GIT_OK;
11471
}
115-
#endif
11672

11773
void test_network_remote_remotes__urlresolve(void)
11874
{

tests/online/push_util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern const git_oid OID_ZERO;
1212
* @param data pointer to a record_callbacks_data instance
1313
*/
1414
#define RECORD_CALLBACKS_INIT(data) \
15-
{ GIT_REMOTE_CALLBACKS_VERSION, NULL, NULL, cred_acquire_cb, NULL, NULL, record_update_tips_cb, NULL, NULL, NULL, NULL, NULL, NULL, data, NULL }
15+
{ GIT_REMOTE_CALLBACKS_VERSION, NULL, NULL, cred_acquire_cb, NULL, NULL, record_update_tips_cb, NULL, NULL, NULL, NULL, NULL, data, NULL }
1616

1717
typedef struct {
1818
char *name;

0 commit comments

Comments
 (0)