blob: eecca721ac0826ef09071e6c3119a231d693771a [file] [log] [blame]
Elijah Newrend812c3b2023-04-11 00:41:56 -07001#include "git-compat-util.h"
Junio C Hamanoc64ed702006-09-04 21:50:12 -07002#include "tag.h"
3#include "commit.h"
Elijah Newrenf394e092023-03-21 06:25:54 +00004#include "gettext.h"
Elijah Newren41771fa2023-02-24 00:09:27 +00005#include "hex.h"
Junio C Hamanoc64ed702006-09-04 21:50:12 -07006#include "tree.h"
7#include "blob.h"
8#include "diff.h"
9#include "tree-walk.h"
10#include "revision.h"
11#include "list-objects.h"
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +000012#include "list-objects-filter.h"
13#include "list-objects-filter-options.h"
Jonathan Tandf11e192017-12-08 15:27:15 +000014#include "packfile.h"
Stefan Bellercbd53a22018-05-15 16:42:15 -070015#include "object-store.h"
Matthew DeVore8b10a202018-10-17 17:39:15 -070016#include "trace.h"
Junio C Hamanoc64ed702006-09-04 21:50:12 -070017
Matthew DeVoref447a492018-08-13 11:14:28 -070018struct traversal_context {
19 struct rev_info *revs;
20 show_object_fn show_object;
21 show_commit_fn show_commit;
22 void *show_data;
Matthew DeVore94301472019-06-27 15:54:05 -070023 struct filter *filter;
Matthew DeVoref447a492018-08-13 11:14:28 -070024};
25
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +000026static void show_commit(struct traversal_context *ctx,
27 struct commit *commit)
28{
29 if (!ctx->show_commit)
30 return;
31 ctx->show_commit(commit, ctx->show_data);
32}
33
34static void show_object(struct traversal_context *ctx,
35 struct object *object,
36 const char *name)
37{
38 if (!ctx->show_object)
39 return;
40 ctx->show_object(object, name, ctx->show_data);
41}
42
Matthew DeVoref447a492018-08-13 11:14:28 -070043static void process_blob(struct traversal_context *ctx,
Junio C Hamanoc64ed702006-09-04 21:50:12 -070044 struct blob *blob,
Jeff Kingbd645162016-02-11 17:26:44 -050045 struct strbuf *path,
Matthew DeVoref447a492018-08-13 11:14:28 -070046 const char *name)
Junio C Hamanoc64ed702006-09-04 21:50:12 -070047{
48 struct object *obj = &blob->object;
Jeff Kingde1e67d2016-02-11 17:28:36 -050049 size_t pathlen;
Matthew DeVore94301472019-06-27 15:54:05 -070050 enum list_objects_filter_result r;
Junio C Hamanoc64ed702006-09-04 21:50:12 -070051
Matthew DeVoref447a492018-08-13 11:14:28 -070052 if (!ctx->revs->blob_objects)
Junio C Hamanoc64ed702006-09-04 21:50:12 -070053 return;
Martin Koeglera301b0c2008-02-18 21:47:56 +010054 if (!obj)
55 die("bad blob object");
Junio C Hamanoc64ed702006-09-04 21:50:12 -070056 if (obj->flags & (UNINTERESTING | SEEN))
57 return;
Jeff Kingde1e67d2016-02-11 17:28:36 -050058
Jonathan Tandf11e192017-12-08 15:27:15 +000059 /*
60 * Pre-filter known-missing objects when explicitly requested.
61 * Otherwise, a missing object error message may be reported
62 * later (depending on other filtering criteria).
63 *
64 * Note that this "--exclude-promisor-objects" pre-filtering
65 * may cause the actual filter to report an incomplete list
66 * of missing objects.
67 */
Matthew DeVoref447a492018-08-13 11:14:28 -070068 if (ctx->revs->exclude_promisor_objects &&
Ævar Arnfjörð Bjarmasonbc726bd2023-03-28 15:58:50 +020069 !repo_has_object_file(the_repository, &obj->oid) &&
Jonathan Tandf11e192017-12-08 15:27:15 +000070 is_promisor_object(&obj->oid))
71 return;
72
Jeff Kingde1e67d2016-02-11 17:28:36 -050073 pathlen = path->len;
74 strbuf_addstr(path, name);
Matthew DeVore94301472019-06-27 15:54:05 -070075 r = list_objects_filter__filter_object(ctx->revs->repo,
76 LOFS_BLOB, obj,
77 path->buf, &path->buf[pathlen],
78 ctx->filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +000079 if (r & LOFR_MARK_SEEN)
80 obj->flags |= SEEN;
81 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +000082 show_object(ctx, obj, path->buf);
Jeff Kingde1e67d2016-02-11 17:28:36 -050083 strbuf_setlen(path, pathlen);
Junio C Hamanoc64ed702006-09-04 21:50:12 -070084}
85
Matthew DeVoref447a492018-08-13 11:14:28 -070086static void process_tree(struct traversal_context *ctx,
Junio C Hamanoc64ed702006-09-04 21:50:12 -070087 struct tree *tree,
Elijah Newrencc5fa2f2010-12-17 20:26:47 +070088 struct strbuf *base,
Matthew DeVore92024892018-08-13 11:14:29 -070089 const char *name);
90
91static void process_tree_contents(struct traversal_context *ctx,
92 struct tree *tree,
93 struct strbuf *base)
Junio C Hamanoc64ed702006-09-04 21:50:12 -070094{
Junio C Hamanoc64ed702006-09-04 21:50:12 -070095 struct tree_desc desc;
96 struct name_entry entry;
Matthew DeVore92024892018-08-13 11:14:29 -070097 enum interesting match = ctx->revs->diffopt.pathspec.nr == 0 ?
98 all_entries_interesting : entry_not_interesting;
99
100 init_tree_desc(&desc, tree->buffer, tree->size);
101
102 while (tree_entry(&desc, &entry)) {
103 if (match != all_entries_interesting) {
Nguyễn Thái Ngọc Duy67022e02018-11-18 17:47:57 +0100104 match = tree_entry_interesting(ctx->revs->repo->index,
105 &entry, base, 0,
Matthew DeVore92024892018-08-13 11:14:29 -0700106 &ctx->revs->diffopt.pathspec);
107 if (match == all_entries_not_interesting)
108 break;
109 if (match == entry_not_interesting)
110 continue;
111 }
112
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700113 if (S_ISDIR(entry.mode)) {
brian m. carlsonea82b2a2019-01-15 00:39:44 +0000114 struct tree *t = lookup_tree(ctx->revs->repo, &entry.oid);
Taylor Blaub49e74e2019-04-09 19:13:19 -0700115 if (!t) {
116 die(_("entry '%s' in tree %s has tree mode, "
117 "but is not a tree"),
118 entry.path, oid_to_hex(&tree->object.oid));
119 }
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700120 t->object.flags |= NOT_USER_GIVEN;
121 process_tree(ctx, t, base, entry.path);
122 }
Matthew DeVore92024892018-08-13 11:14:29 -0700123 else if (S_ISGITLINK(entry.mode))
Jeff King00271482022-12-13 06:12:09 -0500124 ; /* ignore gitlink */
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700125 else {
brian m. carlsonea82b2a2019-01-15 00:39:44 +0000126 struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid);
Taylor Blau23c20442019-04-09 19:13:17 -0700127 if (!b) {
128 die(_("entry '%s' in tree %s has blob mode, "
129 "but is not a blob"),
130 entry.path, oid_to_hex(&tree->object.oid));
131 }
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700132 b->object.flags |= NOT_USER_GIVEN;
133 process_blob(ctx, b, base, entry.path);
134 }
Matthew DeVore92024892018-08-13 11:14:29 -0700135 }
136}
137
138static void process_tree(struct traversal_context *ctx,
139 struct tree *tree,
140 struct strbuf *base,
Matthew DeVoref447a492018-08-13 11:14:28 -0700141 const char *name)
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700142{
143 struct object *obj = &tree->object;
Matthew DeVoref447a492018-08-13 11:14:28 -0700144 struct rev_info *revs = ctx->revs;
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700145 int baselen = base->len;
Matthew DeVore94301472019-06-27 15:54:05 -0700146 enum list_objects_filter_result r;
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700147 int failed_parse;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700148
149 if (!revs->tree_objects)
150 return;
Martin Koeglera301b0c2008-02-18 21:47:56 +0100151 if (!obj)
152 die("bad tree object");
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700153 if (obj->flags & (UNINTERESTING | SEEN))
154 return;
Jeff Kingaa9ad6f2021-06-14 08:05:44 -0400155 if (revs->include_check_obj &&
156 !revs->include_check_obj(&tree->object, revs->include_check_data))
157 return;
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700158
159 failed_parse = parse_tree_gently(tree, 1);
160 if (failed_parse) {
Vicent Marti2db1a432014-03-28 06:00:43 -0400161 if (revs->ignore_missing_links)
162 return;
Jonathan Tandf11e192017-12-08 15:27:15 +0000163
164 /*
165 * Pre-filter known-missing tree objects when explicitly
166 * requested. This may cause the actual filter to report
167 * an incomplete list of missing objects.
168 */
169 if (revs->exclude_promisor_objects &&
170 is_promisor_object(&obj->oid))
171 return;
172
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700173 if (!revs->do_not_die_on_missing_tree)
174 die("bad tree object %s", oid_to_hex(&obj->oid));
Vicent Marti2db1a432014-03-28 06:00:43 -0400175 }
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700176
Jeff King13528ab2016-02-11 17:26:18 -0500177 strbuf_addstr(base, name);
Matthew DeVore94301472019-06-27 15:54:05 -0700178 r = list_objects_filter__filter_object(ctx->revs->repo,
179 LOFS_BEGIN_TREE, obj,
180 base->buf, &base->buf[baselen],
181 ctx->filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000182 if (r & LOFR_MARK_SEEN)
183 obj->flags |= SEEN;
184 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000185 show_object(ctx, obj, base->buf);
Jeff King13528ab2016-02-11 17:26:18 -0500186 if (base->len)
187 strbuf_addch(base, '/');
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700188
Matthew DeVore8b10a202018-10-17 17:39:15 -0700189 if (r & LOFR_SKIP_TREE)
190 trace_printf("Skipping contents of tree %s...\n", base->buf);
191 else if (!failed_parse)
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700192 process_tree_contents(ctx, tree, base);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700193
Matthew DeVore94301472019-06-27 15:54:05 -0700194 r = list_objects_filter__filter_object(ctx->revs->repo,
195 LOFS_END_TREE, obj,
196 base->buf, &base->buf[baselen],
197 ctx->filter);
198 if (r & LOFR_MARK_SEEN)
199 obj->flags |= SEEN;
200 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000201 show_object(ctx, obj, base->buf);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000202
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700203 strbuf_setlen(base, baselen);
Jeff King6e454b92013-06-05 18:37:39 -0400204 free_tree_buffer(tree);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700205}
206
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200207static void process_tag(struct traversal_context *ctx,
208 struct tag *tag,
209 const char *name)
210{
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200211 enum list_objects_filter_result r;
212
213 r = list_objects_filter__filter_object(ctx->revs->repo, LOFS_TAG,
214 &tag->object, NULL, NULL,
215 ctx->filter);
216 if (r & LOFR_MARK_SEEN)
217 tag->object.flags |= SEEN;
218 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000219 show_object(ctx, &tag->object, name);
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200220}
221
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700222static void mark_edge_parents_uninteresting(struct commit *commit,
223 struct rev_info *revs,
224 show_edge_fn show_edge)
225{
226 struct commit_list *parents;
227
228 for (parents = commit->parents; parents; parents = parents->next) {
229 struct commit *parent = parents->item;
230 if (!(parent->object.flags & UNINTERESTING))
231 continue;
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200232 mark_tree_uninteresting(revs->repo,
233 repo_get_commit_tree(the_repository, parent));
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700234 if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
235 parent->object.flags |= SHOWN;
236 show_edge(parent);
237 }
238 }
239}
240
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800241static void add_edge_parents(struct commit *commit,
242 struct rev_info *revs,
243 show_edge_fn show_edge,
244 struct oidset *set)
245{
246 struct commit_list *parents;
247
248 for (parents = commit->parents; parents; parents = parents->next) {
249 struct commit *parent = parents->item;
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200250 struct tree *tree = repo_get_commit_tree(the_repository,
251 parent);
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800252
253 if (!tree)
254 continue;
255
256 oidset_insert(set, &tree->object.oid);
257
258 if (!(parent->object.flags & UNINTERESTING))
259 continue;
260 tree->object.flags |= UNINTERESTING;
261
262 if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
263 parent->object.flags |= SHOWN;
264 show_edge(parent);
265 }
266 }
267}
268
269void mark_edges_uninteresting(struct rev_info *revs,
270 show_edge_fn show_edge,
271 int sparse)
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700272{
Nguyễn Thái Ngọc Duye76a5fb2013-08-16 16:52:06 +0700273 struct commit_list *list;
Nguyễn Thái Ngọc Duyfbd4a702013-08-16 16:52:07 +0700274 int i;
275
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800276 if (sparse) {
277 struct oidset set;
278 oidset_init(&set, 16);
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700279
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800280 for (list = revs->commits; list; list = list->next) {
281 struct commit *commit = list->item;
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200282 struct tree *tree = repo_get_commit_tree(the_repository,
283 commit);
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800284
285 if (commit->object.flags & UNINTERESTING)
286 tree->object.flags |= UNINTERESTING;
287
288 oidset_insert(&set, &tree->object.oid);
289 add_edge_parents(commit, revs, show_edge, &set);
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700290 }
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800291
292 mark_trees_uninteresting_sparse(revs->repo, &set);
293 oidset_clear(&set);
294 } else {
295 for (list = revs->commits; list; list = list->next) {
296 struct commit *commit = list->item;
297 if (commit->object.flags & UNINTERESTING) {
298 mark_tree_uninteresting(revs->repo,
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200299 repo_get_commit_tree(the_repository, commit));
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800300 if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
301 commit->object.flags |= SHOWN;
302 show_edge(commit);
303 }
304 continue;
305 }
306 mark_edge_parents_uninteresting(commit, revs, show_edge);
307 }
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700308 }
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800309
brian m. carlson1684c1b2014-12-24 23:05:39 +0000310 if (revs->edge_hint_aggressive) {
Jeff King200abe72014-01-20 21:25:40 -0500311 for (i = 0; i < revs->cmdline.nr; i++) {
312 struct object *obj = revs->cmdline.rev[i].item;
313 struct commit *commit = (struct commit *)obj;
314 if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
315 continue;
Nguyễn Thái Ngọc Duyb3c7eef2018-09-21 17:57:39 +0200316 mark_tree_uninteresting(revs->repo,
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200317 repo_get_commit_tree(the_repository, commit));
Jeff King200abe72014-01-20 21:25:40 -0500318 if (!(obj->flags & SHOWN)) {
319 obj->flags |= SHOWN;
320 show_edge(commit);
321 }
Nguyễn Thái Ngọc Duyfbd4a702013-08-16 16:52:07 +0700322 }
323 }
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700324}
325
Linus Torvalds8d2dfc42009-04-10 17:27:58 -0700326static void add_pending_tree(struct rev_info *revs, struct tree *tree)
327{
328 add_pending_object(revs, &tree->object, "");
329}
330
Teng Longb3e36df2021-08-12 16:59:31 +0800331static void traverse_non_commits(struct traversal_context *ctx,
332 struct strbuf *base)
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700333{
334 int i;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700335
Stefan Beller91904f52017-11-02 12:41:43 -0700336 assert(base->len == 0);
337
Matthew DeVoref447a492018-08-13 11:14:28 -0700338 for (i = 0; i < ctx->revs->pending.nr; i++) {
339 struct object_array_entry *pending = ctx->revs->pending.objects + i;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700340 struct object *obj = pending->item;
341 const char *name = pending->name;
Jeff King20739492014-10-15 18:43:19 -0400342 const char *path = pending->path;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700343 if (obj->flags & (UNINTERESTING | SEEN))
344 continue;
345 if (obj->type == OBJ_TAG) {
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200346 process_tag(ctx, (struct tag *)obj, name);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700347 continue;
348 }
Jeff King20739492014-10-15 18:43:19 -0400349 if (!path)
350 path = "";
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700351 if (obj->type == OBJ_TREE) {
Matthew DeVoref447a492018-08-13 11:14:28 -0700352 process_tree(ctx, (struct tree *)obj, base, path);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700353 continue;
354 }
355 if (obj->type == OBJ_BLOB) {
Matthew DeVoref447a492018-08-13 11:14:28 -0700356 process_blob(ctx, (struct blob *)obj, base, path);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700357 continue;
358 }
359 die("unknown pending object %s (%s)",
brian m. carlsonf2fd0762015-11-10 02:22:28 +0000360 oid_to_hex(&obj->oid), name);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700361 }
Matthew DeVoref447a492018-08-13 11:14:28 -0700362 object_array_clear(&ctx->revs->pending);
Stefan Beller91904f52017-11-02 12:41:43 -0700363}
364
Matthew DeVoref447a492018-08-13 11:14:28 -0700365static void do_traverse(struct traversal_context *ctx)
Stefan Beller91904f52017-11-02 12:41:43 -0700366{
367 struct commit *commit;
368 struct strbuf csp; /* callee's scratch pad */
369 strbuf_init(&csp, PATH_MAX);
370
Matthew DeVoref447a492018-08-13 11:14:28 -0700371 while ((commit = get_revision(ctx->revs)) != NULL) {
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200372 enum list_objects_filter_result r;
373
374 r = list_objects_filter__filter_object(ctx->revs->repo,
375 LOFS_COMMIT, &commit->object,
376 NULL, NULL, ctx->filter);
377
Stefan Beller91904f52017-11-02 12:41:43 -0700378 /*
379 * an uninteresting boundary commit may not have its tree
380 * parsed yet, but we are not going to show them anyway
381 */
Jeff King72ed80c2019-09-11 21:11:37 -0400382 if (!ctx->revs->tree_objects)
383 ; /* do not bother loading tree */
Ævar Arnfjörð Bjarmasonecb50912023-03-28 15:58:48 +0200384 else if (repo_get_commit_tree(the_repository, commit)) {
385 struct tree *tree = repo_get_commit_tree(the_repository,
386 commit);
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700387 tree->object.flags |= NOT_USER_GIVEN;
388 add_pending_tree(ctx->revs, tree);
Jeff King97dd5122019-04-09 19:13:25 -0700389 } else if (commit->object.parsed) {
390 die(_("unable to load root tree for commit %s"),
391 oid_to_hex(&commit->object.oid));
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700392 }
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200393
394 if (r & LOFR_MARK_SEEN)
395 commit->object.flags |= SEEN;
396 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000397 show_commit(ctx, commit);
Stefan Bellerce5b6f92017-11-15 18:00:35 -0800398
Matthew DeVoref447a492018-08-13 11:14:28 -0700399 if (ctx->revs->tree_blobs_in_commit_order)
Stefan Bellerce5b6f92017-11-15 18:00:35 -0800400 /*
401 * NEEDSWORK: Adding the tree and then flushing it here
402 * needs a reallocation for each commit. Can we pass the
403 * tree directory without allocation churn?
404 */
Teng Longb3e36df2021-08-12 16:59:31 +0800405 traverse_non_commits(ctx, &csp);
Stefan Beller91904f52017-11-02 12:41:43 -0700406 }
Teng Longb3e36df2021-08-12 16:59:31 +0800407 traverse_non_commits(ctx, &csp);
Stefan Beller91904f52017-11-02 12:41:43 -0700408 strbuf_release(&csp);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700409}
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000410
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000411void traverse_commit_list_filtered(
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000412 struct rev_info *revs,
413 show_commit_fn show_commit,
414 show_object_fn show_object,
415 void *show_data,
416 struct oidset *omitted)
417{
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000418 struct traversal_context ctx = {
419 .revs = revs,
420 .show_object = show_object,
421 .show_commit = show_commit,
422 .show_data = show_data,
423 };
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000424
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000425 if (revs->filter.choice)
426 ctx.filter = list_objects_filter__init(omitted, &revs->filter);
427
Matthew DeVoref447a492018-08-13 11:14:28 -0700428 do_traverse(&ctx);
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000429
430 if (ctx.filter)
431 list_objects_filter__free(ctx.filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000432}