git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] tag.c: use the correct algorithm for the '--contains' option

From
Karthik Nayak <karthik.188@gmail.com>
Date
Oct 18, 2015, 10:25 UTC
Message-ID
<1445163904-24611-1-git-send-email-Karthik.188@gmail.com>

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()'.

Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Tested-by: Jerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 builtin/tag.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/tag.c b/builtin/tag.c
index 977a18c..2c5a9f1 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -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);
 
-- 
2.6.1
Message 1 of 1 in “tag.c: use the correct algorithm for the '--contains' option”
  1. tag.c: use the correct algorithm for the '--contains' optionKarthik Nayak, Oct 18, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.