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
ac5e507c
Commit
ac5e507c
authored
Nov 01, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1918 from libgit2/cmn/indexer-naming
indexer: remove the stream infix
parents
b22593fb
a6154f21
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
85 deletions
+85
-85
examples/network/index-pack.c
+6
-6
include/git2/indexer.h
+8
-8
include/git2/odb_backend.h
+1
-1
src/indexer.c
+26
-26
src/odb_pack.c
+7
-7
src/pack-objects.c
+7
-7
src/transports/local.c
+1
-1
src/transports/smart_protocol.c
+2
-2
tests-clar/pack/indexer.c
+15
-15
tests-clar/pack/packbuilder.c
+12
-12
No files found.
examples/network/index-pack.c
View file @
ac5e507c
...
...
@@ -31,7 +31,7 @@ static int index_cb(const git_transfer_progress *stats, void *data)
int
index_pack
(
git_repository
*
repo
,
int
argc
,
char
**
argv
)
{
git_indexer
_stream
*
idx
;
git_indexer
*
idx
;
git_transfer_progress
stats
=
{
0
,
0
};
int
error
;
char
hash
[
GIT_OID_HEXSZ
+
1
]
=
{
0
};
...
...
@@ -46,7 +46,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
return
EXIT_FAILURE
;
}
if
(
git_indexer_
stream_
new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
)
<
0
)
{
if
(
git_indexer_new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
)
<
0
)
{
puts
(
"bad idx"
);
return
-
1
;
}
...
...
@@ -61,7 +61,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
if
(
read_bytes
<
0
)
break
;
if
((
error
=
git_indexer_
stream_ad
d
(
idx
,
buf
,
read_bytes
,
&
stats
))
<
0
)
if
((
error
=
git_indexer_
appen
d
(
idx
,
buf
,
read_bytes
,
&
stats
))
<
0
)
goto
cleanup
;
index_cb
(
&
stats
,
NULL
);
...
...
@@ -73,16 +73,16 @@ int index_pack(git_repository *repo, int argc, char **argv)
goto
cleanup
;
}
if
((
error
=
git_indexer_
stream_finalize
(
idx
,
&
stats
))
<
0
)
if
((
error
=
git_indexer_
commit
(
idx
,
&
stats
))
<
0
)
goto
cleanup
;
printf
(
"
\r
Indexing %d of %d
\n
"
,
stats
.
indexed_objects
,
stats
.
total_objects
);
git_oid_fmt
(
hash
,
git_indexer_
stream_
hash
(
idx
));
git_oid_fmt
(
hash
,
git_indexer_hash
(
idx
));
puts
(
hash
);
cleanup:
close
(
fd
);
git_indexer_
stream_
free
(
idx
);
git_indexer_free
(
idx
);
return
error
;
}
include/git2/indexer.h
View file @
ac5e507c
...
...
@@ -13,10 +13,10 @@
GIT_BEGIN_DECL
typedef
struct
git_indexer
_stream
git_indexer_stream
;
typedef
struct
git_indexer
git_indexer
;
/**
* Create a new
streaming
indexer instance
* Create a new indexer instance
*
* @param out where to store the indexer instance
* @param path to the directory where the packfile should be stored
...
...
@@ -26,8 +26,8 @@ typedef struct git_indexer_stream git_indexer_stream;
* @param progress_cb function to call with progress information
* @param progress_cb_payload payload for the progress callback
*/
GIT_EXTERN
(
int
)
git_indexer_
stream_
new
(
git_indexer
_stream
**
out
,
GIT_EXTERN
(
int
)
git_indexer_new
(
git_indexer
**
out
,
const
char
*
path
,
git_odb
*
odb
,
git_transfer_progress_callback
progress_cb
,
...
...
@@ -41,7 +41,7 @@ GIT_EXTERN(int) git_indexer_stream_new(
* @param size the size of the data in bytes
* @param stats stat storage
*/
GIT_EXTERN
(
int
)
git_indexer_
stream_add
(
git_indexer_stream
*
idx
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
);
GIT_EXTERN
(
int
)
git_indexer_
append
(
git_indexer
*
idx
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
);
/**
* Finalize the pack and index
...
...
@@ -50,7 +50,7 @@ GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data
*
* @param idx the indexer
*/
GIT_EXTERN
(
int
)
git_indexer_
stream_finalize
(
git_indexer_stream
*
idx
,
git_transfer_progress
*
stats
);
GIT_EXTERN
(
int
)
git_indexer_
commit
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
);
/**
* Get the packfile's hash
...
...
@@ -60,14 +60,14 @@ GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_transfe
*
* @param idx the indexer instance
*/
GIT_EXTERN
(
const
git_oid
*
)
git_indexer_
stream_hash
(
const
git_indexer_stream
*
idx
);
GIT_EXTERN
(
const
git_oid
*
)
git_indexer_
hash
(
const
git_indexer
*
idx
);
/**
* Free the indexer and its resources
*
* @param idx the indexer to free
*/
GIT_EXTERN
(
void
)
git_indexer_
stream_free
(
git_indexer_stream
*
idx
);
GIT_EXTERN
(
void
)
git_indexer_
free
(
git_indexer
*
idx
);
GIT_END_DECL
...
...
include/git2/odb_backend.h
View file @
ac5e507c
...
...
@@ -116,7 +116,7 @@ struct git_odb_stream {
struct
git_odb_writepack
{
git_odb_backend
*
backend
;
int
(
*
a
d
d
)(
git_odb_writepack
*
writepack
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
);
int
(
*
a
ppen
d
)(
git_odb_writepack
*
writepack
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
);
int
(
*
commit
)(
git_odb_writepack
*
writepack
,
git_transfer_progress
*
stats
);
void
(
*
free
)(
git_odb_writepack
*
writepack
);
};
...
...
src/indexer.c
View file @
ac5e507c
...
...
@@ -29,7 +29,7 @@ struct entry {
uint64_t
offset_long
;
};
struct
git_indexer
_stream
{
struct
git_indexer
{
unsigned
int
parsed_header
:
1
,
opened_pack
:
1
,
have_stream
:
1
,
...
...
@@ -63,7 +63,7 @@ struct delta_info {
git_off_t
delta_off
;
};
const
git_oid
*
git_indexer_
stream_hash
(
const
git_indexer_stream
*
idx
)
const
git_oid
*
git_indexer_
hash
(
const
git_indexer
*
idx
)
{
return
&
idx
->
hash
;
}
...
...
@@ -116,19 +116,19 @@ static int objects_cmp(const void *a, const void *b)
return
git_oid__cmp
(
&
entrya
->
oid
,
&
entryb
->
oid
);
}
int
git_indexer_
stream_
new
(
git_indexer
_stream
**
out
,
int
git_indexer_new
(
git_indexer
**
out
,
const
char
*
prefix
,
git_odb
*
odb
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
)
{
git_indexer
_stream
*
idx
;
git_indexer
*
idx
;
git_buf
path
=
GIT_BUF_INIT
;
static
const
char
suff
[]
=
"/pack"
;
int
error
;
idx
=
git__calloc
(
1
,
sizeof
(
git_indexer
_stream
));
idx
=
git__calloc
(
1
,
sizeof
(
git_indexer
));
GITERR_CHECK_ALLOC
(
idx
);
idx
->
odb
=
odb
;
idx
->
progress_cb
=
progress_cb
;
...
...
@@ -156,7 +156,7 @@ cleanup:
}
/* Try to store the delta so we can try to resolve it later */
static
int
store_delta
(
git_indexer
_stream
*
idx
)
static
int
store_delta
(
git_indexer
*
idx
)
{
struct
delta_info
*
delta
;
...
...
@@ -179,7 +179,7 @@ static void hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type)
git_hash_update
(
ctx
,
buffer
,
hdrlen
);
}
static
int
hash_object_stream
(
git_indexer
_stream
*
idx
,
git_packfile_stream
*
stream
)
static
int
hash_object_stream
(
git_indexer
*
idx
,
git_packfile_stream
*
stream
)
{
ssize_t
read
;
...
...
@@ -199,7 +199,7 @@ static int hash_object_stream(git_indexer_stream *idx, git_packfile_stream *stre
}
/* In order to create the packfile stream, we need to skip over the delta base description */
static
int
advance_delta_offset
(
git_indexer
_stream
*
idx
,
git_otype
type
)
static
int
advance_delta_offset
(
git_indexer
*
idx
,
git_otype
type
)
{
git_mwindow
*
w
=
NULL
;
...
...
@@ -218,7 +218,7 @@ static int advance_delta_offset(git_indexer_stream *idx, git_otype type)
}
/* Read from the stream and discard any output */
static
int
read_object_stream
(
git_indexer
_stream
*
idx
,
git_packfile_stream
*
stream
)
static
int
read_object_stream
(
git_indexer
*
idx
,
git_packfile_stream
*
stream
)
{
ssize_t
read
;
...
...
@@ -258,7 +258,7 @@ static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start,
return
0
;
}
static
int
store_object
(
git_indexer
_stream
*
idx
)
static
int
store_object
(
git_indexer
*
idx
)
{
int
i
,
error
;
khiter_t
k
;
...
...
@@ -316,7 +316,7 @@ on_error:
return
-
1
;
}
static
int
save_entry
(
git_indexer
_stream
*
idx
,
struct
entry
*
entry
,
struct
git_pack_entry
*
pentry
,
git_off_t
entry_start
)
static
int
save_entry
(
git_indexer
*
idx
,
struct
entry
*
entry
,
struct
git_pack_entry
*
pentry
,
git_off_t
entry_start
)
{
int
i
,
error
;
khiter_t
k
;
...
...
@@ -346,7 +346,7 @@ static int save_entry(git_indexer_stream *idx, struct entry *entry, struct git_p
return
0
;
}
static
int
hash_and_save
(
git_indexer
_stream
*
idx
,
git_rawobj
*
obj
,
git_off_t
entry_start
)
static
int
hash_and_save
(
git_indexer
*
idx
,
git_rawobj
*
obj
,
git_off_t
entry_start
)
{
git_oid
oid
;
size_t
entry_size
;
...
...
@@ -380,14 +380,14 @@ on_error:
return
-
1
;
}
static
int
do_progress_callback
(
git_indexer
_stream
*
idx
,
git_transfer_progress
*
stats
)
static
int
do_progress_callback
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
)
{
if
(
!
idx
->
progress_cb
)
return
0
;
return
idx
->
progress_cb
(
stats
,
idx
->
progress_payload
);
}
/* Hash everything but the last 20B of input */
static
void
hash_partially
(
git_indexer
_stream
*
idx
,
const
uint8_t
*
data
,
size_t
size
)
static
void
hash_partially
(
git_indexer
*
idx
,
const
uint8_t
*
data
,
size_t
size
)
{
size_t
to_expell
,
to_keep
;
...
...
@@ -423,7 +423,7 @@ static void hash_partially(git_indexer_stream *idx, const uint8_t *data, size_t
idx
->
inbuf_len
+=
size
-
to_expell
;
}
int
git_indexer_
stream_add
(
git_indexer_stream
*
idx
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
)
int
git_indexer_
append
(
git_indexer
*
idx
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
)
{
int
error
=
-
1
;
size_t
processed
;
...
...
@@ -583,7 +583,7 @@ on_error:
return
error
;
}
static
int
index_path
_stream
(
git_buf
*
path
,
git_indexer_stream
*
idx
,
const
char
*
suffix
)
static
int
index_path
(
git_buf
*
path
,
git_indexer
*
idx
,
const
char
*
suffix
)
{
const
char
prefix
[]
=
"pack-"
;
size_t
slash
=
(
size_t
)
path
->
size
;
...
...
@@ -609,7 +609,7 @@ static int index_path_stream(git_buf *path, git_indexer_stream *idx, const char
* Rewind the packfile by the trailer, as we might need to fix the
* packfile by injecting objects at the tail and must overwrite it.
*/
static
git_off_t
seek_back_trailer
(
git_indexer
_stream
*
idx
)
static
git_off_t
seek_back_trailer
(
git_indexer
*
idx
)
{
git_off_t
off
;
...
...
@@ -622,7 +622,7 @@ static git_off_t seek_back_trailer(git_indexer_stream *idx)
return
off
;
}
static
int
inject_object
(
git_indexer
_stream
*
idx
,
git_oid
*
id
)
static
int
inject_object
(
git_indexer
*
idx
,
git_oid
*
id
)
{
git_odb_object
*
obj
;
struct
entry
*
entry
;
...
...
@@ -684,7 +684,7 @@ cleanup:
return
error
;
}
static
int
fix_thin_pack
(
git_indexer
_stream
*
idx
,
git_transfer_progress
*
stats
)
static
int
fix_thin_pack
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
)
{
int
error
,
found_ref_delta
=
0
;
unsigned
int
i
;
...
...
@@ -741,7 +741,7 @@ static int fix_thin_pack(git_indexer_stream *idx, git_transfer_progress *stats)
return
0
;
}
static
int
resolve_deltas
(
git_indexer
_stream
*
idx
,
git_transfer_progress
*
stats
)
static
int
resolve_deltas
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
)
{
unsigned
int
i
;
struct
delta_info
*
delta
;
...
...
@@ -784,7 +784,7 @@ static int resolve_deltas(git_indexer_stream *idx, git_transfer_progress *stats)
return
0
;
}
static
int
update_header_and_rehash
(
git_indexer
_stream
*
idx
,
git_transfer_progress
*
stats
)
static
int
update_header_and_rehash
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
)
{
void
*
ptr
;
size_t
chunk
=
1024
*
1024
;
...
...
@@ -833,7 +833,7 @@ static int update_header_and_rehash(git_indexer_stream *idx, git_transfer_progre
return
0
;
}
int
git_indexer_
stream_finalize
(
git_indexer_stream
*
idx
,
git_transfer_progress
*
stats
)
int
git_indexer_
commit
(
git_indexer
*
idx
,
git_transfer_progress
*
stats
)
{
git_mwindow
*
w
=
NULL
;
unsigned
int
i
,
long_offsets
=
0
,
left
;
...
...
@@ -965,7 +965,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
git_filebuf_write
(
&
index_file
,
&
trailer_hash
,
sizeof
(
git_oid
));
/* Figure out what the final name should be */
if
(
index_path
_stream
(
&
filename
,
idx
,
".idx"
)
<
0
)
if
(
index_path
(
&
filename
,
idx
,
".idx"
)
<
0
)
goto
on_error
;
/* Commit file */
...
...
@@ -977,7 +977,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
p_close
(
idx
->
pack
->
mwf
.
fd
);
idx
->
pack
->
mwf
.
fd
=
-
1
;
if
(
index_path
_stream
(
&
filename
,
idx
,
".pack"
)
<
0
)
if
(
index_path
(
&
filename
,
idx
,
".pack"
)
<
0
)
goto
on_error
;
/* And don't forget to rename the packfile to its new place. */
if
(
git_filebuf_commit_at
(
&
idx
->
pack_file
,
filename
.
ptr
,
GIT_PACK_FILE_MODE
)
<
0
)
...
...
@@ -994,7 +994,7 @@ on_error:
return
-
1
;
}
void
git_indexer_
stream_free
(
git_indexer_stream
*
idx
)
void
git_indexer_
free
(
git_indexer
*
idx
)
{
khiter_t
k
;
unsigned
int
i
;
...
...
src/odb_pack.c
View file @
ac5e507c
...
...
@@ -29,7 +29,7 @@ struct pack_backend {
struct
pack_writepack
{
struct
git_odb_writepack
parent
;
git_indexer
_stream
*
indexer_stream
;
git_indexer
*
indexer
;
};
/**
...
...
@@ -511,13 +511,13 @@ static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb c
return
0
;
}
static
int
pack_backend__writepack_a
d
d
(
struct
git_odb_writepack
*
_writepack
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
)
static
int
pack_backend__writepack_a
ppen
d
(
struct
git_odb_writepack
*
_writepack
,
const
void
*
data
,
size_t
size
,
git_transfer_progress
*
stats
)
{
struct
pack_writepack
*
writepack
=
(
struct
pack_writepack
*
)
_writepack
;
assert
(
writepack
);
return
git_indexer_
stream_add
(
writepack
->
indexer_stream
,
data
,
size
,
stats
);
return
git_indexer_
append
(
writepack
->
indexer
,
data
,
size
,
stats
);
}
static
int
pack_backend__writepack_commit
(
struct
git_odb_writepack
*
_writepack
,
git_transfer_progress
*
stats
)
...
...
@@ -526,7 +526,7 @@ static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack,
assert
(
writepack
);
return
git_indexer_
stream_finalize
(
writepack
->
indexer_stream
,
stats
);
return
git_indexer_
commit
(
writepack
->
indexer
,
stats
);
}
static
void
pack_backend__writepack_free
(
struct
git_odb_writepack
*
_writepack
)
...
...
@@ -535,7 +535,7 @@ static void pack_backend__writepack_free(struct git_odb_writepack *_writepack)
assert
(
writepack
);
git_indexer_
stream_free
(
writepack
->
indexer_stream
);
git_indexer_
free
(
writepack
->
indexer
);
git__free
(
writepack
);
}
...
...
@@ -557,14 +557,14 @@ static int pack_backend__writepack(struct git_odb_writepack **out,
writepack
=
git__calloc
(
1
,
sizeof
(
struct
pack_writepack
));
GITERR_CHECK_ALLOC
(
writepack
);
if
(
git_indexer_
stream_new
(
&
writepack
->
indexer_stream
,
if
(
git_indexer_
new
(
&
writepack
->
indexer
,
backend
->
pack_folder
,
odb
,
progress_cb
,
progress_payload
)
<
0
)
{
git__free
(
writepack
);
return
-
1
;
}
writepack
->
parent
.
backend
=
_backend
;
writepack
->
parent
.
a
dd
=
pack_backend__writepack_ad
d
;
writepack
->
parent
.
a
ppend
=
pack_backend__writepack_appen
d
;
writepack
->
parent
.
commit
=
pack_backend__writepack_commit
;
writepack
->
parent
.
free
=
pack_backend__writepack_free
;
...
...
src/pack-objects.c
View file @
ac5e507c
...
...
@@ -35,7 +35,7 @@ struct tree_walk_context {
};
struct
pack_write_context
{
git_indexer
_stream
*
indexer
;
git_indexer
*
indexer
;
git_transfer_progress
*
stats
;
};
...
...
@@ -1241,7 +1241,7 @@ int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb)
static
int
write_cb
(
void
*
buf
,
size_t
len
,
void
*
payload
)
{
struct
pack_write_context
*
ctx
=
payload
;
return
git_indexer_
stream_ad
d
(
ctx
->
indexer
,
buf
,
len
,
ctx
->
stats
);
return
git_indexer_
appen
d
(
ctx
->
indexer
,
buf
,
len
,
ctx
->
stats
);
}
int
git_packbuilder_write
(
...
...
@@ -1250,13 +1250,13 @@ int git_packbuilder_write(
git_transfer_progress_callback
progress_cb
,
void
*
progress_cb_payload
)
{
git_indexer
_stream
*
indexer
;
git_indexer
*
indexer
;
git_transfer_progress
stats
;
struct
pack_write_context
ctx
;
PREPARE_PACK
;
if
(
git_indexer_
stream_
new
(
if
(
git_indexer_new
(
&
indexer
,
path
,
pb
->
odb
,
progress_cb
,
progress_cb_payload
)
<
0
)
return
-
1
;
...
...
@@ -1264,12 +1264,12 @@ int git_packbuilder_write(
ctx
.
stats
=
&
stats
;
if
(
git_packbuilder_foreach
(
pb
,
write_cb
,
&
ctx
)
<
0
||
git_indexer_
stream_finalize
(
indexer
,
&
stats
)
<
0
)
{
git_indexer_
stream_
free
(
indexer
);
git_indexer_
commit
(
indexer
,
&
stats
)
<
0
)
{
git_indexer_free
(
indexer
);
return
-
1
;
}
git_indexer_
stream_
free
(
indexer
);
git_indexer_free
(
indexer
);
return
0
;
}
...
...
src/transports/local.c
View file @
ac5e507c
...
...
@@ -459,7 +459,7 @@ static int foreach_cb(void *buf, size_t len, void *payload)
foreach_data
*
data
=
(
foreach_data
*
)
payload
;
data
->
stats
->
received_bytes
+=
len
;
return
data
->
writepack
->
a
d
d
(
data
->
writepack
,
buf
,
len
,
data
->
stats
);
return
data
->
writepack
->
a
ppen
d
(
data
->
writepack
,
buf
,
len
,
data
->
stats
);
}
static
int
local_download_pack
(
...
...
src/transports/smart_protocol.c
View file @
ac5e507c
...
...
@@ -429,7 +429,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
return
GIT_EUSER
;
}
if
(
writepack
->
a
d
d
(
writepack
,
buf
->
data
,
buf
->
offset
,
stats
)
<
0
)
if
(
writepack
->
a
ppen
d
(
writepack
,
buf
->
data
,
buf
->
offset
,
stats
)
<
0
)
return
-
1
;
gitno_consume_n
(
buf
,
buf
->
offset
);
...
...
@@ -544,7 +544,7 @@ int git_smart__download_pack(
git__free
(
pkt
);
}
else
if
(
pkt
->
type
==
GIT_PKT_DATA
)
{
git_pkt_data
*
p
=
(
git_pkt_data
*
)
pkt
;
error
=
writepack
->
a
d
d
(
writepack
,
p
->
data
,
p
->
len
,
stats
);
error
=
writepack
->
a
ppen
d
(
writepack
,
p
->
data
,
p
->
len
,
stats
);
git__free
(
pkt
);
if
(
error
<
0
)
...
...
tests-clar/pack/indexer.c
View file @
ac5e507c
...
...
@@ -45,23 +45,23 @@ unsigned int base_obj_len = 2;
void
test_pack_indexer__out_of_order
(
void
)
{
git_indexer
_stream
*
idx
;
git_indexer
*
idx
;
git_transfer_progress
stats
;
cl_git_pass
(
git_indexer_
stream_
new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_
stream_ad
d
(
idx
,
out_of_order_pack
,
out_of_order_pack_len
,
&
stats
));
cl_git_pass
(
git_indexer_
stream_finalize
(
idx
,
&
stats
));
cl_git_pass
(
git_indexer_new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_
appen
d
(
idx
,
out_of_order_pack
,
out_of_order_pack_len
,
&
stats
));
cl_git_pass
(
git_indexer_
commit
(
idx
,
&
stats
));
cl_assert_equal_i
(
stats
.
total_objects
,
3
);
cl_assert_equal_i
(
stats
.
received_objects
,
3
);
cl_assert_equal_i
(
stats
.
indexed_objects
,
3
);
git_indexer_
stream_
free
(
idx
);
git_indexer_free
(
idx
);
}
void
test_pack_indexer__fix_thin
(
void
)
{
git_indexer
_stream
*
idx
;
git_indexer
*
idx
;
git_transfer_progress
stats
;
git_repository
*
repo
;
git_odb
*
odb
;
...
...
@@ -75,9 +75,9 @@ void test_pack_indexer__fix_thin(void)
git_oid_fromstr
(
&
should_id
,
"e68fe8129b546b101aee9510c5328e7f21ca1d18"
);
cl_assert
(
!
git_oid_cmp
(
&
id
,
&
should_id
));
cl_git_pass
(
git_indexer_
stream_
new
(
&
idx
,
"."
,
odb
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_
stream_ad
d
(
idx
,
thin_pack
,
thin_pack_len
,
&
stats
));
cl_git_pass
(
git_indexer_
stream_finalize
(
idx
,
&
stats
));
cl_git_pass
(
git_indexer_new
(
&
idx
,
"."
,
odb
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_
appen
d
(
idx
,
thin_pack
,
thin_pack_len
,
&
stats
));
cl_git_pass
(
git_indexer_
commit
(
idx
,
&
stats
));
cl_assert_equal_i
(
stats
.
total_objects
,
2
);
cl_assert_equal_i
(
stats
.
received_objects
,
2
);
...
...
@@ -85,9 +85,9 @@ void test_pack_indexer__fix_thin(void)
cl_assert_equal_i
(
stats
.
local_objects
,
1
);
git_oid_fromstr
(
&
should_id
,
"11f0f69b334728fdd8bc86b80499f22f29d85b15"
);
cl_assert
(
!
git_oid_cmp
(
git_indexer_
stream_
hash
(
idx
),
&
should_id
));
cl_assert
(
!
git_oid_cmp
(
git_indexer_hash
(
idx
),
&
should_id
));
git_indexer_
stream_
free
(
idx
);
git_indexer_free
(
idx
);
git_odb_free
(
odb
);
git_repository_free
(
repo
);
...
...
@@ -110,19 +110,19 @@ void test_pack_indexer__fix_thin(void)
cl_git_pass
(
p_stat
(
name
,
&
st
));
left
=
st
.
st_size
;
cl_git_pass
(
git_indexer_
stream_
new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
read
=
p_read
(
fd
,
buffer
,
sizeof
(
buffer
));
cl_assert
(
read
!=
-
1
);
p_close
(
fd
);
cl_git_pass
(
git_indexer_
stream_ad
d
(
idx
,
buffer
,
read
,
&
stats
));
cl_git_pass
(
git_indexer_
stream_finalize
(
idx
,
&
stats
));
cl_git_pass
(
git_indexer_
appen
d
(
idx
,
buffer
,
read
,
&
stats
));
cl_git_pass
(
git_indexer_
commit
(
idx
,
&
stats
));
cl_assert_equal_i
(
stats
.
total_objects
,
3
);
cl_assert_equal_i
(
stats
.
received_objects
,
3
);
cl_assert_equal_i
(
stats
.
indexed_objects
,
3
);
cl_assert_equal_i
(
stats
.
local_objects
,
0
);
git_indexer_
stream_
free
(
idx
);
git_indexer_free
(
idx
);
}
}
tests-clar/pack/packbuilder.c
View file @
ac5e507c
...
...
@@ -8,7 +8,7 @@
static
git_repository
*
_repo
;
static
git_revwalk
*
_revwalker
;
static
git_packbuilder
*
_packbuilder
;
static
git_indexer
_stream
*
_indexer
;
static
git_indexer
*
_indexer
;
static
git_vector
_commits
;
static
int
_commits_is_initialized
;
...
...
@@ -40,7 +40,7 @@ void test_pack_packbuilder__cleanup(void)
git_revwalk_free
(
_revwalker
);
_revwalker
=
NULL
;
git_indexer_
stream_
free
(
_indexer
);
git_indexer_free
(
_indexer
);
_indexer
=
NULL
;
cl_git_sandbox_cleanup
();
...
...
@@ -79,7 +79,7 @@ static int feed_indexer(void *ptr, size_t len, void *payload)
{
git_transfer_progress
*
stats
=
(
git_transfer_progress
*
)
payload
;
return
git_indexer_
stream_ad
d
(
_indexer
,
ptr
,
len
,
stats
);
return
git_indexer_
appen
d
(
_indexer
,
ptr
,
len
,
stats
);
}
void
test_pack_packbuilder__create_pack
(
void
)
...
...
@@ -92,11 +92,11 @@ void test_pack_packbuilder__create_pack(void)
seed_packbuilder
();
cl_git_pass
(
git_indexer_
stream_
new
(
&
_indexer
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_new
(
&
_indexer
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_packbuilder_foreach
(
_packbuilder
,
feed_indexer
,
&
stats
));
cl_git_pass
(
git_indexer_
stream_finalize
(
_indexer
,
&
stats
));
cl_git_pass
(
git_indexer_
commit
(
_indexer
,
&
stats
));
git_oid_fmt
(
hex
,
git_indexer_
stream_
hash
(
_indexer
));
git_oid_fmt
(
hex
,
git_indexer_hash
(
_indexer
));
git_buf_printf
(
&
path
,
"pack-%s.pack"
,
hex
);
/*
...
...
@@ -131,18 +131,18 @@ void test_pack_packbuilder__create_pack(void)
static
git_transfer_progress
stats
;
static
int
foreach_cb
(
void
*
buf
,
size_t
len
,
void
*
payload
)
{
git_indexer
_stream
*
idx
=
(
git_indexer_stream
*
)
payload
;
cl_git_pass
(
git_indexer_
stream_ad
d
(
idx
,
buf
,
len
,
&
stats
));
git_indexer
*
idx
=
(
git_indexer
*
)
payload
;
cl_git_pass
(
git_indexer_
appen
d
(
idx
,
buf
,
len
,
&
stats
));
return
0
;
}
void
test_pack_packbuilder__foreach
(
void
)
{
git_indexer
_stream
*
idx
;
git_indexer
*
idx
;
seed_packbuilder
();
cl_git_pass
(
git_indexer_
stream_
new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_indexer_new
(
&
idx
,
"."
,
NULL
,
NULL
,
NULL
));
cl_git_pass
(
git_packbuilder_foreach
(
_packbuilder
,
foreach_cb
,
idx
));
cl_git_pass
(
git_indexer_
stream_finalize
(
idx
,
&
stats
));
git_indexer_
stream_
free
(
idx
);
cl_git_pass
(
git_indexer_
commit
(
idx
,
&
stats
));
git_indexer_free
(
idx
);
}
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