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
9762ad99
Commit
9762ad99
authored
Oct 24, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renaming: fix example
parent
7d222e13
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
examples/network/clone.c
+8
-7
examples/network/fetch.c
+5
-3
examples/network/index-pack.c
+4
-4
No files found.
examples/network/clone.c
View file @
9762ad99
...
...
@@ -8,7 +8,7 @@
#include <unistd.h>
typedef
struct
progress_data
{
git_
indexer_stat
s
fetch_progress
;
git_
transfer_progres
s
fetch_progress
;
size_t
completed_steps
;
size_t
total_steps
;
const
char
*
path
;
...
...
@@ -16,20 +16,21 @@ typedef struct progress_data {
static
void
print_progress
(
const
progress_data
*
pd
)
{
int
network_percent
=
(
100
*
pd
->
fetch_progress
.
received
)
/
pd
->
fetch_progress
.
total
;
int
index_percent
=
(
100
*
pd
->
fetch_progress
.
processed
)
/
pd
->
fetch_progress
.
total
;
int
network_percent
=
(
100
*
pd
->
fetch_progress
.
received
_objects
)
/
pd
->
fetch_progress
.
total_objects
;
int
index_percent
=
(
100
*
pd
->
fetch_progress
.
indexed_objects
)
/
pd
->
fetch_progress
.
total_objects
;
int
checkout_percent
=
pd
->
total_steps
>
0
?
(
100
*
pd
->
completed_steps
)
/
pd
->
total_steps
:
0
.
f
;
int
kbytes
=
pd
->
fetch_progress
.
bytes
/
1024
;
int
kbytes
=
pd
->
fetch_progress
.
received_
bytes
/
1024
;
printf
(
"net %3d%% (%4d kb, %5d/%5d) / idx %3d%% (%5d/%5d) / chk %3d%% (%4lu/%4lu) %s
\n
"
,
network_percent
,
kbytes
,
pd
->
fetch_progress
.
received
,
pd
->
fetch_progress
.
total
,
index_percent
,
pd
->
fetch_progress
.
processed
,
pd
->
fetch_progress
.
total
,
network_percent
,
kbytes
,
pd
->
fetch_progress
.
received_objects
,
pd
->
fetch_progress
.
total_objects
,
index_percent
,
pd
->
fetch_progress
.
indexed_objects
,
pd
->
fetch_progress
.
total_objects
,
checkout_percent
,
pd
->
completed_steps
,
pd
->
total_steps
,
pd
->
path
);
}
static
void
fetch_progress
(
const
git_
indexer_stat
s
*
stats
,
void
*
payload
)
static
void
fetch_progress
(
const
git_
transfer_progres
s
*
stats
,
void
*
payload
)
{
progress_data
*
pd
=
(
progress_data
*
)
payload
;
pd
->
fetch_progress
=
*
stats
;
...
...
examples/network/fetch.c
View file @
9762ad99
...
...
@@ -105,16 +105,18 @@ int fetch(git_repository *repo, int argc, char **argv)
do
{
usleep
(
10000
);
if
(
stats
->
total
>
0
)
if
(
stats
->
total
_objects
>
0
)
printf
(
"Received %d/%d objects (%d) in %d bytes
\r
"
,
stats
->
received
,
stats
->
total
,
stats
->
processed
,
bytes
);
stats
->
received_objects
,
stats
->
total_objects
,
stats
->
indexed_objects
,
bytes
);
}
while
(
!
data
.
finished
);
if
(
data
.
ret
<
0
)
goto
on_error
;
pthread_join
(
worker
,
NULL
);
printf
(
"
\r
Received %d/%d objects in %zu bytes
\n
"
,
stats
->
processed
,
stats
->
total
,
bytes
);
printf
(
"
\r
Received %d/%d objects in %zu bytes
\n
"
,
stats
->
indexed_objects
,
stats
->
total_objects
,
bytes
);
// Disconnect the underlying connection to prevent from idling.
git_remote_disconnect
(
remote
);
...
...
examples/network/index-pack.c
View file @
9762ad99
...
...
@@ -10,10 +10,10 @@
// This could be run in the main loop whilst the application waits for
// the indexing to finish in a worker thread
static
int
index_cb
(
const
git_
indexer_stat
s
*
stats
,
void
*
data
)
static
int
index_cb
(
const
git_
transfer_progres
s
*
stats
,
void
*
data
)
{
data
=
data
;
printf
(
"
\r
Processing %d of %d"
,
stats
->
processed
,
stats
->
total
);
printf
(
"
\r
Processing %d of %d"
,
stats
->
indexed_objects
,
stats
->
total_objects
);
return
0
;
}
...
...
@@ -21,7 +21,7 @@ static int index_cb(const git_indexer_stats *stats, void *data)
int
index_pack
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
{
git_indexer_stream
*
idx
;
git_
indexer_stat
s
stats
=
{
0
,
0
};
git_
transfer_progres
s
stats
=
{
0
,
0
};
int
error
,
fd
;
char
hash
[
GIT_OID_HEXSZ
+
1
]
=
{
0
};
ssize_t
read_bytes
;
...
...
@@ -63,7 +63,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
if
((
error
=
git_indexer_stream_finalize
(
idx
,
&
stats
))
<
0
)
goto
cleanup
;
printf
(
"
\r
Indexing %d of %d
\n
"
,
stats
.
processed
,
stats
.
total
);
printf
(
"
\r
Indexing %d of %d
\n
"
,
stats
.
indexed_objects
,
stats
.
total_objects
);
git_oid_fmt
(
hash
,
git_indexer_stream_hash
(
idx
));
puts
(
hash
);
...
...
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