]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: put object filter into struct rev_info
authorDerrick Stolee <derrickstolee@github.com>
Wed, 9 Mar 2022 16:01:33 +0000 (16:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Mar 2022 18:25:26 +0000 (10:25 -0800)
Placing a 'struct list_objects_filter_options' within 'struct rev_info'
will assist making some bookkeeping around object filters in the future.

For now, let's use this new member to remove a static global instance of
the struct from builtin/rev-list.c.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-list.c
revision.h

index 777558e9b067ebbf7e91ba4e65570a86bd25a105..1beb578cc51997cc89d4adab0fb1e94e0f5ccfa5 100644 (file)
@@ -62,7 +62,6 @@ static const char rev_list_usage[] =
 static struct progress *progress;
 static unsigned progress_counter;
 
-static struct list_objects_filter_options filter_options;
 static struct oidset omitted_objects;
 static int arg_print_omitted; /* print objects omitted by filter */
 
@@ -400,7 +399,6 @@ static inline int parse_missing_action_value(const char *value)
 }
 
 static int try_bitmap_count(struct rev_info *revs,
-                           struct list_objects_filter_options *filter,
                            int filter_provided_objects)
 {
        uint32_t commit_count = 0,
@@ -436,7 +434,8 @@ static int try_bitmap_count(struct rev_info *revs,
         */
        max_count = revs->max_count;
 
-       bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
+       bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
+                                        filter_provided_objects);
        if (!bitmap_git)
                return -1;
 
@@ -453,7 +452,6 @@ static int try_bitmap_count(struct rev_info *revs,
 }
 
 static int try_bitmap_traversal(struct rev_info *revs,
-                               struct list_objects_filter_options *filter,
                                int filter_provided_objects)
 {
        struct bitmap_index *bitmap_git;
@@ -465,7 +463,8 @@ static int try_bitmap_traversal(struct rev_info *revs,
        if (revs->max_count >= 0)
                return -1;
 
-       bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
+       bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
+                                        filter_provided_objects);
        if (!bitmap_git)
                return -1;
 
@@ -475,7 +474,6 @@ static int try_bitmap_traversal(struct rev_info *revs,
 }
 
 static int try_bitmap_disk_usage(struct rev_info *revs,
-                                struct list_objects_filter_options *filter,
                                 int filter_provided_objects)
 {
        struct bitmap_index *bitmap_git;
@@ -483,7 +481,7 @@ static int try_bitmap_disk_usage(struct rev_info *revs,
        if (!show_disk_usage)
                return -1;
 
-       bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
+       bitmap_git = prepare_bitmap_walk(revs, &revs->filter, filter_provided_objects);
        if (!bitmap_git)
                return -1;
 
@@ -597,13 +595,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                }
 
                if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
-                       parse_list_objects_filter(&filter_options, arg);
-                       if (filter_options.choice && !revs.blob_objects)
+                       parse_list_objects_filter(&revs.filter, arg);
+                       if (revs.filter.choice && !revs.blob_objects)
                                die(_("object filtering requires --objects"));
                        continue;
                }
                if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) {
-                       list_objects_filter_set_no_filter(&filter_options);
+                       list_objects_filter_set_no_filter(&revs.filter);
                        continue;
                }
                if (!strcmp(arg, "--filter-provided-objects")) {
@@ -688,11 +686,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                progress = start_delayed_progress(show_progress, 0);
 
        if (use_bitmap_index) {
-               if (!try_bitmap_count(&revs, &filter_options, filter_provided_objects))
+               if (!try_bitmap_count(&revs, filter_provided_objects))
                        return 0;
-               if (!try_bitmap_disk_usage(&revs, &filter_options, filter_provided_objects))
+               if (!try_bitmap_disk_usage(&revs, filter_provided_objects))
                        return 0;
-               if (!try_bitmap_traversal(&revs, &filter_options, filter_provided_objects))
+               if (!try_bitmap_traversal(&revs, filter_provided_objects))
                        return 0;
        }
 
@@ -733,7 +731,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
 
        traverse_commit_list_filtered(
-               &filter_options, &revs, show_commit, show_object, &info,
+               &revs.filter, &revs, show_commit, show_object, &info,
                (arg_print_omitted ? &omitted_objects : NULL));
 
        if (arg_print_omitted) {
index b9c2421687fef8e5e1d90cdcefa163165573d7ad..5bc59c7bfe1e35efe7fb24e93f9a093baa28b658 100644 (file)
@@ -8,6 +8,7 @@
 #include "pretty.h"
 #include "diff.h"
 #include "commit-slab-decl.h"
+#include "list-objects-filter-options.h"
 
 /**
  * The revision walking API offers functions to build a list of revisions
@@ -94,6 +95,12 @@ struct rev_info {
        /* The end-points specified by the end user */
        struct rev_cmdline_info cmdline;
 
+       /*
+        * Object filter options. No filtering is specified
+        * if and only if filter.choice is zero.
+        */
+       struct list_objects_filter_options filter;
+
        /* excluding from --branches, --refs, etc. expansion */
        struct string_list *ref_excludes;