summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-04-10 11:38:07 +0200
committerEdward Thomson <ethomson@edwardthomson.com>2015-04-10 11:38:07 +0200
commit623fbd93f1a7538df0c9a433df68f87bbd58b803 (patch)
tree48411be1dd99a979f789107d4de1d0051b93557e /src
parent63af449e24125b050dbad3530c3ec64e2e4ee754 (diff)
parentc84a9dd2da864a975b5dee408e3edaf84422b828 (diff)
downloadlibgit2-623fbd93f1a7538df0c9a433df68f87bbd58b803.tar.gz
Merge pull request #2974 from libgit2/cmn/clone-everything
Make sure to pack referenced objects for non-branches
Diffstat (limited to 'src')
-rw-r--r--src/pack-objects.c36
-rw-r--r--src/transports/local.c3
-rw-r--r--src/tree.c4
3 files changed, 40 insertions, 3 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 0f43b98e0..932764698 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -1404,6 +1404,42 @@ int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
return error;
}
+int git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const char *name)
+{
+ git_object *obj;
+ int error;
+
+ assert(pb && id);
+
+ if ((error = git_object_lookup(&obj, pb->repo, id, GIT_OBJ_ANY)) < 0)
+ return error;
+
+ switch (git_object_type(obj)) {
+ case GIT_OBJ_BLOB:
+ error = git_packbuilder_insert(pb, id, name);
+ break;
+ case GIT_OBJ_TREE:
+ error = git_packbuilder_insert_tree(pb, id);
+ break;
+ case GIT_OBJ_COMMIT:
+ error = git_packbuilder_insert_commit(pb, id);
+ break;
+ case GIT_OBJ_TAG:
+ if ((error = git_packbuilder_insert(pb, id, name)) < 0)
+ goto cleanup;
+ error = git_packbuilder_insert_recur(pb, git_tag_target_id((git_tag *) obj), NULL);
+ break;
+
+ default:
+ giterr_set(GITERR_INVALID, "unknown object type");
+ error = -1;
+ }
+
+cleanup:
+ git_object_free(obj);
+ return error;
+}
+
uint32_t git_packbuilder_object_count(git_packbuilder *pb)
{
return pb->nr_objects;
diff --git a/src/transports/local.c b/src/transports/local.c
index 64ddbd970..def8ac037 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -544,7 +544,8 @@ static int local_download_pack(
error = 0;
}
} else {
- error = git_packbuilder_insert(pack, &rhead->oid, rhead->name);
+ /* Tag or some other wanted object. Add it on its own */
+ error = git_packbuilder_insert_recur(pack, &rhead->oid, rhead->name);
}
git_object_free(obj);
if (error < 0)
diff --git a/src/tree.c b/src/tree.c
index 47ed20dbb..bdd17661b 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -858,7 +858,7 @@ int git_tree_entry_bypath(
if (entry == NULL) {
giterr_set(GITERR_TREE,
- "The path '%s' does not exist in the given tree", path);
+ "the path '%.*s' does not exist in the given tree", filename_len, path);
return GIT_ENOTFOUND;
}
@@ -868,7 +868,7 @@ int git_tree_entry_bypath(
* then this entry *must* be a tree */
if (!git_tree_entry__is_tree(entry)) {
giterr_set(GITERR_TREE,
- "The path '%s' does not exist in the given tree", path);
+ "the path '%.*s' exists but is not a tree", filename_len, path);
return GIT_ENOTFOUND;
}