revision.c: put promisor option in specialized struct
authorMatthew DeVore <matvore@google.com>
Mon, 3 Dec 2018 22:10:19 +0000 (14:10 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Dec 2018 05:52:56 +0000 (14:52 +0900)
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>
builtin/pack-objects.c
builtin/prune.c
builtin/rev-list.c
revision.c
revision.h
index 8ac8ca1d2609422d603b2a1f8e65027e4e8c0697..4408807e62de8cc0721e2a567d98ded042a0087d 100644 (file)
@@ -2848,13 +2848,15 @@ static void record_recent_commit(struct commit *commit, void *data)
 static void get_object_list(int ac, const char **av)
 {
        struct rev_info revs;
+       struct setup_revision_opt s_r_opt = {
+               .allow_exclude_promisor_objects = 1,
+       };
        char line[1000];
        int flags = 0;
 
        init_revisions(&revs, NULL);
        save_commit_buffer = 0;
-       revs.allow_exclude_promisor_objects_opt = 1;
-       setup_revisions(ac, av, &revs, NULL);
+       setup_revisions(ac, av, &revs, &s_r_opt);
 
        /* make sure shallows are read */
        is_repository_shallow();
index a5c784749eaebd92655800ab87b2df5512501603..4394d01c9350ae3e1fa26de034edf1509128469e 100644 (file)
@@ -118,7 +118,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
        save_commit_buffer = 0;
        check_replace_refs = 0;
        ref_paranoia = 1;
-       revs.allow_exclude_promisor_objects_opt = 1;
        init_revisions(&revs, prefix);
 
        argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
index c8f3ac8d0927e67ea913299bc26173d870d7b29c..807a50a2fb3f59d8dbd67378b1a4336f0a21aa25 100644 (file)
@@ -357,6 +357,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
        struct rev_list_info info;
+       struct setup_revision_opt s_r_opt = {
+               .allow_exclude_promisor_objects = 1,
+       };
        int i;
        int bisect_list = 0;
        int bisect_show_vars = 0;
@@ -370,7 +373,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
        git_config(git_default_config, NULL);
        init_revisions(&revs, prefix);
        revs.abbrev = DEFAULT_ABBREV;
-       revs.allow_exclude_promisor_objects_opt = 1;
        revs.commit_format = CMIT_FMT_UNSPECIFIED;
 
        /*
@@ -401,7 +403,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                }
        }
 
-       argc = setup_revisions(argc, argv, &revs, NULL);
+       argc = setup_revisions(argc, argv, &revs, &s_r_opt);
 
        memset(&info, 0, sizeof(info));
        info.revs = &revs;
index 748310c2a3b194322dae8fe586b9a247c186a6b1..f19de0de34f66aecc3d09108942607c40b7d66ef 100644 (file)
@@ -1746,7 +1746,8 @@ static void add_message_grep(struct rev_info *revs, const char *pattern)
 }
 
 static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
-                              int *unkc, const char **unkv)
+                              int *unkc, const char **unkv,
+                              const struct setup_revision_opt* opt)
 {
        const char *arg = argv[0];
        const char *optarg;
@@ -2105,7 +2106,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->limited = 1;
        } else if (!strcmp(arg, "--ignore-missing")) {
                revs->ignore_missing = 1;
-       } else if (revs->allow_exclude_promisor_objects_opt &&
+       } else if (opt && opt->allow_exclude_promisor_objects &&
                   !strcmp(arg, "--exclude-promisor-objects")) {
                if (fetch_if_missing)
                        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,
                        const char * const usagestr[])
 {
        int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
-                                   &ctx->cpidx, ctx->out);
+                                   &ctx->cpidx, ctx->out, NULL);
        if (n <= 0) {
                error("unknown option `%s'", ctx->argv[0]);
                usage_with_options(usagestr, options);
@@ -2346,7 +2347,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                                continue;
                        }
 
-                       opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
+                       opts = handle_revision_opt(revs, argc - i, argv + i,
+                                                  &left, argv, opt);
                        if (opts > 0) {
                                i += opts - 1;
                                continue;
index e892a40cd9a0df6e1c184457d69245cb36a711f6..8b81ae334233bf10cf2b25ccf2e4f7e22afa2560 100644 (file)
@@ -124,7 +124,6 @@ struct rev_info {
                        tree_blobs_in_commit_order:1,
 
                        /* for internal use only */
-                       allow_exclude_promisor_objects_opt:1,
                        exclude_promisor_objects:1;
 
        /* Diff flags */
@@ -245,7 +244,8 @@ struct setup_revision_opt {
        const char *def;
        void (*tweak)(struct rev_info *, struct setup_revision_opt *);
        const char *submodule;
-       int assume_dashdash;
+       unsigned int    assume_dashdash:1,
+                       allow_exclude_promisor_objects:1;
        unsigned revarg_opt;
 };