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
52a8a130
Commit
52a8a130
authored
Jan 06, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Packbuilder contains its own zstream
parent
0ade2f7a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
5 deletions
+12
-5
src/pack-objects.c
+4
-5
src/pack-objects.h
+2
-0
src/zstream.c
+5
-0
src/zstream.h
+1
-0
No files found.
src/pack-objects.c
View file @
52a8a130
...
@@ -130,6 +130,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
...
@@ -130,6 +130,7 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
pb
->
nr_threads
=
1
;
/* do not spawn any thread by default */
pb
->
nr_threads
=
1
;
/* do not spawn any thread by default */
if
(
git_hash_ctx_init
(
&
pb
->
ctx
)
<
0
||
if
(
git_hash_ctx_init
(
&
pb
->
ctx
)
<
0
||
git_zstream_init
(
&
pb
->
zstream
)
<
0
||
git_repository_odb
(
&
pb
->
odb
,
repo
)
<
0
||
git_repository_odb
(
&
pb
->
odb
,
repo
)
<
0
||
packbuilder_config
(
pb
)
<
0
)
packbuilder_config
(
pb
)
<
0
)
goto
on_error
;
goto
on_error
;
...
@@ -284,7 +285,6 @@ static int write_object(
...
@@ -284,7 +285,6 @@ static int write_object(
int
(
*
write_cb
)(
void
*
buf
,
size_t
size
,
void
*
cb_data
),
int
(
*
write_cb
)(
void
*
buf
,
size_t
size
,
void
*
cb_data
),
void
*
cb_data
)
void
*
cb_data
)
{
{
git_zstream
zstream
=
GIT_ZSTREAM_INIT
;
git_odb_object
*
obj
=
NULL
;
git_odb_object
*
obj
=
NULL
;
git_otype
type
;
git_otype
type
;
unsigned
char
hdr
[
10
],
*
zbuf
=
NULL
;
unsigned
char
hdr
[
10
],
*
zbuf
=
NULL
;
...
@@ -334,10 +334,9 @@ static int write_object(
...
@@ -334,10 +334,9 @@ static int write_object(
zbuf
=
git__malloc
(
zbuf_len
);
zbuf
=
git__malloc
(
zbuf_len
);
GITERR_CHECK_ALLOC
(
zbuf
);
GITERR_CHECK_ALLOC
(
zbuf
);
if
((
error
=
git_zstream_init
(
&
zstream
))
<
0
)
git_zstream_reset
(
&
pb
->
zstream
);
goto
done
;
while
((
written
=
git_zstream_deflate
(
zbuf
,
zbuf_len
,
&
zstream
,
data
,
data_len
))
>
0
)
{
while
((
written
=
git_zstream_deflate
(
zbuf
,
zbuf_len
,
&
pb
->
zstream
,
data
,
data_len
))
>
0
)
{
if
((
error
=
write_cb
(
zbuf
,
written
,
cb_data
))
<
0
||
if
((
error
=
write_cb
(
zbuf
,
written
,
cb_data
))
<
0
||
(
error
=
git_hash_update
(
&
pb
->
ctx
,
zbuf
,
written
))
<
0
)
(
error
=
git_hash_update
(
&
pb
->
ctx
,
zbuf
,
written
))
<
0
)
goto
done
;
goto
done
;
...
@@ -364,7 +363,6 @@ static int write_object(
...
@@ -364,7 +363,6 @@ static int write_object(
done:
done:
git__free
(
zbuf
);
git__free
(
zbuf
);
git_zstream_free
(
&
zstream
);
git_odb_object_free
(
obj
);
git_odb_object_free
(
obj
);
return
error
;
return
error
;
}
}
...
@@ -1413,6 +1411,7 @@ void git_packbuilder_free(git_packbuilder *pb)
...
@@ -1413,6 +1411,7 @@ void git_packbuilder_free(git_packbuilder *pb)
git__free
(
pb
->
object_list
);
git__free
(
pb
->
object_list
);
git_hash_ctx_cleanup
(
&
pb
->
ctx
);
git_hash_ctx_cleanup
(
&
pb
->
ctx
);
git_zstream_free
(
&
pb
->
zstream
);
git__free
(
pb
);
git__free
(
pb
);
}
}
src/pack-objects.h
View file @
52a8a130
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "hash.h"
#include "hash.h"
#include "oidmap.h"
#include "oidmap.h"
#include "netops.h"
#include "netops.h"
#include "zstream.h"
#include "git2/oid.h"
#include "git2/oid.h"
#include "git2/pack.h"
#include "git2/pack.h"
...
@@ -54,6 +55,7 @@ struct git_packbuilder {
...
@@ -54,6 +55,7 @@ struct git_packbuilder {
git_odb
*
odb
;
/* associated object database */
git_odb
*
odb
;
/* associated object database */
git_hash_ctx
ctx
;
git_hash_ctx
ctx
;
git_zstream
zstream
;
uint32_t
nr_objects
,
uint32_t
nr_objects
,
nr_alloc
,
nr_alloc
,
...
...
src/zstream.c
View file @
52a8a130
...
@@ -52,6 +52,11 @@ ssize_t git_zstream_deflate(void *out, size_t out_len, git_zstream *zstream, con
...
@@ -52,6 +52,11 @@ ssize_t git_zstream_deflate(void *out, size_t out_len, git_zstream *zstream, con
return
(
out_len
-
zstream
->
avail_out
);
return
(
out_len
-
zstream
->
avail_out
);
}
}
void
git_zstream_reset
(
git_zstream
*
zstream
)
{
deflateReset
(
zstream
);
}
void
git_zstream_free
(
git_zstream
*
zstream
)
void
git_zstream_free
(
git_zstream
*
zstream
)
{
{
deflateEnd
(
zstream
);
deflateEnd
(
zstream
);
...
...
src/zstream.h
View file @
52a8a130
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
int
git_zstream_init
(
git_zstream
*
zstream
);
int
git_zstream_init
(
git_zstream
*
zstream
);
ssize_t
git_zstream_deflate
(
void
*
out
,
size_t
out_len
,
git_zstream
*
zstream
,
const
void
*
in
,
size_t
in_len
);
ssize_t
git_zstream_deflate
(
void
*
out
,
size_t
out_len
,
git_zstream
*
zstream
,
const
void
*
in
,
size_t
in_len
);
void
git_zstream_reset
(
git_zstream
*
zstream
);
void
git_zstream_free
(
git_zstream
*
zstream
);
void
git_zstream_free
(
git_zstream
*
zstream
);
int
git_zstream_deflatebuf
(
git_buf
*
out
,
const
void
*
in
,
size_t
in_len
);
int
git_zstream_deflatebuf
(
git_buf
*
out
,
const
void
*
in
,
size_t
in_len
);
...
...
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