diff options
author | Ben Straub <bs@github.com> | 2012-11-08 21:29:17 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2012-11-09 10:33:16 -0800 |
commit | 90207709a367ef07ecf4087f285d3017031401ab (patch) | |
tree | a87b9038a0b3e3ce972b5384dccb40dded24e727 | |
parent | 11fabe73a07ba7c5ef4a713d71b3643c9b0970db (diff) | |
download | libgit2-90207709a367ef07ecf4087f285d3017031401ab.tar.gz |
Avoid copying duplicate commits
-rw-r--r-- | src/transports/local.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index 8b3a2d481..436ac435a 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -263,6 +263,7 @@ static int local_download_pack( git_oid oid; git_packbuilder *pack = NULL; git_odb_writepack *writepack = NULL; + git_odb *odb = NULL; if ((error = git_revwalk_new(&walk, t->repo)) < 0) goto cleanup; @@ -295,10 +296,15 @@ static int local_download_pack( } /* 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) { git_commit *commit; + /* Skip commits we already have */ + if (git_odb_exists(odb, &oid)) continue; + stats->total_objects++; 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); - - { - 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; - } + if ((error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) < 0) + goto cleanup; /* Write the data to the ODB */ { |