From 368a89124c3ad859631452f7b012d0ad939375f3 Mon Sep 17 00:00:00 2001 From: Matthew DeVore Date: Mon, 22 Oct 2018 18:13:41 -0700 Subject: [PATCH 1/2] Documentation/git-log.txt: do not show --exclude-promisor-objects Do not suggest that --exclude-promisor-objects is supported by git-log, since it currently BUG-crashes and it's not necessary to support it. Options that control behavior for promisor objects should be limited to a small number of commands. Signed-off-by: Matthew DeVore Signed-off-by: Junio C Hamano --- Documentation/rev-list-options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 7b273635de..21978ebbac 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -756,7 +756,6 @@ Unexpected missing objects will raise an error. + The form '--missing=print' is like 'allow-any', but will also print a list of the missing objects. Object IDs are prefixed with a ``?'' character. -endif::git-rev-list[] --exclude-promisor-objects:: (For internal use only.) Prefilter object traversal at @@ -764,6 +763,7 @@ endif::git-rev-list[] stronger than `--missing=allow-promisor` because it limits the traversal, rather than just silencing errors about missing objects. +endif::git-rev-list[] --no-walk[=(sorted|unsorted)]:: Only show the given commits, but do not traverse their ancestors. From 669b1d2aaec73ba762bf566078308075886ca208 Mon Sep 17 00:00:00 2001 From: Matthew DeVore Date: Mon, 22 Oct 2018 18:13:42 -0700 Subject: [PATCH 2/2] exclude-promisor-objects: declare when option is allowed 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 Signed-off-by: Junio C Hamano --- builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/rev-list.c | 1 + revision.c | 3 ++- revision.h | 1 + t/t4202-log.sh | 4 ++++ t/t8002-blame.sh | 4 ++++ 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index e9d3cfb9e3..8ac8ca1d26 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -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 */ diff --git a/builtin/prune.c b/builtin/prune.c index 4394d01c93..a5c784749e 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -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); diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 6f5b9b0847..c8f3ac8d09 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -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; /* diff --git a/revision.c b/revision.c index b42c836d7a..748310c2a3 100644 --- a/revision.c +++ b/revision.c @@ -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; diff --git a/revision.h b/revision.h index b8c47b98e2..e892a40cd9 100644 --- a/revision.h +++ b/revision.h @@ -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 */ diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 25b1f8cc73..61610ce08e 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -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 diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh index 380e1c1054..eea048e52c 100755 --- a/t/t8002-blame.sh +++ b/t/t8002-blame.sh @@ -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