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
1e3b8ed5
Commit
1e3b8ed5
authored
Oct 24, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 'bytes' param from git_remote_download
parent
9762ad99
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
12 additions
and
29 deletions
+12
-29
examples/network/fetch.c
+3
-6
include/git2/remote.h
+0
-3
src/clone.c
+1
-2
src/fetch.c
+4
-10
src/fetch.h
+0
-2
src/remote.c
+2
-3
src/transport.h
+1
-1
tests-clar/network/fetch.c
+1
-2
No files found.
examples/network/fetch.c
View file @
1e3b8ed5
...
...
@@ -8,7 +8,6 @@
struct
dl_data
{
git_remote
*
remote
;
git_off_t
*
bytes
;
int
ret
;
int
finished
;
};
...
...
@@ -34,7 +33,7 @@ static void *download(void *ptr)
// Download the packfile and index it. This function updates the
// amount of received data and the indexer stats which lets you
// inform the user about progress.
if
(
git_remote_download
(
data
->
remote
,
data
->
bytes
,
NULL
,
NULL
)
<
0
)
{
if
(
git_remote_download
(
data
->
remote
,
NULL
,
NULL
)
<
0
)
{
data
->
ret
=
-
1
;
goto
exit
;
}
...
...
@@ -68,7 +67,6 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
int
fetch
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
{
git_remote
*
remote
=
NULL
;
git_off_t
bytes
=
0
;
const
git_transfer_progress
*
stats
;
pthread_t
worker
;
struct
dl_data
data
;
...
...
@@ -90,7 +88,6 @@ int fetch(git_repository *repo, int argc, char **argv)
// Set up the information for the background worker thread
data
.
remote
=
remote
;
data
.
bytes
=
&
bytes
;
data
.
ret
=
0
;
data
.
finished
=
0
;
...
...
@@ -108,7 +105,7 @@ int fetch(git_repository *repo, int argc, char **argv)
if
(
stats
->
total_objects
>
0
)
printf
(
"Received %d/%d objects (%d) in %d bytes
\r
"
,
stats
->
received_objects
,
stats
->
total_objects
,
stats
->
indexed_objects
,
bytes
);
stats
->
indexed_objects
,
stats
->
received_
bytes
);
}
while
(
!
data
.
finished
);
if
(
data
.
ret
<
0
)
...
...
@@ -116,7 +113,7 @@ int fetch(git_repository *repo, int argc, char **argv)
pthread_join
(
worker
,
NULL
);
printf
(
"
\r
Received %d/%d objects in %zu bytes
\n
"
,
stats
->
indexed_objects
,
stats
->
total_objects
,
bytes
);
stats
->
indexed_objects
,
stats
->
total_objects
,
stats
->
received_
bytes
);
// Disconnect the underlying connection to prevent from idling.
git_remote_disconnect
(
remote
);
...
...
include/git2/remote.h
View file @
1e3b8ed5
...
...
@@ -183,8 +183,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
* filename will be NULL and the function will return success.
*
* @param remote the remote to download from
* @param bytes buffer that receives the number of bytes transferred (updated
* while transfer is in progress)
* @param progress_cb function to call with progress information. Be aware that
* this is called inline with network and indexing operations, so performance
* may be affected.
...
...
@@ -193,7 +191,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
*/
GIT_EXTERN
(
int
)
git_remote_download
(
git_remote
*
remote
,
git_off_t
*
bytes
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
);
...
...
src/clone.c
View file @
1e3b8ed5
...
...
@@ -256,13 +256,12 @@ static int setup_remotes_and_fetch(
{
int
retcode
=
GIT_ERROR
;
git_remote
*
origin
=
NULL
;
git_off_t
bytes
=
0
;
/* Create the "origin" remote */
if
(
!
git_remote_add
(
&
origin
,
repo
,
GIT_REMOTE_ORIGIN
,
origin_url
))
{
/* Connect and download everything */
if
(
!
git_remote_connect
(
origin
,
GIT_DIR_FETCH
))
{
if
(
!
git_remote_download
(
origin
,
&
bytes
,
progress_cb
,
progress_payload
))
{
if
(
!
git_remote_download
(
origin
,
progress_cb
,
progress_payload
))
{
/* Create "origin/foo" branches for all remote branches */
if
(
!
git_remote_update_tips
(
origin
))
{
/* Point HEAD to the same ref as the remote's head */
...
...
src/fetch.c
View file @
1e3b8ed5
...
...
@@ -306,7 +306,6 @@ on_error:
int
git_fetch_download_pack
(
git_remote
*
remote
,
git_off_t
*
bytes
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
)
{
...
...
@@ -316,14 +315,14 @@ int git_fetch_download_pack(
return
0
;
if
(
t
->
own_logic
)
return
t
->
download_pack
(
t
,
remote
->
repo
,
bytes
,
&
remote
->
stats
);
return
t
->
download_pack
(
t
,
remote
->
repo
,
&
remote
->
stats
);
return
git_fetch__download_pack
(
t
,
remote
->
repo
,
bytes
,
&
remote
->
stats
,
return
git_fetch__download_pack
(
t
,
remote
->
repo
,
&
remote
->
stats
,
progress_cb
,
progress_payload
);
}
static
int
no_sideband
(
git_transport
*
t
,
git_indexer_stream
*
idx
,
gitno_buffer
*
buf
,
git_
off_t
*
bytes
,
git_
transfer_progress
*
stats
)
static
int
no_sideband
(
git_transport
*
t
,
git_indexer_stream
*
idx
,
gitno_buffer
*
buf
,
git_transfer_progress
*
stats
)
{
int
recvd
;
...
...
@@ -340,8 +339,6 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *
if
((
recvd
=
gitno_recv
(
buf
))
<
0
)
return
-
1
;
*
bytes
+=
recvd
;
}
while
(
recvd
>
0
);
if
(
git_indexer_stream_finalize
(
idx
,
stats
))
...
...
@@ -376,7 +373,6 @@ static void network_packetsize(int received, void *payload)
int
git_fetch__download_pack
(
git_transport
*
t
,
git_repository
*
repo
,
git_off_t
*
bytes
,
git_transfer_progress
*
stats
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
)
...
...
@@ -403,7 +399,6 @@ int git_fetch__download_pack(
git_buf_free
(
&
path
);
memset
(
stats
,
0
,
sizeof
(
git_transfer_progress
));
*
bytes
=
0
;
/*
* If the remote doesn't support the side-band, we can feed
...
...
@@ -411,7 +406,7 @@ int git_fetch__download_pack(
* check which one belongs there.
*/
if
(
!
t
->
caps
.
side_band
&&
!
t
->
caps
.
side_band_64k
)
{
if
(
no_sideband
(
t
,
idx
,
buf
,
bytes
,
stats
)
<
0
)
if
(
no_sideband
(
t
,
idx
,
buf
,
stats
)
<
0
)
goto
on_error
;
git_indexer_stream_free
(
idx
);
...
...
@@ -438,7 +433,6 @@ int git_fetch__download_pack(
git__free
(
pkt
);
}
else
if
(
pkt
->
type
==
GIT_PKT_DATA
)
{
git_pkt_data
*
p
=
(
git_pkt_data
*
)
pkt
;
*
bytes
+=
p
->
len
;
if
(
git_indexer_stream_add
(
idx
,
p
->
data
,
p
->
len
,
stats
)
<
0
)
goto
on_error
;
...
...
src/fetch.h
View file @
1e3b8ed5
...
...
@@ -13,14 +13,12 @@ int git_fetch_negotiate(git_remote *remote);
int
git_fetch_download_pack
(
git_remote
*
remote
,
git_off_t
*
bytes
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
);
int
git_fetch__download_pack
(
git_transport
*
t
,
git_repository
*
repo
,
git_off_t
*
bytes
,
git_transfer_progress
*
stats
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
);
...
...
src/remote.c
View file @
1e3b8ed5
...
...
@@ -435,18 +435,17 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
int
git_remote_download
(
git_remote
*
remote
,
git_off_t
*
bytes
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
)
{
int
error
;
assert
(
remote
&&
bytes
);
assert
(
remote
);
if
((
error
=
git_fetch_negotiate
(
remote
))
<
0
)
return
error
;
return
git_fetch_download_pack
(
remote
,
bytes
,
progress_cb
,
progress_payload
);
return
git_fetch_download_pack
(
remote
,
progress_cb
,
progress_payload
);
}
int
git_remote_update_tips
(
git_remote
*
remote
)
...
...
src/transport.h
View file @
1e3b8ed5
...
...
@@ -113,7 +113,7 @@ struct git_transport {
/**
* Download the packfile
*/
int
(
*
download_pack
)(
struct
git_transport
*
transport
,
git_repository
*
repo
,
git_
off_t
*
bytes
,
git_
transfer_progress
*
stats
);
int
(
*
download_pack
)(
struct
git_transport
*
transport
,
git_repository
*
repo
,
git_transfer_progress
*
stats
);
/**
* Close the connection
*/
...
...
tests-clar/network/fetch.c
View file @
1e3b8ed5
...
...
@@ -38,7 +38,6 @@ static void progress(const git_transfer_progress *stats, void *payload)
static
void
do_fetch
(
const
char
*
url
,
int
flag
,
int
n
)
{
git_remote
*
remote
;
git_off_t
bytes
;
git_remote_callbacks
callbacks
;
bool
progress_was_called
=
false
;
...
...
@@ -50,7 +49,7 @@ static void do_fetch(const char *url, int flag, int n)
git_remote_set_callbacks
(
remote
,
&
callbacks
);
git_remote_set_autotag
(
remote
,
flag
);
cl_git_pass
(
git_remote_connect
(
remote
,
GIT_DIR_FETCH
));
cl_git_pass
(
git_remote_download
(
remote
,
&
bytes
,
progress
,
&
progress_was_called
));
cl_git_pass
(
git_remote_download
(
remote
,
progress
,
&
progress_was_called
));
git_remote_disconnect
(
remote
);
cl_git_pass
(
git_remote_update_tips
(
remote
));
cl_assert_equal_i
(
counter
,
n
);
...
...
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