Skip to content

Commit 6e5be1f

Browse files
committed
Merge branch 'md/exclude-promisor-objects-fix-cleanup'
Code clean-up. * md/exclude-promisor-objects-fix-cleanup: revision.c: put promisor option in specialized struct
2 parents ecdc7cb + bbcde41 commit 6e5be1f

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

builtin/pack-objects.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,14 +3084,16 @@ static void record_recent_commit(struct commit *commit, void *data)
30843084
static void get_object_list(int ac, const char **av)
30853085
{
30863086
struct rev_info revs;
3087+
struct setup_revision_opt s_r_opt = {
3088+
.allow_exclude_promisor_objects = 1,
3089+
};
30873090
char line[1000];
30883091
int flags = 0;
30893092
int save_warning;
30903093

30913094
repo_init_revisions(the_repository, &revs, NULL);
30923095
save_commit_buffer = 0;
3093-
revs.allow_exclude_promisor_objects_opt = 1;
3094-
setup_revisions(ac, av, &revs, NULL);
3096+
setup_revisions(ac, av, &revs, &s_r_opt);
30953097

30963098
/* make sure shallows are read */
30973099
is_repository_shallow(the_repository);

builtin/prune.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
120120
save_commit_buffer = 0;
121121
read_replace_refs = 0;
122122
ref_paranoia = 1;
123-
revs.allow_exclude_promisor_objects_opt = 1;
124123
repo_init_revisions(the_repository, &revs, prefix);
125124

126125
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);

builtin/rev-list.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
361361
{
362362
struct rev_info revs;
363363
struct rev_list_info info;
364+
struct setup_revision_opt s_r_opt = {
365+
.allow_exclude_promisor_objects = 1,
366+
};
364367
int i;
365368
int bisect_list = 0;
366369
int bisect_show_vars = 0;
@@ -374,7 +377,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
374377
git_config(git_default_config, NULL);
375378
repo_init_revisions(the_repository, &revs, prefix);
376379
revs.abbrev = DEFAULT_ABBREV;
377-
revs.allow_exclude_promisor_objects_opt = 1;
378380
revs.commit_format = CMIT_FMT_UNSPECIFIED;
379381
revs.do_not_die_on_missing_tree = 1;
380382

@@ -406,7 +408,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
406408
}
407409
}
408410

409-
argc = setup_revisions(argc, argv, &revs, NULL);
411+
argc = setup_revisions(argc, argv, &revs, &s_r_opt);
410412

411413
memset(&info, 0, sizeof(info));
412414
info.revs = &revs;

revision.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,8 @@ static void add_message_grep(struct rev_info *revs, const char *pattern)
17941794
}
17951795

17961796
static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
1797-
int *unkc, const char **unkv)
1797+
int *unkc, const char **unkv,
1798+
const struct setup_revision_opt* opt)
17981799
{
17991800
const char *arg = argv[0];
18001801
const char *optarg;
@@ -2154,7 +2155,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
21542155
revs->limited = 1;
21552156
} else if (!strcmp(arg, "--ignore-missing")) {
21562157
revs->ignore_missing = 1;
2157-
} else if (revs->allow_exclude_promisor_objects_opt &&
2158+
} else if (opt && opt->allow_exclude_promisor_objects &&
21582159
!strcmp(arg, "--exclude-promisor-objects")) {
21592160
if (fetch_if_missing)
21602161
BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0");
@@ -2176,7 +2177,7 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
21762177
const char * const usagestr[])
21772178
{
21782179
int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
2179-
&ctx->cpidx, ctx->out);
2180+
&ctx->cpidx, ctx->out, NULL);
21802181
if (n <= 0) {
21812182
error("unknown option `%s'", ctx->argv[0]);
21822183
usage_with_options(usagestr, options);
@@ -2394,7 +2395,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
23942395
continue;
23952396
}
23962397

2397-
opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
2398+
opts = handle_revision_opt(revs, argc - i, argv + i,
2399+
&left, argv, opt);
23982400
if (opts > 0) {
23992401
i += opts - 1;
24002402
continue;

revision.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ struct rev_info {
161161
do_not_die_on_missing_tree:1,
162162

163163
/* for internal use only */
164-
allow_exclude_promisor_objects_opt:1,
165164
exclude_promisor_objects:1;
166165

167166
/* Diff flags */
@@ -297,7 +296,8 @@ struct setup_revision_opt {
297296
const char *def;
298297
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
299298
const char *submodule; /* TODO: drop this and use rev_info->repo */
300-
int assume_dashdash;
299+
unsigned int assume_dashdash:1,
300+
allow_exclude_promisor_objects:1;
301301
unsigned revarg_opt;
302302
};
303303

0 commit comments

Comments
 (0)