mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 09:28:59 +00:00
indexer: clearer stats for thin packs
Don't increase the number of total objects, as it can produce suprising progress output. The only addition compared to pre-thin is the addition of local_objects to allow an output similar to git's "completed with %d local objects".
This commit is contained in:
parent
7fb6eb278b
commit
893055f22e
@ -212,6 +212,13 @@ typedef struct git_remote_callbacks git_remote_callbacks;
|
||||
/**
|
||||
* This is passed as the first argument to the callback to allow the
|
||||
* user to see the progress.
|
||||
*
|
||||
* - total_objects: number of objects in the packfile being downloaded
|
||||
* - indexed_objects: received objects that have been hashed
|
||||
* - received_objects: objects which have been downloaded
|
||||
* - local_objects: locally-available objects that have been injected
|
||||
* in order to fix a thin pack.
|
||||
* - received-bytes: size of the packfile received up to now
|
||||
*/
|
||||
typedef struct git_transfer_progress {
|
||||
unsigned int total_objects;
|
||||
|
@ -733,7 +733,6 @@ static int fix_thin_pack(git_indexer_stream *idx, git_transfer_progress *stats)
|
||||
if (inject_object(idx, &base) < 0)
|
||||
return -1;
|
||||
|
||||
stats->total_objects++;
|
||||
stats->local_objects++;
|
||||
|
||||
return 0;
|
||||
@ -798,7 +797,7 @@ static int update_header_and_rehash(git_indexer_stream *idx, git_transfer_progre
|
||||
git_mwindow_free_all(mwf);
|
||||
|
||||
/* Update the header to include the numer of local objects we injected */
|
||||
idx->hdr.hdr_entries = htonl(stats->total_objects);
|
||||
idx->hdr.hdr_entries = htonl(stats->total_objects + stats->local_objects);
|
||||
if (p_lseek(idx->pack_file.fd, 0, SEEK_SET) < 0) {
|
||||
giterr_set(GITERR_OS, "failed to seek to the beginning of the pack");
|
||||
return -1;
|
||||
@ -870,7 +869,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
|
||||
if (resolve_deltas(idx, stats) < 0)
|
||||
return -1;
|
||||
|
||||
if (stats->indexed_objects + stats->local_objects != stats->total_objects) {
|
||||
if (stats->indexed_objects != stats->total_objects) {
|
||||
giterr_set(GITERR_INDEXER, "early EOF");
|
||||
return -1;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void test_pack_indexer__fix_thin(void)
|
||||
cl_git_pass(git_indexer_stream_add(idx, thin_pack, thin_pack_len, &stats));
|
||||
cl_git_pass(git_indexer_stream_finalize(idx, &stats));
|
||||
|
||||
cl_assert_equal_i(stats.total_objects, 3);
|
||||
cl_assert_equal_i(stats.total_objects, 2);
|
||||
cl_assert_equal_i(stats.received_objects, 2);
|
||||
cl_assert_equal_i(stats.indexed_objects, 2);
|
||||
cl_assert_equal_i(stats.local_objects, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user