Git fork

rev-list: refactor early option parsing

Before invoking `setup_revisions()`, the `--missing` and
`--exclude-promisor-objects` options are parsed early. In a subsequent
commit, another option is added that must be parsed early.

Refactor the code to parse both options in a single early pass.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Justin Tobler and committed by
Junio C Hamano
c9907a19 1481e291

+7 -10
+7 -10
builtin/rev-list.c
··· 16 16 #include "object-file.h" 17 17 #include "object-store-ll.h" 18 18 #include "pack-bitmap.h" 19 + #include "parse-options.h" 19 20 #include "log-tree.h" 20 21 #include "graph.h" 21 22 #include "bisect.h" ··· 639 640 if (!strcmp(arg, "--exclude-promisor-objects")) { 640 641 fetch_if_missing = 0; 641 642 revs.exclude_promisor_objects = 1; 642 - break; 643 - } 644 - } 645 - for (i = 1; i < argc; i++) { 646 - const char *arg = argv[i]; 647 - if (skip_prefix(arg, "--missing=", &arg)) { 648 - if (revs.exclude_promisor_objects) 649 - die(_("options '%s' and '%s' cannot be used together"), "--exclude-promisor-objects", "--missing"); 650 - if (parse_missing_action_value(arg)) 651 - break; 643 + } else if (skip_prefix(arg, "--missing=", &arg)) { 644 + parse_missing_action_value(arg); 652 645 } 653 646 } 647 + 648 + die_for_incompatible_opt2(revs.exclude_promisor_objects, 649 + "--exclude_promisor_objects", 650 + arg_missing_action, "--missing"); 654 651 655 652 if (arg_missing_action) 656 653 revs.do_not_die_on_missing_objects = 1;