Commit 709768a8 by Chris Hescock

Don't fetch objects we don't need in local transport.

Hide all local refs in the revwalk.
Packbuilder should not add hidden trees or blobs.
parent 42864e58
...@@ -1641,7 +1641,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) ...@@ -1641,7 +1641,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0)
return error; return error;
if (obj->seen) if (obj->seen || obj->uninteresting)
return 0; return 0;
obj->seen = 1; obj->seen = 1;
...@@ -1665,6 +1665,10 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) ...@@ -1665,6 +1665,10 @@ int insert_tree(git_packbuilder *pb, git_tree *tree)
break; break;
case GIT_OBJ_BLOB: case GIT_OBJ_BLOB:
if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0)
return error;
if (obj->uninteresting)
continue;
name = git_tree_entry_name(entry); name = git_tree_entry_name(entry);
if ((error = git_packbuilder_insert(pb, entry_id, name)) < 0) if ((error = git_packbuilder_insert(pb, entry_id, name)) < 0)
return error; return error;
......
...@@ -503,6 +503,21 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v ...@@ -503,6 +503,21 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v
return error; return error;
} }
static int foreach_reference_cb(git_reference *reference, void *payload)
{
git_revwalk *walk = (git_revwalk *)payload;
int error = git_revwalk_hide(walk, git_reference_target(reference));
/* The reference is in the local repository, so the target may not
* exist on the remote. It also may not be a commit. */
if (error == GIT_ENOTFOUND || error == GITERR_INVALID) {
giterr_clear();
error = 0;
}
return error;
}
static int local_download_pack( static int local_download_pack(
git_transport *transport, git_transport *transport,
git_repository *repo, git_repository *repo,
...@@ -542,11 +557,6 @@ static int local_download_pack( ...@@ -542,11 +557,6 @@ static int local_download_pack(
if (git_object_type(obj) == GIT_OBJ_COMMIT) { if (git_object_type(obj) == GIT_OBJ_COMMIT) {
/* Revwalker includes only wanted commits */ /* Revwalker includes only wanted commits */
error = git_revwalk_push(walk, &rhead->oid); error = git_revwalk_push(walk, &rhead->oid);
if (!error && !git_oid_iszero(&rhead->loid)) {
error = git_revwalk_hide(walk, &rhead->loid);
if (error == GIT_ENOTFOUND)
error = 0;
}
} else { } else {
/* Tag or some other wanted object. Add it on its own */ /* Tag or some other wanted object. Add it on its own */
error = git_packbuilder_insert_recur(pack, &rhead->oid, rhead->name); error = git_packbuilder_insert_recur(pack, &rhead->oid, rhead->name);
...@@ -556,6 +566,9 @@ static int local_download_pack( ...@@ -556,6 +566,9 @@ static int local_download_pack(
goto cleanup; goto cleanup;
} }
if ((error = git_reference_foreach(repo, foreach_reference_cb, walk)))
goto cleanup;
if ((error = git_packbuilder_insert_walk(pack, walk))) if ((error = git_packbuilder_insert_walk(pack, walk)))
goto cleanup; goto cleanup;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment