Skip to content

Commit 669b1d2

Browse files
matvoregitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 368a891 commit 669b1d2

File tree

7 files changed

+14
-1
lines changed

7 files changed

+14
-1
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,6 +2853,7 @@ static void get_object_list(int ac, const char **av)
28532853

28542854
init_revisions(&revs, NULL);
28552855
save_commit_buffer = 0;
2856+
revs.allow_exclude_promisor_objects_opt = 1;
28562857
setup_revisions(ac, av, &revs, NULL);
28572858

28582859
/* make sure shallows are read */

builtin/prune.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ 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;
121122
init_revisions(&revs, prefix);
122123

123124
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);

builtin/rev-list.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
370370
git_config(git_default_config, NULL);
371371
init_revisions(&revs, prefix);
372372
revs.abbrev = DEFAULT_ABBREV;
373+
revs.allow_exclude_promisor_objects_opt = 1;
373374
revs.commit_format = CMIT_FMT_UNSPECIFIED;
374375

375376
/*

revision.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
21052105
revs->limited = 1;
21062106
} else if (!strcmp(arg, "--ignore-missing")) {
21072107
revs->ignore_missing = 1;
2108-
} else if (!strcmp(arg, "--exclude-promisor-objects")) {
2108+
} else if (revs->allow_exclude_promisor_objects_opt &&
2109+
!strcmp(arg, "--exclude-promisor-objects")) {
21092110
if (fetch_if_missing)
21102111
die("BUG: exclude_promisor_objects can only be used when fetch_if_missing is 0");
21112112
revs->exclude_promisor_objects = 1;

revision.h

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

126126
/* for internal use only */
127+
allow_exclude_promisor_objects_opt:1,
127128
exclude_promisor_objects:1;
128129

129130
/* Diff flags */

t/t4202-log.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,4 +1668,8 @@ test_expect_success 'log --source paints symmetric ranges' '
16681668
test_cmp expect actual
16691669
'
16701670

1671+
test_expect_success '--exclude-promisor-objects does not BUG-crash' '
1672+
test_must_fail git log --exclude-promisor-objects source-a
1673+
'
1674+
16711675
test_done

t/t8002-blame.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,8 @@ test_expect_success '--no-abbrev works like --abbrev=40' '
118118
check_abbrev 40 --no-abbrev
119119
'
120120

121+
test_expect_success '--exclude-promisor-objects does not BUG-crash' '
122+
test_must_fail git blame --exclude-promisor-objects one
123+
'
124+
121125
test_done

0 commit comments

Comments
 (0)