blob: 250d9de41cb56072e95420530b203ce417191a2b [file] [log] [blame]
Junio C Hamanoc64ed702006-09-04 21:50:12 -07001#include "cache.h"
2#include "tag.h"
3#include "commit.h"
4#include "tree.h"
5#include "blob.h"
6#include "diff.h"
7#include "tree-walk.h"
8#include "revision.h"
9#include "list-objects.h"
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +000010#include "list-objects-filter.h"
11#include "list-objects-filter-options.h"
Jonathan Tandf11e192017-12-08 15:27:15 +000012#include "packfile.h"
Stefan Bellercbd53a22018-05-15 16:42:15 -070013#include "object-store.h"
Matthew DeVore8b10a202018-10-17 17:39:15 -070014#include "trace.h"
Junio C Hamanoc64ed702006-09-04 21:50:12 -070015
Matthew DeVoref447a492018-08-13 11:14:28 -070016struct traversal_context {
17 struct rev_info *revs;
18 show_object_fn show_object;
19 show_commit_fn show_commit;
20 void *show_data;
Matthew DeVore94301472019-06-27 15:54:05 -070021 struct filter *filter;
Matthew DeVoref447a492018-08-13 11:14:28 -070022};
23
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +000024static void show_commit(struct traversal_context *ctx,
25 struct commit *commit)
26{
27 if (!ctx->show_commit)
28 return;
29 ctx->show_commit(commit, ctx->show_data);
30}
31
32static void show_object(struct traversal_context *ctx,
33 struct object *object,
34 const char *name)
35{
36 if (!ctx->show_object)
37 return;
38 ctx->show_object(object, name, ctx->show_data);
39}
40
Matthew DeVoref447a492018-08-13 11:14:28 -070041static void process_blob(struct traversal_context *ctx,
Junio C Hamanoc64ed702006-09-04 21:50:12 -070042 struct blob *blob,
Jeff Kingbd645162016-02-11 17:26:44 -050043 struct strbuf *path,
Matthew DeVoref447a492018-08-13 11:14:28 -070044 const char *name)
Junio C Hamanoc64ed702006-09-04 21:50:12 -070045{
46 struct object *obj = &blob->object;
Jeff Kingde1e67d2016-02-11 17:28:36 -050047 size_t pathlen;
Matthew DeVore94301472019-06-27 15:54:05 -070048 enum list_objects_filter_result r;
Junio C Hamanoc64ed702006-09-04 21:50:12 -070049
Matthew DeVoref447a492018-08-13 11:14:28 -070050 if (!ctx->revs->blob_objects)
Junio C Hamanoc64ed702006-09-04 21:50:12 -070051 return;
Martin Koeglera301b0c2008-02-18 21:47:56 +010052 if (!obj)
53 die("bad blob object");
Junio C Hamanoc64ed702006-09-04 21:50:12 -070054 if (obj->flags & (UNINTERESTING | SEEN))
55 return;
Jeff Kingde1e67d2016-02-11 17:28:36 -050056
Jonathan Tandf11e192017-12-08 15:27:15 +000057 /*
58 * Pre-filter known-missing objects when explicitly requested.
59 * Otherwise, a missing object error message may be reported
60 * later (depending on other filtering criteria).
61 *
62 * Note that this "--exclude-promisor-objects" pre-filtering
63 * may cause the actual filter to report an incomplete list
64 * of missing objects.
65 */
Matthew DeVoref447a492018-08-13 11:14:28 -070066 if (ctx->revs->exclude_promisor_objects &&
Jonathan Tandf11e192017-12-08 15:27:15 +000067 !has_object_file(&obj->oid) &&
68 is_promisor_object(&obj->oid))
69 return;
70
Jeff Kingde1e67d2016-02-11 17:28:36 -050071 pathlen = path->len;
72 strbuf_addstr(path, name);
Matthew DeVore94301472019-06-27 15:54:05 -070073 r = list_objects_filter__filter_object(ctx->revs->repo,
74 LOFS_BLOB, obj,
75 path->buf, &path->buf[pathlen],
76 ctx->filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +000077 if (r & LOFR_MARK_SEEN)
78 obj->flags |= SEEN;
79 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +000080 show_object(ctx, obj, path->buf);
Jeff Kingde1e67d2016-02-11 17:28:36 -050081 strbuf_setlen(path, pathlen);
Junio C Hamanoc64ed702006-09-04 21:50:12 -070082}
83
Linus Torvalds6e2f4412007-04-13 09:25:01 -070084/*
85 * Processing a gitlink entry currently does nothing, since
86 * we do not recurse into the subproject.
87 *
88 * We *could* eventually add a flag that actually does that,
89 * which would involve:
90 * - is the subproject actually checked out?
91 * - if so, see if the subproject has already been added
92 * to the alternates list, and add it if not.
93 * - process the commit (or tag) the gitlink points to
94 * recursively.
95 *
96 * However, it's unclear whether there is really ever any
97 * reason to see superprojects and subprojects as such a
98 * "unified" object pool (potentially resulting in a totally
99 * humongous pack - avoiding which was the whole point of
100 * having gitlinks in the first place!).
101 *
102 * So for now, there is just a note that we *could* follow
103 * the link, and how to do it. Whether it necessarily makes
104 * any sense what-so-ever to ever do that is another issue.
105 */
Matthew DeVoref447a492018-08-13 11:14:28 -0700106static void process_gitlink(struct traversal_context *ctx,
Linus Torvalds6e2f4412007-04-13 09:25:01 -0700107 const unsigned char *sha1,
Jeff Kingbd645162016-02-11 17:26:44 -0500108 struct strbuf *path,
Matthew DeVoref447a492018-08-13 11:14:28 -0700109 const char *name)
Linus Torvalds6e2f4412007-04-13 09:25:01 -0700110{
111 /* Nothing to do */
112}
113
Matthew DeVoref447a492018-08-13 11:14:28 -0700114static void process_tree(struct traversal_context *ctx,
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700115 struct tree *tree,
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700116 struct strbuf *base,
Matthew DeVore92024892018-08-13 11:14:29 -0700117 const char *name);
118
119static void process_tree_contents(struct traversal_context *ctx,
120 struct tree *tree,
121 struct strbuf *base)
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700122{
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700123 struct tree_desc desc;
124 struct name_entry entry;
Matthew DeVore92024892018-08-13 11:14:29 -0700125 enum interesting match = ctx->revs->diffopt.pathspec.nr == 0 ?
126 all_entries_interesting : entry_not_interesting;
127
128 init_tree_desc(&desc, tree->buffer, tree->size);
129
130 while (tree_entry(&desc, &entry)) {
131 if (match != all_entries_interesting) {
Nguyễn Thái Ngọc Duy67022e02018-11-18 17:47:57 +0100132 match = tree_entry_interesting(ctx->revs->repo->index,
133 &entry, base, 0,
Matthew DeVore92024892018-08-13 11:14:29 -0700134 &ctx->revs->diffopt.pathspec);
135 if (match == all_entries_not_interesting)
136 break;
137 if (match == entry_not_interesting)
138 continue;
139 }
140
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700141 if (S_ISDIR(entry.mode)) {
brian m. carlsonea82b2a2019-01-15 00:39:44 +0000142 struct tree *t = lookup_tree(ctx->revs->repo, &entry.oid);
Taylor Blaub49e74e2019-04-09 19:13:19 -0700143 if (!t) {
144 die(_("entry '%s' in tree %s has tree mode, "
145 "but is not a tree"),
146 entry.path, oid_to_hex(&tree->object.oid));
147 }
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700148 t->object.flags |= NOT_USER_GIVEN;
149 process_tree(ctx, t, base, entry.path);
150 }
Matthew DeVore92024892018-08-13 11:14:29 -0700151 else if (S_ISGITLINK(entry.mode))
brian m. carlsonea82b2a2019-01-15 00:39:44 +0000152 process_gitlink(ctx, entry.oid.hash,
Matthew DeVore92024892018-08-13 11:14:29 -0700153 base, entry.path);
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700154 else {
brian m. carlsonea82b2a2019-01-15 00:39:44 +0000155 struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid);
Taylor Blau23c20442019-04-09 19:13:17 -0700156 if (!b) {
157 die(_("entry '%s' in tree %s has blob mode, "
158 "but is not a blob"),
159 entry.path, oid_to_hex(&tree->object.oid));
160 }
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700161 b->object.flags |= NOT_USER_GIVEN;
162 process_blob(ctx, b, base, entry.path);
163 }
Matthew DeVore92024892018-08-13 11:14:29 -0700164 }
165}
166
167static void process_tree(struct traversal_context *ctx,
168 struct tree *tree,
169 struct strbuf *base,
Matthew DeVoref447a492018-08-13 11:14:28 -0700170 const char *name)
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700171{
172 struct object *obj = &tree->object;
Matthew DeVoref447a492018-08-13 11:14:28 -0700173 struct rev_info *revs = ctx->revs;
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700174 int baselen = base->len;
Matthew DeVore94301472019-06-27 15:54:05 -0700175 enum list_objects_filter_result r;
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700176 int failed_parse;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700177
178 if (!revs->tree_objects)
179 return;
Martin Koeglera301b0c2008-02-18 21:47:56 +0100180 if (!obj)
181 die("bad tree object");
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700182 if (obj->flags & (UNINTERESTING | SEEN))
183 return;
Jeff Kingaa9ad6f2021-06-14 08:05:44 -0400184 if (revs->include_check_obj &&
185 !revs->include_check_obj(&tree->object, revs->include_check_data))
186 return;
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700187
188 failed_parse = parse_tree_gently(tree, 1);
189 if (failed_parse) {
Vicent Marti2db1a432014-03-28 06:00:43 -0400190 if (revs->ignore_missing_links)
191 return;
Jonathan Tandf11e192017-12-08 15:27:15 +0000192
193 /*
194 * Pre-filter known-missing tree objects when explicitly
195 * requested. This may cause the actual filter to report
196 * an incomplete list of missing objects.
197 */
198 if (revs->exclude_promisor_objects &&
199 is_promisor_object(&obj->oid))
200 return;
201
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700202 if (!revs->do_not_die_on_missing_tree)
203 die("bad tree object %s", oid_to_hex(&obj->oid));
Vicent Marti2db1a432014-03-28 06:00:43 -0400204 }
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700205
Jeff King13528ab2016-02-11 17:26:18 -0500206 strbuf_addstr(base, name);
Matthew DeVore94301472019-06-27 15:54:05 -0700207 r = list_objects_filter__filter_object(ctx->revs->repo,
208 LOFS_BEGIN_TREE, obj,
209 base->buf, &base->buf[baselen],
210 ctx->filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000211 if (r & LOFR_MARK_SEEN)
212 obj->flags |= SEEN;
213 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000214 show_object(ctx, obj, base->buf);
Jeff King13528ab2016-02-11 17:26:18 -0500215 if (base->len)
216 strbuf_addch(base, '/');
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700217
Matthew DeVore8b10a202018-10-17 17:39:15 -0700218 if (r & LOFR_SKIP_TREE)
219 trace_printf("Skipping contents of tree %s...\n", base->buf);
220 else if (!failed_parse)
Matthew DeVore7c0fe332018-10-05 14:31:23 -0700221 process_tree_contents(ctx, tree, base);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700222
Matthew DeVore94301472019-06-27 15:54:05 -0700223 r = list_objects_filter__filter_object(ctx->revs->repo,
224 LOFS_END_TREE, obj,
225 base->buf, &base->buf[baselen],
226 ctx->filter);
227 if (r & LOFR_MARK_SEEN)
228 obj->flags |= SEEN;
229 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000230 show_object(ctx, obj, base->buf);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000231
Elijah Newrencc5fa2f2010-12-17 20:26:47 +0700232 strbuf_setlen(base, baselen);
Jeff King6e454b92013-06-05 18:37:39 -0400233 free_tree_buffer(tree);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700234}
235
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200236static void process_tag(struct traversal_context *ctx,
237 struct tag *tag,
238 const char *name)
239{
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200240 enum list_objects_filter_result r;
241
242 r = list_objects_filter__filter_object(ctx->revs->repo, LOFS_TAG,
243 &tag->object, NULL, NULL,
244 ctx->filter);
245 if (r & LOFR_MARK_SEEN)
246 tag->object.flags |= SEEN;
247 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000248 show_object(ctx, &tag->object, name);
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200249}
250
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700251static void mark_edge_parents_uninteresting(struct commit *commit,
252 struct rev_info *revs,
253 show_edge_fn show_edge)
254{
255 struct commit_list *parents;
256
257 for (parents = commit->parents; parents; parents = parents->next) {
258 struct commit *parent = parents->item;
259 if (!(parent->object.flags & UNINTERESTING))
260 continue;
Nguyễn Thái Ngọc Duyb3c7eef2018-09-21 17:57:39 +0200261 mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700262 if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
263 parent->object.flags |= SHOWN;
264 show_edge(parent);
265 }
266 }
267}
268
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800269static void add_edge_parents(struct commit *commit,
270 struct rev_info *revs,
271 show_edge_fn show_edge,
272 struct oidset *set)
273{
274 struct commit_list *parents;
275
276 for (parents = commit->parents; parents; parents = parents->next) {
277 struct commit *parent = parents->item;
278 struct tree *tree = get_commit_tree(parent);
279
280 if (!tree)
281 continue;
282
283 oidset_insert(set, &tree->object.oid);
284
285 if (!(parent->object.flags & UNINTERESTING))
286 continue;
287 tree->object.flags |= UNINTERESTING;
288
289 if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
290 parent->object.flags |= SHOWN;
291 show_edge(parent);
292 }
293 }
294}
295
296void mark_edges_uninteresting(struct rev_info *revs,
297 show_edge_fn show_edge,
298 int sparse)
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700299{
Nguyễn Thái Ngọc Duye76a5fb2013-08-16 16:52:06 +0700300 struct commit_list *list;
Nguyễn Thái Ngọc Duyfbd4a702013-08-16 16:52:07 +0700301 int i;
302
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800303 if (sparse) {
304 struct oidset set;
305 oidset_init(&set, 16);
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700306
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800307 for (list = revs->commits; list; list = list->next) {
308 struct commit *commit = list->item;
309 struct tree *tree = get_commit_tree(commit);
310
311 if (commit->object.flags & UNINTERESTING)
312 tree->object.flags |= UNINTERESTING;
313
314 oidset_insert(&set, &tree->object.oid);
315 add_edge_parents(commit, revs, show_edge, &set);
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700316 }
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800317
318 mark_trees_uninteresting_sparse(revs->repo, &set);
319 oidset_clear(&set);
320 } else {
321 for (list = revs->commits; list; list = list->next) {
322 struct commit *commit = list->item;
323 if (commit->object.flags & UNINTERESTING) {
324 mark_tree_uninteresting(revs->repo,
325 get_commit_tree(commit));
326 if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
327 commit->object.flags |= SHOWN;
328 show_edge(commit);
329 }
330 continue;
331 }
332 mark_edge_parents_uninteresting(commit, revs, show_edge);
333 }
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700334 }
Derrick Stolee4f6d26b2019-01-16 10:25:58 -0800335
brian m. carlson1684c1b2014-12-24 23:05:39 +0000336 if (revs->edge_hint_aggressive) {
Jeff King200abe72014-01-20 21:25:40 -0500337 for (i = 0; i < revs->cmdline.nr; i++) {
338 struct object *obj = revs->cmdline.rev[i].item;
339 struct commit *commit = (struct commit *)obj;
340 if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
341 continue;
Nguyễn Thái Ngọc Duyb3c7eef2018-09-21 17:57:39 +0200342 mark_tree_uninteresting(revs->repo,
343 get_commit_tree(commit));
Jeff King200abe72014-01-20 21:25:40 -0500344 if (!(obj->flags & SHOWN)) {
345 obj->flags |= SHOWN;
346 show_edge(commit);
347 }
Nguyễn Thái Ngọc Duyfbd4a702013-08-16 16:52:07 +0700348 }
349 }
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700350}
351
Linus Torvalds8d2dfc42009-04-10 17:27:58 -0700352static void add_pending_tree(struct rev_info *revs, struct tree *tree)
353{
354 add_pending_object(revs, &tree->object, "");
355}
356
Teng Longb3e36df2021-08-12 16:59:31 +0800357static void traverse_non_commits(struct traversal_context *ctx,
358 struct strbuf *base)
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700359{
360 int i;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700361
Stefan Beller91904f52017-11-02 12:41:43 -0700362 assert(base->len == 0);
363
Matthew DeVoref447a492018-08-13 11:14:28 -0700364 for (i = 0; i < ctx->revs->pending.nr; i++) {
365 struct object_array_entry *pending = ctx->revs->pending.objects + i;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700366 struct object *obj = pending->item;
367 const char *name = pending->name;
Jeff King20739492014-10-15 18:43:19 -0400368 const char *path = pending->path;
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700369 if (obj->flags & (UNINTERESTING | SEEN))
370 continue;
371 if (obj->type == OBJ_TAG) {
Patrick Steinhardt628d81b2021-04-09 13:28:02 +0200372 process_tag(ctx, (struct tag *)obj, name);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700373 continue;
374 }
Jeff King20739492014-10-15 18:43:19 -0400375 if (!path)
376 path = "";
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700377 if (obj->type == OBJ_TREE) {
Matthew DeVoref447a492018-08-13 11:14:28 -0700378 process_tree(ctx, (struct tree *)obj, base, path);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700379 continue;
380 }
381 if (obj->type == OBJ_BLOB) {
Matthew DeVoref447a492018-08-13 11:14:28 -0700382 process_blob(ctx, (struct blob *)obj, base, path);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700383 continue;
384 }
385 die("unknown pending object %s (%s)",
brian m. carlsonf2fd0762015-11-10 02:22:28 +0000386 oid_to_hex(&obj->oid), name);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700387 }
Matthew DeVoref447a492018-08-13 11:14:28 -0700388 object_array_clear(&ctx->revs->pending);
Stefan Beller91904f52017-11-02 12:41:43 -0700389}
390
Matthew DeVoref447a492018-08-13 11:14:28 -0700391static void do_traverse(struct traversal_context *ctx)
Stefan Beller91904f52017-11-02 12:41:43 -0700392{
393 struct commit *commit;
394 struct strbuf csp; /* callee's scratch pad */
395 strbuf_init(&csp, PATH_MAX);
396
Matthew DeVoref447a492018-08-13 11:14:28 -0700397 while ((commit = get_revision(ctx->revs)) != NULL) {
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200398 enum list_objects_filter_result r;
399
400 r = list_objects_filter__filter_object(ctx->revs->repo,
401 LOFS_COMMIT, &commit->object,
402 NULL, NULL, ctx->filter);
403
Stefan Beller91904f52017-11-02 12:41:43 -0700404 /*
405 * an uninteresting boundary commit may not have its tree
406 * parsed yet, but we are not going to show them anyway
407 */
Jeff King72ed80c2019-09-11 21:11:37 -0400408 if (!ctx->revs->tree_objects)
409 ; /* do not bother loading tree */
410 else if (get_commit_tree(commit)) {
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700411 struct tree *tree = get_commit_tree(commit);
412 tree->object.flags |= NOT_USER_GIVEN;
413 add_pending_tree(ctx->revs, tree);
Jeff King97dd5122019-04-09 19:13:25 -0700414 } else if (commit->object.parsed) {
415 die(_("unable to load root tree for commit %s"),
416 oid_to_hex(&commit->object.oid));
Matthew DeVore99c9aa92018-10-05 14:31:24 -0700417 }
Patrick Steinhardt9a2a4f92021-04-12 15:37:35 +0200418
419 if (r & LOFR_MARK_SEEN)
420 commit->object.flags |= SEEN;
421 if (r & LOFR_DO_SHOW)
Ævar Arnfjörð Bjarmason4f33a632022-03-09 16:01:38 +0000422 show_commit(ctx, commit);
Stefan Bellerce5b6f92017-11-15 18:00:35 -0800423
Matthew DeVoref447a492018-08-13 11:14:28 -0700424 if (ctx->revs->tree_blobs_in_commit_order)
Stefan Bellerce5b6f92017-11-15 18:00:35 -0800425 /*
426 * NEEDSWORK: Adding the tree and then flushing it here
427 * needs a reallocation for each commit. Can we pass the
428 * tree directory without allocation churn?
429 */
Teng Longb3e36df2021-08-12 16:59:31 +0800430 traverse_non_commits(ctx, &csp);
Stefan Beller91904f52017-11-02 12:41:43 -0700431 }
Teng Longb3e36df2021-08-12 16:59:31 +0800432 traverse_non_commits(ctx, &csp);
Stefan Beller91904f52017-11-02 12:41:43 -0700433 strbuf_release(&csp);
Junio C Hamanoc64ed702006-09-04 21:50:12 -0700434}
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000435
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000436void traverse_commit_list_filtered(
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000437 struct rev_info *revs,
438 show_commit_fn show_commit,
439 show_object_fn show_object,
440 void *show_data,
441 struct oidset *omitted)
442{
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000443 struct traversal_context ctx = {
444 .revs = revs,
445 .show_object = show_object,
446 .show_commit = show_commit,
447 .show_data = show_data,
448 };
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000449
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000450 if (revs->filter.choice)
451 ctx.filter = list_objects_filter__init(omitted, &revs->filter);
452
Matthew DeVoref447a492018-08-13 11:14:28 -0700453 do_traverse(&ctx);
Derrick Stolee3e0370a2022-03-09 16:01:36 +0000454
455 if (ctx.filter)
456 list_objects_filter__free(ctx.filter);
Jeff Hostetler25ec7bc2017-11-21 20:58:50 +0000457}