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 <matvore@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthew DeVore committed
Dec 3, 2018 at 14:10 UTC
bbcde41a70a7e0264c214896aac84d1ec3fdcbf6
5 files changed
+16
-11
builtin/pack-objects.c
+4
-2
@@ -2848,13 +2848,15 @@ static void record_recent_commit(struct commit *commit, void *data)
2848
static void get_object_list(int ac, const char **av)
2849
{
2850
struct rev_info revs;
2851
+ struct setup_revision_opt s_r_opt = {
2852
+ .allow_exclude_promisor_objects = 1,
2853
+ };
2854
char line[1000];
2855
int flags = 0;
2856
2857
init_revisions(&revs, NULL);
2858
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);
2860
2861
/* make sure shallows are read */
2862
is_repository_shallow();
builtin/prune.c
-1
@@ -118,7 +118,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
118
save_commit_buffer = 0;
119
check_replace_refs = 0;
120
ref_paranoia = 1;
121
- revs.allow_exclude_promisor_objects_opt = 1;
121
init_revisions(&revs, prefix);
122
123
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
builtin/rev-list.c
+4
-2
@@ -357,6 +357,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
357
{
358
struct rev_info revs;
359
struct rev_list_info info;
360
+ struct setup_revision_opt s_r_opt = {
361
+ .allow_exclude_promisor_objects = 1,
362
+ };
363
int i;
364
int bisect_list = 0;
365
int bisect_show_vars = 0;
@@ -370,7 +373,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
373
git_config(git_default_config, NULL);
374
init_revisions(&revs, prefix);
375
revs.abbrev = DEFAULT_ABBREV;
373
- revs.allow_exclude_promisor_objects_opt = 1;
376
revs.commit_format = CMIT_FMT_UNSPECIFIED;
377
378
/*
@@ -401,7 +403,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
403
}
404
}
405
404
- argc = setup_revisions(argc, argv, &revs, NULL);
406
+ argc = setup_revisions(argc, argv, &revs, &s_r_opt);
407
408
memset(&info, 0, sizeof(info));
409
info.revs = &revs;
revision.c
+6
-4
@@ -1746,7 +1746,8 @@ static void add_message_grep(struct rev_info *revs, const char *pattern)
1746
}
1747
1748
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)
1751
{
1752
const char *arg = argv[0];
1753
const char *optarg;
@@ -2105,7 +2106,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
2106
revs->limited = 1;
2107
} else if (!strcmp(arg, "--ignore-missing")) {
2108
revs->ignore_missing = 1;
2108
- } else if (revs->allow_exclude_promisor_objects_opt &&
2109
+ } else if (opt && opt->allow_exclude_promisor_objects &&
2110
!strcmp(arg, "--exclude-promisor-objects")) {
2111
if (fetch_if_missing)
2112
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,
2128
const char * const usagestr[])
2129
{
2130
int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
2130
- &ctx->cpidx, ctx->out);
2131
+ &ctx->cpidx, ctx->out, NULL);
2132
if (n <= 0) {
2133
error("unknown option `%s'", ctx->argv[0]);
2134
usage_with_options(usagestr, options);
@@ -2346,7 +2347,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2347
continue;
2348
}
2349
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);
2352
if (opts > 0) {
2353
i += opts - 1;
2354
continue;
revision.h
+2
-2
@@ -124,7 +124,6 @@ struct rev_info {
124
tree_blobs_in_commit_order:1,
125
126
/* for internal use only */
127
- allow_exclude_promisor_objects_opt:1,
127
exclude_promisor_objects:1;
128
129
/* Diff flags */
@@ -245,7 +244,8 @@ struct setup_revision_opt {
244
const char *def;
245
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
246
const char *submodule;
248
- int assume_dashdash;
247
+ unsigned int assume_dashdash:1,
248
+ allow_exclude_promisor_objects:1;
249
unsigned revarg_opt;
250
};
251