Skip to content

Commit ffaa137

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a4c3f9 commit ffaa137

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

builtin/rev-list.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ static const char rev_list_usage[] =
6262
static struct progress *progress;
6363
static unsigned progress_counter;
6464

65-
static struct list_objects_filter_options filter_options;
6665
static struct oidset omitted_objects;
6766
static int arg_print_omitted; /* print objects omitted by filter */
6867

@@ -400,7 +399,6 @@ static inline int parse_missing_action_value(const char *value)
400399
}
401400

402401
static int try_bitmap_count(struct rev_info *revs,
403-
struct list_objects_filter_options *filter,
404402
int filter_provided_objects)
405403
{
406404
uint32_t commit_count = 0,
@@ -436,7 +434,8 @@ static int try_bitmap_count(struct rev_info *revs,
436434
*/
437435
max_count = revs->max_count;
438436

439-
bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
437+
bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
438+
filter_provided_objects);
440439
if (!bitmap_git)
441440
return -1;
442441

@@ -453,7 +452,6 @@ static int try_bitmap_count(struct rev_info *revs,
453452
}
454453

455454
static int try_bitmap_traversal(struct rev_info *revs,
456-
struct list_objects_filter_options *filter,
457455
int filter_provided_objects)
458456
{
459457
struct bitmap_index *bitmap_git;
@@ -465,7 +463,8 @@ static int try_bitmap_traversal(struct rev_info *revs,
465463
if (revs->max_count >= 0)
466464
return -1;
467465

468-
bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
466+
bitmap_git = prepare_bitmap_walk(revs, &revs->filter,
467+
filter_provided_objects);
469468
if (!bitmap_git)
470469
return -1;
471470

@@ -475,15 +474,14 @@ static int try_bitmap_traversal(struct rev_info *revs,
475474
}
476475

477476
static int try_bitmap_disk_usage(struct rev_info *revs,
478-
struct list_objects_filter_options *filter,
479477
int filter_provided_objects)
480478
{
481479
struct bitmap_index *bitmap_git;
482480

483481
if (!show_disk_usage)
484482
return -1;
485483

486-
bitmap_git = prepare_bitmap_walk(revs, filter, filter_provided_objects);
484+
bitmap_git = prepare_bitmap_walk(revs, &revs->filter, filter_provided_objects);
487485
if (!bitmap_git)
488486
return -1;
489487

@@ -597,13 +595,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
597595
}
598596

599597
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)
602600
die(_("object filtering requires --objects"));
603601
continue;
604602
}
605603
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);
607605
continue;
608606
}
609607
if (!strcmp(arg, "--filter-provided-objects")) {
@@ -688,11 +686,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
688686
progress = start_delayed_progress(show_progress, 0);
689687

690688
if (use_bitmap_index) {
691-
if (!try_bitmap_count(&revs, &filter_options, filter_provided_objects))
689+
if (!try_bitmap_count(&revs, filter_provided_objects))
692690
return 0;
693-
if (!try_bitmap_disk_usage(&revs, &filter_options, filter_provided_objects))
691+
if (!try_bitmap_disk_usage(&revs, filter_provided_objects))
694692
return 0;
695-
if (!try_bitmap_traversal(&revs, &filter_options, filter_provided_objects))
693+
if (!try_bitmap_traversal(&revs, filter_provided_objects))
696694
return 0;
697695
}
698696

@@ -733,7 +731,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
733731
oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
734732

735733
traverse_commit_list_filtered(
736-
&filter_options, &revs, show_commit, show_object, &info,
734+
&revs.filter, &revs, show_commit, show_object, &info,
737735
(arg_print_omitted ? &omitted_objects : NULL));
738736

739737
if (arg_print_omitted) {

revision.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "pretty.h"
99
#include "diff.h"
1010
#include "commit-slab-decl.h"
11+
#include "list-objects-filter-options.h"
1112

1213
/**
1314
* The revision walking API offers functions to build a list of revisions
@@ -94,6 +95,12 @@ struct rev_info {
9495
/* The end-points specified by the end user */
9596
struct rev_cmdline_info cmdline;
9697

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+
97104
/* excluding from --branches, --refs, etc. expansion */
98105
struct string_list *ref_excludes;
99106

0 commit comments

Comments
 (0)