Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2021-04-12 16:37:35 +0300
committerJunio C Hamano <gitster@pobox.com>2021-04-12 19:35:50 +0300
commit9a2a4f95448890d138a800c8a55c5d5dcfe16082 (patch)
tree9c3c3df9c336ad1f733ba78831ba7ee61be66139 /list-objects.c
parent628d81be6c007de5aa0fa352b912b89f74a5cfa7 (diff)
list-objects: support filtering by tag and commit
Object filters currently only support filtering blobs or trees based on some criteria. This commit lays the foundation to also allow filtering of tags and commits. No change in behaviour is expected from this commit given that there are no filters yet for those object types. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects.c')
-rw-r--r--list-objects.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/list-objects.c b/list-objects.c
index a5a60301cb..7f404677d5 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -217,8 +217,15 @@ static void process_tag(struct traversal_context *ctx,
struct tag *tag,
const char *name)
{
- tag->object.flags |= SEEN;
- ctx->show_object(&tag->object, name, ctx->show_data);
+ enum list_objects_filter_result r;
+
+ r = list_objects_filter__filter_object(ctx->revs->repo, LOFS_TAG,
+ &tag->object, NULL, NULL,
+ ctx->filter);
+ if (r & LOFR_MARK_SEEN)
+ tag->object.flags |= SEEN;
+ if (r & LOFR_DO_SHOW)
+ ctx->show_object(&tag->object, name, ctx->show_data);
}
static void mark_edge_parents_uninteresting(struct commit *commit,
@@ -368,6 +375,12 @@ static void do_traverse(struct traversal_context *ctx)
strbuf_init(&csp, PATH_MAX);
while ((commit = get_revision(ctx->revs)) != NULL) {
+ enum list_objects_filter_result r;
+
+ r = list_objects_filter__filter_object(ctx->revs->repo,
+ LOFS_COMMIT, &commit->object,
+ NULL, NULL, ctx->filter);
+
/*
* an uninteresting boundary commit may not have its tree
* parsed yet, but we are not going to show them anyway
@@ -382,7 +395,11 @@ static void do_traverse(struct traversal_context *ctx)
die(_("unable to load root tree for commit %s"),
oid_to_hex(&commit->object.oid));
}
- ctx->show_commit(commit, ctx->show_data);
+
+ if (r & LOFR_MARK_SEEN)
+ commit->object.flags |= SEEN;
+ if (r & LOFR_DO_SHOW)
+ ctx->show_commit(commit, ctx->show_data);
if (ctx->revs->tree_blobs_in_commit_order)
/*