Skip to contentSkip to conversation

tag.c: use the correct algorithm for the '--contains' option

PATCH New Karthik Nayak 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tag.c: use the correct algorithm for the '--contains' option

In b7cc53e92c806b73e14b03f60c17b7c29e52b4a4 we port tag.c to use ref-filter APIs for filtering and printing refs. In ref-filter we have two implementations for filtering refs when the '--contains' option is used. Although they do the same thing, one is optimized for filtering branches and the other for tags (borrowed from branch.c and tag.c respectively) and the 'filter->with_commit_tag_algo' bit decides which algorithm must be used. Maybe we'd want to unify these eventually.

When we ported tag.c to use ref-filter APIs we missed out on setting the 'filter->with_commit_tag_algo' bit. As reported by Jerry Snitselaar, this causes the '--contains' option to work way slower than expected, fix this by setting 'filter->with_commit_tag_algo' in tag.c before calling 'filter_refs()'.

---
 builtin/tag.c | 1 +
 1 file changed, 1 insertion(+)
builtin/tag.c +1 -0
index 977a18c..2c5a9f1 100644
@@ -49,6 +49,7 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting)
 		format = "%(refname:short)";
 
 	verify_ref_format(format);
+	filter->with_commit_tag_algo = 1;
 	filter_refs(&array, filter, FILTER_REFS_TAGS);
 	ref_array_sort(sorting, &array);
 
Signature · 1 line
2.6.1