Skip to content

Commit 9144b93

Browse files
To1negitster
authored andcommitted
parse-options: introduce die_for_incompatible_opt2()
The functions die_for_incompatible_opt3() and die_for_incompatible_opt4() already exist to die whenever a user specifies three or four options respectively that are not compatible. Introduce die_for_incompatible_opt2() which dies when two options that are incompatible are set. Signed-off-by: Toon Claes <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a52a8c commit 9144b93

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

builtin/replay.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
163163
get_ref_information(cmd_info, &rinfo);
164164
if (!rinfo.positive_refexprs)
165165
die(_("need some commits to replay"));
166-
if (onto_name && *advance_name)
167-
die(_("--onto and --advance are incompatible"));
168-
else if (onto_name) {
166+
167+
die_for_incompatible_opt2(!!onto_name, "--onto",
168+
!!*advance_name, "--advance");
169+
if (onto_name) {
169170
*onto = peel_committish(onto_name);
170171
if (rinfo.positive_refexprs <
171172
strset_get_size(&rinfo.positive_refs))

parse-options.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,15 @@ static inline void die_for_incompatible_opt3(int opt1, const char *opt1_name,
436436
0, "");
437437
}
438438

439+
static inline void die_for_incompatible_opt2(int opt1, const char *opt1_name,
440+
int opt2, const char *opt2_name)
441+
{
442+
die_for_incompatible_opt4(opt1, opt1_name,
443+
opt2, opt2_name,
444+
0, "",
445+
0, "");
446+
}
447+
439448
/*
440449
* Use these assertions for callbacks that expect to be called with NONEG and
441450
* NOARG respectively, and do not otherwise handle the "unset" and "arg"

0 commit comments

Comments
 (0)