Skip to content

Commit bbcde41

Browse files
matvoregitster
authored andcommitted
revision.c: put promisor option in specialized struct
Put the allow_exclude_promisor_objects flag in setup_revision_opt. When it was in rev_info, it was unclear when it was used, since rev_info is passed to functions that don't use the flag. This resulted in unnecessary setting of the flag in prune.c, so fix that as well. Signed-off-by: Matthew DeVore <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 669b1d2 commit bbcde41

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
@@ -2848,13 +2848,15 @@ static void record_recent_commit(struct commit *commit, void *data)
28482848
static void get_object_list(int ac, const char **av)
28492849
{
28502850
struct rev_info revs;
2851+
struct setup_revision_opt s_r_opt = {
2852+
.allow_exclude_promisor_objects = 1,
2853+
};
28512854
char line[1000];
28522855
int flags = 0;
28532856

28542857
init_revisions(&revs, NULL);
28552858
save_commit_buffer = 0;
2856-
revs.allow_exclude_promisor_objects_opt = 1;
2857-
setup_revisions(ac, av, &revs, NULL);
2859+
setup_revisions(ac, av, &revs, &s_r_opt);
28582860

28592861
/* make sure shallows are read */
28602862
is_repository_shallow();

builtin/prune.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
118118
save_commit_buffer = 0;
119119
check_replace_refs = 0;
120120
ref_paranoia = 1;
121-
revs.allow_exclude_promisor_objects_opt = 1;
122121
init_revisions(&revs, prefix);
123122

124123
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
@@ -357,6 +357,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
357357
{
358358
struct rev_info revs;
359359
struct rev_list_info info;
360+
struct setup_revision_opt s_r_opt = {
361+
.allow_exclude_promisor_objects = 1,
362+
};
360363
int i;
361364
int bisect_list = 0;
362365
int bisect_show_vars = 0;
@@ -370,7 +373,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
370373
git_config(git_default_config, NULL);
371374
init_revisions(&revs, prefix);
372375
revs.abbrev = DEFAULT_ABBREV;
373-
revs.allow_exclude_promisor_objects_opt = 1;
374376
revs.commit_format = CMIT_FMT_UNSPECIFIED;
375377

376378
/*
@@ -401,7 +403,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
401403
}
402404
}
403405

404-
argc = setup_revisions(argc, argv, &revs, NULL);
406+
argc = setup_revisions(argc, argv, &revs, &s_r_opt);
405407

406408
memset(&info, 0, sizeof(info));
407409
info.revs = &revs;

revision.c

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

17481748
static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
1749-
int *unkc, const char **unkv)
1749+
int *unkc, const char **unkv,
1750+
const struct setup_revision_opt* opt)
17501751
{
17511752
const char *arg = argv[0];
17521753
const char *optarg;
@@ -2105,7 +2106,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
21052106
revs->limited = 1;
21062107
} else if (!strcmp(arg, "--ignore-missing")) {
21072108
revs->ignore_missing = 1;
2108-
} else if (revs->allow_exclude_promisor_objects_opt &&
2109+
} else if (opt && opt->allow_exclude_promisor_objects &&
21092110
!strcmp(arg, "--exclude-promisor-objects")) {
21102111
if (fetch_if_missing)
21112112
die("BUG: exclude_promisor_objects can only be used when fetch_if_missing is 0");
@@ -2127,7 +2128,7 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
21272128
const char * const usagestr[])
21282129
{
21292130
int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
2130-
&ctx->cpidx, ctx->out);
2131+
&ctx->cpidx, ctx->out, NULL);
21312132
if (n <= 0) {
21322133
error("unknown option `%s'", ctx->argv[0]);
21332134
usage_with_options(usagestr, options);
@@ -2346,7 +2347,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
23462347
continue;
23472348
}
23482349

2349-
opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
2350+
opts = handle_revision_opt(revs, argc - i, argv + i,
2351+
&left, argv, opt);
23502352
if (opts > 0) {
23512353
i += opts - 1;
23522354
continue;

revision.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ struct rev_info {
124124
tree_blobs_in_commit_order:1,
125125

126126
/* for internal use only */
127-
allow_exclude_promisor_objects_opt:1,
128127
exclude_promisor_objects:1;
129128

130129
/* Diff flags */
@@ -245,7 +244,8 @@ struct setup_revision_opt {
245244
const char *def;
246245
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
247246
const char *submodule;
248-
int assume_dashdash;
247+
unsigned int assume_dashdash:1,
248+
allow_exclude_promisor_objects:1;
249249
unsigned revarg_opt;
250250
};
251251

0 commit comments

Comments
 (0)