mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 20:14:44 +00:00
Avoid copying duplicate commits
This commit is contained in:
parent
11fabe73a0
commit
90207709a3
@ -263,6 +263,7 @@ static int local_download_pack(
|
|||||||
git_oid oid;
|
git_oid oid;
|
||||||
git_packbuilder *pack = NULL;
|
git_packbuilder *pack = NULL;
|
||||||
git_odb_writepack *writepack = NULL;
|
git_odb_writepack *writepack = NULL;
|
||||||
|
git_odb *odb = NULL;
|
||||||
|
|
||||||
if ((error = git_revwalk_new(&walk, t->repo)) < 0)
|
if ((error = git_revwalk_new(&walk, t->repo)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -295,10 +296,15 @@ static int local_download_pack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Walk the objects, building a packfile */
|
/* Walk the objects, building a packfile */
|
||||||
|
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
while ((error = git_revwalk_next(&oid, walk)) == 0) {
|
while ((error = git_revwalk_next(&oid, walk)) == 0) {
|
||||||
git_commit *commit;
|
git_commit *commit;
|
||||||
|
|
||||||
|
/* Skip commits we already have */
|
||||||
|
if (git_odb_exists(odb, &oid)) continue;
|
||||||
|
|
||||||
stats->total_objects++;
|
stats->total_objects++;
|
||||||
|
|
||||||
if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
|
if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
|
||||||
@ -313,13 +319,8 @@ static int local_download_pack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (progress_cb) progress_cb(stats, progress_payload);
|
if (progress_cb) progress_cb(stats, progress_payload);
|
||||||
|
if ((error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) < 0)
|
||||||
{
|
goto cleanup;
|
||||||
git_odb *odb;
|
|
||||||
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
|
|
||||||
(error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write the data to the ODB */
|
/* Write the data to the ODB */
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user