revision: put object filter into struct rev_info
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>
Derrick Stolee committed
Mar 9, 2022 at 16:01 UTC
ffaa137f646803749cf81017d3208be2ce8a2964
2 files changed
+19
-14
builtin/rev-list.c
+12
-14
@@ -62,7 +62,6 @@ static const char rev_list_usage[] =
62
static struct progress *progress;
63
static unsigned progress_counter;
64
65
-static struct list_objects_filter_options filter_options;
65
static struct oidset omitted_objects;
66
static int arg_print_omitted; /* print objects omitted by filter */
67
@@ -400,7 +399,6 @@ static inline int parse_missing_action_value(const char *value)
399
}
400
401
static int try_bitmap_count(struct rev_info *revs,
403
- struct list_objects_filter_options *filter,
402
int filter_provided_objects)
403
{
404
uint32_t commit_count = 0,
@@ -436,7 +434,8 @@ static int try_bitmap_count(struct rev_info *revs,
434
*/
435
max_count = revs->max_count;
436
439
- bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
437
+ bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
438
+ filter_provided_objects);
439
if (!bitmap_git)
440
return -1;
441
@@ -453,7 +452,6 @@ static int try_bitmap_count(struct rev_info *revs,
452
}
453
454
static int try_bitmap_traversal(struct rev_info *revs,
456
- struct list_objects_filter_options *filter,
455
int filter_provided_objects)
456
{
457
struct bitmap_index *bitmap_git;
@@ -465,7 +463,8 @@ static int try_bitmap_traversal(struct rev_info *revs,
463
if (revs->max_count >= 0)
464
return -1;
465
468
- bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
466
+ bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
467
+ filter_provided_objects);
468
if (!bitmap_git)
469
return -1;
470
@@ -475,7 +474,6 @@ static int try_bitmap_traversal(struct rev_info *revs,
474
}
475
476
static int try_bitmap_disk_usage(struct rev_info *revs,
478
- struct list_objects_filter_options *filter,
477
int filter_provided_objects)
478
{
479
struct bitmap_index *bitmap_git;
@@ -483,7 +481,7 @@ static int try_bitmap_disk_usage(struct rev_info *revs,
481
if (!show_disk_usage)
482
return -1;
483
486
- bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
484
+ bitmap_git = prepare_bitmap_walk(revs, &revs->filter, filter_provided_objects);
485
if (!bitmap_git)
486
return -1;
487
@@ -597,13 +595,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
595
}
596
597
if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
600
- parse_list_objects_filter(&filter_options, arg);
601
- if (filter_options.choice && !revs.blob_objects)
598
+ parse_list_objects_filter(&revs.filter, arg);
599
+ if (revs.filter.choice && !revs.blob_objects)
600
die(_("object filtering requires --objects"));
601
continue;
602
}
603
if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) {
606
- list_objects_filter_set_no_filter(&filter_options);
604
+ list_objects_filter_set_no_filter(&revs.filter);
605
continue;
606
}
607
if (!strcmp(arg, "--filter-provided-objects")) {
@@ -688,11 +686,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
686
progress = start_delayed_progress(show_progress, 0);
687
688
if (use_bitmap_index) {
691
- if (!try_bitmap_count(&revs, &filter_options, filter_provided_objects))
689
+ if (!try_bitmap_count(&revs, filter_provided_objects))
690
return 0;
693
- if (!try_bitmap_disk_usage(&revs, &filter_options, filter_provided_objects))
691
+ if (!try_bitmap_disk_usage(&revs, filter_provided_objects))
692
return 0;
695
- if (!try_bitmap_traversal(&revs, &filter_options, filter_provided_objects))
693
+ if (!try_bitmap_traversal(&revs, filter_provided_objects))
694
return 0;
695
}
696
@@ -733,7 +731,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
731
oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
732
733
traverse_commit_list_filtered(
736
- &filter_options, &revs, show_commit, show_object, &info,
734
+ &revs.filter, &revs, show_commit, show_object, &info,
735
(arg_print_omitted ? &omitted_objects : NULL));
736
737
if (arg_print_omitted) {
revision.h
+7
@@ -8,6 +8,7 @@
8
#include "pretty.h"
9
#include "diff.h"
10
#include "commit-slab-decl.h"
11
+#include "list-objects-filter-options.h"
12
13
/**
14
* The revision walking API offers functions to build a list of revisions
@@ -94,6 +95,12 @@ struct rev_info {
95
/* The end-points specified by the end user */
96
struct rev_cmdline_info cmdline;
97
98
+ /*
99
+ * Object filter options. No filtering is specified
100
+ * if and only if filter.choice is zero.
101
+ */
102
+ struct list_objects_filter_options filter;
103
+
104
/* excluding from --branches, --refs, etc. expansion */
105
struct string_list *ref_excludes;
106