Commit a194e2a
committed
die_for_incompatible_opts(): unbounded number of options
We have die_for_incompatible_optN() (for 2 <= N <= 4) to check and
complain when two or more among N mutually incompatible options are
used.
What should a developer do if there are more than four options that
cannot be used at once?
Introduce die_for_incompatible_opts(), which can handle an arbitrary
number of mutually exclusive options, and rewrite existing variants
using it.
The new function takes N pairs of <bool optN, const char *nameN>,
followed by EOF. Note that even if the caller passes bool, it is
promoted to platform-natural int when calling this variadic
function. Thus, the implementation uses va_arg(ap, int) to extract
the value, which allows it to distinguish between bool and EOF
serving as the sentinel.
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent f78ce2f commit a194e2a
2 files changed
Lines changed: 43 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1535 | 1535 | | |
1536 | 1536 | | |
1537 | 1537 | | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
| 1538 | + | |
1542 | 1539 | | |
1543 | | - | |
| 1540 | + | |
1544 | 1541 | | |
| 1542 | + | |
1545 | 1543 | | |
1546 | 1544 | | |
1547 | 1545 | | |
1548 | | - | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1554 | 1559 | | |
1555 | 1560 | | |
1556 | 1561 | | |
1557 | | - | |
| 1562 | + | |
1558 | 1563 | | |
1559 | 1564 | | |
1560 | 1565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
448 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
449 | 464 | | |
450 | 465 | | |
451 | 466 | | |
452 | 467 | | |
453 | 468 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
458 | 473 | | |
459 | 474 | | |
460 | 475 | | |
461 | 476 | | |
462 | 477 | | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
467 | 481 | | |
468 | 482 | | |
469 | 483 | | |
| |||
0 commit comments