]> git.ipfire.org Git - thirdparty/git.git/commitdiff
list-objects: consolidate traverse_commit_list[_filtered]
authorDerrick Stolee <derrickstolee@github.com>
Wed, 9 Mar 2022 16:01:36 +0000 (16:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Mar 2022 18:25:27 +0000 (10:25 -0800)
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 <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
builtin/rev-list.c
list-objects.c
list-objects.h
pack-bitmap.c

index ddd698a1fea6bbb2a2e027cefd32c08829873959..ae7dbc8c8ac40ee5e1a3838dd1d42cbc444df73b 100644 (file)
@@ -3778,9 +3778,9 @@ static void get_object_list(int ac, const char **av)
 
        if (!fn_show_object)
                fn_show_object = show_object;
-       traverse_commit_list_filtered(&revs.filter, &revs,
-                                     show_commit, fn_show_object, NULL,
-                                     NULL);
+       traverse_commit_list(&revs,
+                            show_commit, fn_show_object,
+                            NULL);
 
        if (unpack_unreachable_expiration) {
                revs.ignore_missing_links = 1;
index ab7558bd66af8e67b3d05c8abdcc77fb79a25b25..ec433cb6d373a705ac3346ed54a05b65b233e538 100644 (file)
@@ -729,7 +729,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
 
        traverse_commit_list_filtered(
-               &revs.filter, &revs, show_commit, show_object, &info,
+               &revs, show_commit, show_object, &info,
                (arg_print_omitted ? &omitted_objects : NULL));
 
        if (arg_print_omitted) {
index 2f623f8211534dabe732b1da140a2512a5a5fcf5..117f734398ca5f385ae586e31131ddebb9523a3b 100644 (file)
@@ -416,35 +416,25 @@ static void do_traverse(struct traversal_context *ctx)
        strbuf_release(&csp);
 }
 
-void traverse_commit_list(struct rev_info *revs,
-                         show_commit_fn show_commit,
-                         show_object_fn show_object,
-                         void *show_data)
-{
-       struct traversal_context ctx;
-       ctx.revs = revs;
-       ctx.show_commit = show_commit;
-       ctx.show_object = show_object;
-       ctx.show_data = show_data;
-       ctx.filter = NULL;
-       do_traverse(&ctx);
-}
-
 void traverse_commit_list_filtered(
-       struct list_objects_filter_options *filter_options,
        struct rev_info *revs,
        show_commit_fn show_commit,
        show_object_fn show_object,
        void *show_data,
        struct oidset *omitted)
 {
-       struct traversal_context ctx;
+       struct traversal_context ctx = {
+               .revs = revs,
+               .show_object = show_object,
+               .show_commit = show_commit,
+               .show_data = show_data,
+       };
+
+       if (revs->filter.choice)
+               ctx.filter = list_objects_filter__init(omitted, &revs->filter);
 
-       ctx.revs = revs;
-       ctx.show_object = show_object;
-       ctx.show_commit = show_commit;
-       ctx.show_data = show_data;
-       ctx.filter = list_objects_filter__init(omitted, filter_options);
        do_traverse(&ctx);
-       list_objects_filter__free(ctx.filter);
+
+       if (ctx.filter)
+               list_objects_filter__free(ctx.filter);
 }
index a952680e46671db2543bc4abff78a2d898cd1408..9eaf4de844950017a947df7efbcceaf9f0d9feb5 100644 (file)
@@ -7,7 +7,6 @@ struct rev_info;
 
 typedef void (*show_commit_fn)(struct commit *, void *);
 typedef void (*show_object_fn)(struct object *, const char *, void *);
-void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
 
 typedef void (*show_edge_fn)(struct commit *);
 void mark_edges_uninteresting(struct rev_info *revs,
@@ -18,11 +17,20 @@ struct oidset;
 struct list_objects_filter_options;
 
 void traverse_commit_list_filtered(
-       struct list_objects_filter_options *filter_options,
        struct rev_info *revs,
        show_commit_fn show_commit,
        show_object_fn show_object,
        void *show_data,
        struct oidset *omitted);
 
+static inline void traverse_commit_list(
+       struct rev_info *revs,
+       show_commit_fn show_commit,
+       show_object_fn show_object,
+       void *show_data)
+{
+       traverse_commit_list_filtered(revs, show_commit,
+                                     show_object, show_data, NULL);
+}
+
 #endif /* LIST_OBJECTS_H */
index 37fa490579602c097af9cc794a09d5ccbb182679..97909d48da381f81622d36fb5889fd5d7013b04a 100644 (file)
@@ -822,9 +822,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
                show_data.bitmap_git = bitmap_git;
                show_data.base = base;
 
-               traverse_commit_list_filtered(&revs->filter, revs,
-                                             show_commit, show_object,
-                                             &show_data, NULL);
+               traverse_commit_list(revs,
+                                    show_commit, show_object,
+                                    &show_data);
 
                revs->include_check = NULL;
                revs->include_check_obj = NULL;