fix 'got fetch' downloading too many objects in some cases Always announce all local references to the server when fetching changes. We used to do this only in mirror mode. In regular mode only refs/tags and refs/remotes/origin were announced, which could result in unnecessary downloads if relevant objects exist in refs/heads or elsewhere.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/lib/fetch.c b/lib/fetch.c
index 5206b45..3b8efe3 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -124,8 +124,6 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
off_t packfile_size = 0;
struct got_packfile_hdr pack_hdr;
uint32_t nobj = 0;
- char *ref_prefix = NULL;
- size_t ref_prefixlen = 0;
char *path;
char *progress = NULL;
@@ -153,13 +151,6 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
TAILQ_INIT(&have_refs);
TAILQ_INIT(&my_refs);
- if (!mirror_references) {
- if (asprintf(&ref_prefix, "refs/remotes/%s/",
- remote_name) == -1)
- return got_error_from_errno("asprintf");
- ref_prefixlen = strlen(ref_prefix);
- }
-
if (!list_refs_only) {
err = got_ref_list(&my_refs, repo, NULL,
got_ref_cmp_by_name, NULL);
@@ -174,60 +165,17 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
if (got_ref_is_symbolic(re->ref))
continue;
- refname = got_ref_get_name(re->ref);
-
- if (mirror_references) {
- char *name;
- err = got_ref_resolve(&id, repo, re->ref);
- if (err)
- goto done;
- name = strdup(refname);
- if (name == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- err = got_pathlist_append(&have_refs, name, id);
- if (err)
- goto done;
- continue;
- }
-
- if (strncmp("refs/tags/", refname, 10) == 0) {
- char *tagname;
-
- err = got_ref_resolve(&id, repo, re->ref);
- if (err)
- goto done;
- tagname = strdup(refname);
- if (tagname == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- err = got_pathlist_append(&have_refs, tagname, id);
- if (err) {
- free(tagname);
- goto done;
- }
- }
-
- if (strncmp(ref_prefix, refname, ref_prefixlen) == 0) {
- char *branchname;
-
- err = got_ref_resolve(&id, repo, re->ref);
- if (err)
- goto done;
-
- if (asprintf(&branchname, "refs/heads/%s",
- refname + ref_prefixlen) == -1) {
- err = got_error_from_errno("asprintf");
- goto done;
- }
- err = got_pathlist_append(&have_refs, branchname, id);
- if (err) {
- free(branchname);
- goto done;
- }
+ err = got_ref_resolve(&id, repo, re->ref);
+ if (err)
+ goto done;
+ refname = strdup(got_ref_get_name(re->ref));
+ if (refname == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
}
+ err = got_pathlist_append(&have_refs, refname, id);
+ if (err)
+ goto done;
}
if (list_refs_only) {
@@ -577,7 +525,6 @@ done:
free(tmpidxpath);
free(idxpath);
free(packpath);
- free(ref_prefix);
free(progress);
TAILQ_FOREACH(pe, &have_refs, entry) {