diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-11-13 22:37:24 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 22:37:24 +0900 |
| commit | 291123e69babcbbab720705a1bc1e6f0ba3012a4 (patch) | |
| tree | de927178be4e839f7e23b8f05ed56067370744a1 /remote.c | |
| parent | 1961efecae1ef937aa1d571add4eae03a8c8303b (diff) | |
| parent | 85daa01f6b80cb6eb14c5f484a6da9f0b1247143 (diff) | |
| download | git-291123e69babcbbab720705a1bc1e6f0ba3012a4.tar.xz | |
Merge branch 'ds/add-missing-tags'
The history traversal used to implement the tag-following has been
optimized by introducing a new helper.
* ds/add-missing-tags:
remote: make add_missing_tags() linear
test-reach: test get_reachable_subset
commit-reach: implement get_reachable_subset
Diffstat (limited to 'remote.c')
| -rw-r--r-- | remote.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -1205,9 +1205,36 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds * sent to the other side. */ if (sent_tips.nr) { + const int reachable_flag = 1; + struct commit_list *found_commits; + struct commit **src_commits; + int nr_src_commits = 0, alloc_src_commits = 16; + ALLOC_ARRAY(src_commits, alloc_src_commits); + for_each_string_list_item(item, &src_tag) { struct ref *ref = item->util; + struct commit *commit; + + if (is_null_oid(&ref->new_oid)) + continue; + commit = lookup_commit_reference_gently(the_repository, + &ref->new_oid, + 1); + if (!commit) + /* not pushing a commit, which is not an error */ + continue; + + ALLOC_GROW(src_commits, nr_src_commits + 1, alloc_src_commits); + src_commits[nr_src_commits++] = commit; + } + + found_commits = get_reachable_subset(sent_tips.tip, sent_tips.nr, + src_commits, nr_src_commits, + reachable_flag); + + for_each_string_list_item(item, &src_tag) { struct ref *dst_ref; + struct ref *ref = item->util; struct commit *commit; if (is_null_oid(&ref->new_oid)) @@ -1223,7 +1250,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds * Is this tag, which they do not have, reachable from * any of the commits we are sending? */ - if (!in_merge_bases_many(commit, sent_tips.nr, sent_tips.tip)) + if (!(commit->object.flags & reachable_flag)) continue; /* Add it in */ @@ -1231,7 +1258,12 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds oidcpy(&dst_ref->new_oid, &ref->new_oid); dst_ref->peer_ref = copy_ref(ref); } + + clear_commit_marks_many(nr_src_commits, src_commits, reachable_flag); + free(src_commits); + free_commit_list(found_commits); } + string_list_clear(&src_tag, 0); free(sent_tips.tip); } |
