From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Christian Couder" <christian.couder@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Jeff King" <peff@peff.net>,
"Jeff Hostetler" <jeffhost@microsoft.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Derrick Stolee" <derrickstolee@github.com>,
"Johannes Schindelin" <johannes.schindelin@gmx.de>,
"ZheNing Hu" <adlternative@gmail.com>,
"ZheNing Hu" <adlternative@gmail.com>
Subject: [PATCH 2/3] list-object-filter: pass traversal_context in filter_init_fn
Date: Thu, 01 Sep 2022 09:41:11 +0000 [thread overview]
Message-ID: <0df61091c194ed46fda4d70272fcbcfdbedc8770.1662025272.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1343.git.1662025272.gitgitgadget@gmail.com>
From: ZheNing Hu <adlternative@gmail.com>
Pass traversal_context to all filter init functions, so that
we can read or modify the rev_info of traversal_context in the
filter initialization function.
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
---
list-objects-filter.c | 12 ++++++++++--
list-objects-filter.h | 2 ++
list-objects.c | 10 +---------
list-objects.h | 8 ++++++++
4 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 1c1ee3d1bb1..76e8659ea73 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -112,6 +112,7 @@ static enum list_objects_filter_result filter_blobs_none(
}
static void filter_blobs_none__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter)
{
@@ -249,6 +250,7 @@ static void filter_trees_free(void *filter_data) {
}
static void filter_trees_depth__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter)
{
@@ -336,6 +338,7 @@ include_it:
}
static void filter_blobs_limit__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter)
{
@@ -519,6 +522,7 @@ static void filter_sparse_free(void *filter_data)
}
static void filter_sparse_oid__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter)
{
@@ -609,6 +613,7 @@ static enum list_objects_filter_result filter_object_type(
}
static void filter_object_type__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter)
{
@@ -734,6 +739,7 @@ static void filter_combine__finalize_omits(
}
static void filter_combine__init(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter* filter)
{
@@ -744,7 +750,7 @@ static void filter_combine__init(
CALLOC_ARRAY(d->sub, d->nr);
for (sub = 0; sub < d->nr; sub++)
d->sub[sub].filter = list_objects_filter__init(
- filter->omits ? &d->sub[sub].omits : NULL,
+ ctx, filter->omits ? &d->sub[sub].omits : NULL,
&filter_options->sub[sub]);
filter->filter_data = d;
@@ -754,6 +760,7 @@ static void filter_combine__init(
}
typedef void (*filter_init_fn)(
+ struct traversal_context *ctx,
struct list_objects_filter_options *filter_options,
struct filter *filter);
@@ -771,6 +778,7 @@ static filter_init_fn s_filters[] = {
};
struct filter *list_objects_filter__init(
+ struct traversal_context *ctx,
struct oidset *omitted,
struct list_objects_filter_options *filter_options)
{
@@ -792,7 +800,7 @@ struct filter *list_objects_filter__init(
CALLOC_ARRAY(filter, 1);
filter->omits = omitted;
- init_fn(filter_options, filter);
+ init_fn(ctx, filter_options, filter);
return filter;
}
diff --git a/list-objects-filter.h b/list-objects-filter.h
index 9e98814111c..0a3cb500976 100644
--- a/list-objects-filter.h
+++ b/list-objects-filter.h
@@ -5,6 +5,7 @@ struct list_objects_filter_options;
struct object;
struct oidset;
struct repository;
+struct traversal_context;
/*
* During list-object traversal we allow certain objects to be
@@ -72,6 +73,7 @@ struct filter;
* filter *`.
*/
struct filter *list_objects_filter__init(
+ struct traversal_context *ctx,
struct oidset *omitted,
struct list_objects_filter_options *filter_options);
diff --git a/list-objects.c b/list-objects.c
index 250d9de41cb..698e4dbe8ff 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -13,14 +13,6 @@
#include "object-store.h"
#include "trace.h"
-struct traversal_context {
- struct rev_info *revs;
- show_object_fn show_object;
- show_commit_fn show_commit;
- void *show_data;
- struct filter *filter;
-};
-
static void show_commit(struct traversal_context *ctx,
struct commit *commit)
{
@@ -448,7 +440,7 @@ void traverse_commit_list_filtered(
};
if (revs->filter.choice)
- ctx.filter = list_objects_filter__init(omitted, &revs->filter);
+ ctx.filter = list_objects_filter__init(&ctx, omitted, &revs->filter);
do_traverse(&ctx);
diff --git a/list-objects.h b/list-objects.h
index 9eaf4de8449..44c598e9ce8 100644
--- a/list-objects.h
+++ b/list-objects.h
@@ -16,6 +16,14 @@ void mark_edges_uninteresting(struct rev_info *revs,
struct oidset;
struct list_objects_filter_options;
+struct traversal_context {
+ struct rev_info *revs;
+ show_object_fn show_object;
+ show_commit_fn show_commit;
+ void *show_data;
+ struct filter *filter;
+};
+
void traverse_commit_list_filtered(
struct rev_info *revs,
show_commit_fn show_commit,
--
gitgitgadget
next prev parent reply other threads:[~2022-09-01 9:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 9:41 [PATCH 0/3] list-object-filter: introduce depth filter ZheNing Hu via GitGitGadget
2022-09-01 9:41 ` [PATCH 1/3] commit-graph: let commit graph respect commit graft ZheNing Hu via GitGitGadget
2022-09-01 19:18 ` Derrick Stolee
2022-09-04 5:57 ` ZheNing Hu
2022-09-01 9:41 ` ZheNing Hu via GitGitGadget [this message]
2022-09-01 9:41 ` [PATCH 3/3] list-object-filter: introduce depth filter ZheNing Hu via GitGitGadget
2022-09-01 19:24 ` [PATCH 0/3] " Derrick Stolee
2022-09-02 13:48 ` Johannes Schindelin
2022-09-04 9:14 ` ZheNing Hu
2022-09-07 10:18 ` Johannes Schindelin
2022-09-11 10:59 ` ZheNing Hu
2022-09-04 7:27 ` ZheNing Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0df61091c194ed46fda4d70272fcbcfdbedc8770.1662025272.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=adlternative@gmail.com \
--cc=avarab@gmail.com \
--cc=christian.couder@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=johannes.schindelin@gmx.de \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).