]> git.ipfire.org Git - thirdparty/git.git/commitdiff
exclude-promisor-objects: declare when option is allowed
authorMatthew DeVore <matvore@google.com>
Tue, 23 Oct 2018 01:13:42 +0000 (18:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Oct 2018 04:52:57 +0000 (13:52 +0900)
The --exclude-promisor-objects option causes some funny behavior in at
least two commands: log and blame. It causes a BUG crash:

$ git log --exclude-promisor-objects
BUG: revision.c:2143: exclude_promisor_objects can only be used
when fetch_if_missing is 0
Aborted
[134]

Fix this such that the option is treated like any other unknown option.
The commands that must support it are limited, so declare in those
commands that the flag is supported. In particular:

pack-objects
prune
rev-list

The commands were found by searching for logic which parses
--exclude-promisor-objects outside of revision.c. Extra logic outside of
revision.c is needed because fetch_if_missing must be turned on before
revision.c sees the option or it will BUG-crash. The above list is
supported by the fact that no other command is introspectively invoked
by another command passing --exclude-promisor-object.

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
t/t4202-log.sh
t/t8002-blame.sh

index e9d3cfb9e33a6b874751ac6acc5aac2361d4a58d..8ac8ca1d2609422d603b2a1f8e65027e4e8c0697 100644 (file)
@@ -2853,6 +2853,7 @@ static void get_object_list(int ac, const char **av)
 
        init_revisions(&revs, NULL);
        save_commit_buffer = 0;
+       revs.allow_exclude_promisor_objects_opt = 1;
        setup_revisions(ac, av, &revs, NULL);
 
        /* make sure shallows are read */
index 4394d01c9350ae3e1fa26de034edf1509128469e..a5c784749eaebd92655800ab87b2df5512501603 100644 (file)
@@ -118,6 +118,7 @@ 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 6f5b9b0847321ca214b4d32719eaeacefffd5ce4..c8f3ac8d0927e67ea913299bc26173d870d7b29c 100644 (file)
@@ -370,6 +370,7 @@ 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;
 
        /*
index b42c836d7a64a67779c587954bcab90d919aaffb..748310c2a3b194322dae8fe586b9a247c186a6b1 100644 (file)
@@ -2105,7 +2105,8 @@ 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 (!strcmp(arg, "--exclude-promisor-objects")) {
+       } else if (revs->allow_exclude_promisor_objects_opt &&
+                  !strcmp(arg, "--exclude-promisor-objects")) {
                if (fetch_if_missing)
                        die("BUG: exclude_promisor_objects can only be used when fetch_if_missing is 0");
                revs->exclude_promisor_objects = 1;
index b8c47b98e22562ef320197b4ddbc8f0c3ee40f98..e892a40cd9a0df6e1c184457d69245cb36a711f6 100644 (file)
@@ -124,6 +124,7 @@ 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 */
index 25b1f8cc73bc35bedaaffeacbb75a1329d725c3b..61610ce08e921ed937bac60a3a12f12afc7fcfb1 100755 (executable)
@@ -1668,4 +1668,8 @@ test_expect_success 'log --source paints symmetric ranges' '
        test_cmp expect actual
 '
 
+test_expect_success '--exclude-promisor-objects does not BUG-crash' '
+       test_must_fail git log --exclude-promisor-objects source-a
+'
+
 test_done
index 380e1c1054de5d55a80cb558fea0791884ad7f38..eea048e52ceb328fd5d97b17e996c8f821ae4abb 100755 (executable)
@@ -118,4 +118,8 @@ test_expect_success '--no-abbrev works like --abbrev=40' '
        check_abbrev 40 --no-abbrev
 '
 
+test_expect_success '--exclude-promisor-objects does not BUG-crash' '
+       test_must_fail git blame --exclude-promisor-objects one
+'
+
 test_done