@@ -14,6 +14,41 @@ namespace git
1414 return git_remote_pushurl (remote_.get ());
1515 }
1616
17+ void Remote::fetch (FetchCallbacks & callbacks, char const * reflog_message)
18+ {
19+ git_fetch_options opts = GIT_FETCH_OPTIONS_INIT ;
20+ opts.callbacks .payload = &callbacks;
21+
22+ opts.callbacks .update_tips = [] (char const * refname, git_oid const * a, git_oid const * b, void * data)
23+ {
24+ auto callbacks = static_cast <FetchCallbacks*>(data);
25+ callbacks->update_tips (refname, *a, *b);
26+ return 0 ;
27+ };
28+ opts.callbacks .sideband_progress = [] (char const * str, int len, void * data)
29+ {
30+ auto callbacks = static_cast <FetchCallbacks*>(data);
31+ callbacks->sideband_progress (str, len);
32+ return 0 ;
33+ };
34+ opts.callbacks .transfer_progress = [] (git_transfer_progress const * stats, void * data)
35+ {
36+ auto callbacks = static_cast <FetchCallbacks*>(data);
37+ callbacks->transfer_progress (*stats);
38+ return 0 ;
39+ };
40+ opts.callbacks .credentials = [] (git_cred ** out, char const *url, char const * user_from_url, unsigned int allowed_types, void * data)
41+ {
42+ auto callbacks = static_cast <FetchCallbacks*>(data);
43+ auto cred = callbacks->acquire_cred (url, user_from_url, allowed_types);
44+ if (!cred)
45+ return -1 ;
46+ *out = cred;
47+ return 0 ;
48+ };
49+ git_remote_fetch (remote_.get (), nullptr , &opts, reflog_message);
50+ }
51+
1752 void Remote::Destroy::operator ()(git_remote * remote) const
1853 {
1954 git_remote_free (remote);
0 commit comments