mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-27 23:50:08 +00:00
Merge pull request #1918 from libgit2/cmn/indexer-naming
indexer: remove the stream infix
This commit is contained in:
commit
ac5e507cec
@ -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_add(idx, buf, read_bytes, &stats)) < 0)
|
||||
if ((error = git_indexer_append(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("\rIndexing %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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -116,7 +116,7 @@ struct git_odb_stream {
|
||||
struct git_odb_writepack {
|
||||
git_odb_backend *backend;
|
||||
|
||||
int (*add)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
|
||||
int (*append)(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);
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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_add(struct git_odb_writepack *_writepack, const void *data, size_t size, git_transfer_progress *stats)
|
||||
static int pack_backend__writepack_append(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.add = pack_backend__writepack_add;
|
||||
writepack->parent.append = pack_backend__writepack_append;
|
||||
writepack->parent.commit = pack_backend__writepack_commit;
|
||||
writepack->parent.free = pack_backend__writepack_free;
|
||||
|
||||
|
@ -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_add(ctx->indexer, buf, len, ctx->stats);
|
||||
return git_indexer_append(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;
|
||||
}
|
||||
|
||||
|
@ -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->add(data->writepack, buf, len, data->stats);
|
||||
return data->writepack->append(data->writepack, buf, len, data->stats);
|
||||
}
|
||||
|
||||
static int local_download_pack(
|
||||
|
@ -429,7 +429,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
|
||||
return GIT_EUSER;
|
||||
}
|
||||
|
||||
if (writepack->add(writepack, buf->data, buf->offset, stats) < 0)
|
||||
if (writepack->append(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->add(writepack, p->data, p->len, stats);
|
||||
error = writepack->append(writepack, p->data, p->len, stats);
|
||||
|
||||
git__free(pkt);
|
||||
if (error < 0)
|
||||
|
@ -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_add(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_append(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_add(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_append(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_add(idx, buffer, read, &stats));
|
||||
cl_git_pass(git_indexer_stream_finalize(idx, &stats));
|
||||
cl_git_pass(git_indexer_append(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);
|
||||
}
|
||||
}
|
||||
|
@ -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_add(_indexer, ptr, len, stats);
|
||||
return git_indexer_append(_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_add(idx, buf, len, &stats));
|
||||
git_indexer *idx = (git_indexer *) payload;
|
||||
cl_git_pass(git_indexer_append(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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user