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
0a1db746
Commit
0a1db746
authored
May 14, 2012
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: add progress output to fetch
parent
e03e71da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
examples/network/fetch.c
+13
-1
No files found.
examples/network/fetch.c
View file @
0a1db746
...
...
@@ -14,6 +14,13 @@ struct dl_data {
int
finished
;
};
static
void
progress_cb
(
const
char
*
str
,
int
len
,
void
*
data
)
{
data
=
data
;
printf
(
"remote: %.*s"
,
len
,
str
);
fflush
(
stdout
);
/* We don't have the \n to force the flush */
}
static
void
*
download
(
void
*
ptr
)
{
struct
dl_data
*
data
=
(
struct
dl_data
*
)
ptr
;
...
...
@@ -43,6 +50,7 @@ exit:
static
int
update_cb
(
const
char
*
refname
,
const
git_oid
*
a
,
const
git_oid
*
b
,
void
*
data
)
{
char
a_str
[
GIT_OID_HEXSZ
+
1
],
b_str
[
GIT_OID_HEXSZ
+
1
];
data
=
data
;
git_oid_fmt
(
b_str
,
b
);
b_str
[
GIT_OID_HEXSZ
]
=
'\0'
;
...
...
@@ -78,6 +86,7 @@ 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
);
// Set up the information for the background worker thread
...
...
@@ -96,7 +105,10 @@ int fetch(git_repository *repo, int argc, char **argv)
// the download rate.
do
{
usleep
(
10000
);
printf
(
"
\r
Received %d/%d objects (%d) in %d bytes"
,
stats
.
received
,
stats
.
total
,
stats
.
processed
,
bytes
);
if
(
stats
.
total
>
0
)
printf
(
"Received %d/%d objects (%d) in %d bytes
\r
"
,
stats
.
received
,
stats
.
total
,
stats
.
processed
,
bytes
);
}
while
(
!
data
.
finished
);
if
(
data
.
ret
<
0
)
...
...
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