Skip to content

Commit 3e0370a

Browse files
derrickstoleegitster
authored andcommitted
list-objects: consolidate traverse_commit_list[_filtered]
Now that all consumers of traverse_commit_list_filtered() populate the 'filter' member of 'struct rev_info', we can drop that parameter from the method prototype to simplify things. In addition, the only thing different now between traverse_commit_list_filtered() and traverse_commit_list() is the presence of the 'omitted' parameter, which is only non-NULL for one caller. We can consolidate these two methods by having one call the other and use the simpler form everywhere the 'omitted' parameter would be NULL. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 09d4a79 commit 3e0370a

File tree

5 files changed

+29
-31
lines changed

5 files changed

+29
-31
lines changed

builtin/pack-objects.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3778,9 +3778,9 @@ static void get_object_list(int ac, const char **av)
37783778

37793779
if (!fn_show_object)
37803780
fn_show_object = show_object;
3781-
traverse_commit_list_filtered(&revs.filter, &revs,
3782-
show_commit, fn_show_object, NULL,
3783-
NULL);
3781+
traverse_commit_list(&revs,
3782+
show_commit, fn_show_object,
3783+
NULL);
37843784

37853785
if (unpack_unreachable_expiration) {
37863786
revs.ignore_missing_links = 1;

builtin/rev-list.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
729729
oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
730730

731731
traverse_commit_list_filtered(
732-
&revs.filter, &revs, show_commit, show_object, &info,
732+
&revs, show_commit, show_object, &info,
733733
(arg_print_omitted ? &omitted_objects : NULL));
734734

735735
if (arg_print_omitted) {

list-objects.c

+12-22
Original file line numberDiff line numberDiff line change
@@ -416,35 +416,25 @@ static void do_traverse(struct traversal_context *ctx)
416416
strbuf_release(&csp);
417417
}
418418

419-
void traverse_commit_list(struct rev_info *revs,
420-
show_commit_fn show_commit,
421-
show_object_fn show_object,
422-
void *show_data)
423-
{
424-
struct traversal_context ctx;
425-
ctx.revs = revs;
426-
ctx.show_commit = show_commit;
427-
ctx.show_object = show_object;
428-
ctx.show_data = show_data;
429-
ctx.filter = NULL;
430-
do_traverse(&ctx);
431-
}
432-
433419
void traverse_commit_list_filtered(
434-
struct list_objects_filter_options *filter_options,
435420
struct rev_info *revs,
436421
show_commit_fn show_commit,
437422
show_object_fn show_object,
438423
void *show_data,
439424
struct oidset *omitted)
440425
{
441-
struct traversal_context ctx;
426+
struct traversal_context ctx = {
427+
.revs = revs,
428+
.show_object = show_object,
429+
.show_commit = show_commit,
430+
.show_data = show_data,
431+
};
432+
433+
if (revs->filter.choice)
434+
ctx.filter = list_objects_filter__init(omitted, &revs->filter);
442435

443-
ctx.revs = revs;
444-
ctx.show_object = show_object;
445-
ctx.show_commit = show_commit;
446-
ctx.show_data = show_data;
447-
ctx.filter = list_objects_filter__init(omitted, filter_options);
448436
do_traverse(&ctx);
449-
list_objects_filter__free(ctx.filter);
437+
438+
if (ctx.filter)
439+
list_objects_filter__free(ctx.filter);
450440
}

list-objects.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ struct rev_info;
77

88
typedef void (*show_commit_fn)(struct commit *, void *);
99
typedef void (*show_object_fn)(struct object *, const char *, void *);
10-
void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
1110

1211
typedef void (*show_edge_fn)(struct commit *);
1312
void mark_edges_uninteresting(struct rev_info *revs,
@@ -18,11 +17,20 @@ struct oidset;
1817
struct list_objects_filter_options;
1918

2019
void traverse_commit_list_filtered(
21-
struct list_objects_filter_options *filter_options,
2220
struct rev_info *revs,
2321
show_commit_fn show_commit,
2422
show_object_fn show_object,
2523
void *show_data,
2624
struct oidset *omitted);
2725

26+
static inline void traverse_commit_list(
27+
struct rev_info *revs,
28+
show_commit_fn show_commit,
29+
show_object_fn show_object,
30+
void *show_data)
31+
{
32+
traverse_commit_list_filtered(revs, show_commit,
33+
show_object, show_data, NULL);
34+
}
35+
2836
#endif /* LIST_OBJECTS_H */

pack-bitmap.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
822822
show_data.bitmap_git = bitmap_git;
823823
show_data.base = base;
824824

825-
traverse_commit_list_filtered(&revs->filter, revs,
826-
show_commit, show_object,
827-
&show_data, NULL);
825+
traverse_commit_list(revs,
826+
show_commit, show_object,
827+
&show_data);
828828

829829
revs->include_check = NULL;
830830
revs->include_check_obj = NULL;

0 commit comments

Comments
 (0)