Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
9267ff58
Commit
9267ff58
authored
Nov 29, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy GIT_REMOTE_CALLBACKS_INIT
parent
55f6f21b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
7 deletions
+24
-7
examples/network/fetch.c
+1
-2
include/git2/remote.h
+2
-1
src/remote.c
+18
-1
tests-clar/network/fetch.c
+1
-2
tests-clar/network/push_util.h
+2
-1
No files found.
examples/network/fetch.c
View file @
9267ff58
...
...
@@ -70,7 +70,7 @@ int fetch(git_repository *repo, int argc, char **argv)
const
git_transfer_progress
*
stats
;
pthread_t
worker
;
struct
dl_data
data
;
git_remote_callbacks
callbacks
;
git_remote_callbacks
callbacks
=
GIT_REMOTE_CALLBACKS_INIT
;
argc
=
argc
;
// Figure out whether it's a named remote or a URL
...
...
@@ -81,7 +81,6 @@ int fetch(git_repository *repo, int argc, char **argv)
}
// Set up the callbacks (only update_tips for now)
memset
(
&
callbacks
,
0
,
sizeof
(
callbacks
));
callbacks
.
update_tips
=
&
update_cb
;
callbacks
.
progress
=
&
progress_cb
;
git_remote_set_callbacks
(
remote
,
&
callbacks
);
...
...
include/git2/remote.h
View file @
9267ff58
...
...
@@ -356,8 +356,9 @@ struct git_remote_callbacks {
*
* @param remote the remote to configure
* @param callbacks a pointer to the user's callback settings
* @return 0 or an error code
*/
GIT_EXTERN
(
void
)
git_remote_set_callbacks
(
git_remote
*
remote
,
git_remote_callbacks
*
callbacks
);
GIT_EXTERN
(
int
)
git_remote_set_callbacks
(
git_remote
*
remote
,
git_remote_callbacks
*
callbacks
);
/**
* Get the statistics structure that is filled in by the fetch operation.
...
...
src/remote.c
View file @
9267ff58
...
...
@@ -985,10 +985,25 @@ void git_remote_check_cert(git_remote *remote, int check)
remote
->
check_cert
=
check
;
}
void
git_remote_set_callbacks
(
git_remote
*
remote
,
git_remote_callbacks
*
callbacks
)
static
bool
callbacks_have_valid_version
(
git_remote_callbacks
*
callbacks
)
{
if
(
!
callbacks
)
return
true
;
if
(
callbacks
->
version
>
0
&&
callbacks
->
version
<=
GIT_REMOTE_CALLBACKS_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d for git_remote_callbacks"
,
callbacks
->
version
);
return
false
;
}
int
git_remote_set_callbacks
(
git_remote
*
remote
,
git_remote_callbacks
*
callbacks
)
{
assert
(
remote
&&
callbacks
);
if
(
!
callbacks_have_valid_version
(
callbacks
))
return
-
1
;
memcpy
(
&
remote
->
callbacks
,
callbacks
,
sizeof
(
git_remote_callbacks
));
if
(
remote
->
transport
&&
remote
->
transport
->
set_callbacks
)
...
...
@@ -996,6 +1011,8 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
remote
->
callbacks
.
progress
,
NULL
,
remote
->
callbacks
.
payload
);
return
0
;
}
void
git_remote_set_cred_acquire_cb
(
...
...
tests-clar/network/fetch.c
View file @
9267ff58
...
...
@@ -36,10 +36,9 @@ static void progress(const git_transfer_progress *stats, void *payload)
static
void
do_fetch
(
const
char
*
url
,
git_remote_autotag_option_t
flag
,
int
n
)
{
git_remote
*
remote
;
git_remote_callbacks
callbacks
;
git_remote_callbacks
callbacks
=
GIT_REMOTE_CALLBACKS_INIT
;
size_t
bytes_received
=
0
;
memset
(
&
callbacks
,
0
,
sizeof
(
git_remote_callbacks
));
callbacks
.
update_tips
=
update_tips
;
counter
=
0
;
...
...
tests-clar/network/push_util.h
View file @
9267ff58
...
...
@@ -11,7 +11,8 @@ extern const git_oid OID_ZERO;
* record data in a record_callbacks_data instance.
* @param data pointer to a record_callbacks_data instance
*/
#define RECORD_CALLBACKS_INIT(data) { NULL, NULL, record_update_tips_cb, data }
#define RECORD_CALLBACKS_INIT(data) \
{ GIT_REMOTE_CALLBACKS_VERSION, NULL, NULL, record_update_tips_cb, data }
typedef
struct
{
char
*
name
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment