Skip to content

Commit c9907a1

Browse files
jltoblergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1481e29 commit c9907a1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

builtin/rev-list.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "object-file.h"
1717
#include "object-store-ll.h"
1818
#include "pack-bitmap.h"
19+
#include "parse-options.h"
1920
#include "log-tree.h"
2021
#include "graph.h"
2122
#include "bisect.h"
@@ -639,19 +640,15 @@ int cmd_rev_list(int argc,
639640
if (!strcmp(arg, "--exclude-promisor-objects")) {
640641
fetch_if_missing = 0;
641642
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);
652645
}
653646
}
654647

648+
die_for_incompatible_opt2(revs.exclude_promisor_objects,
649+
"--exclude_promisor_objects",
650+
arg_missing_action, "--missing");
651+
655652
if (arg_missing_action)
656653
revs.do_not_die_on_missing_objects = 1;
657654

0 commit comments

Comments
 (0)