Re: [PATCH v6 1/3] replay: use die_for_incompatible_opt2() for option validation
- From
Siddharth Asthana <siddharthasthana31@gmail.com>
- Date
- Nov 5, 2025, 18:39 UTC
- Message-ID
- <a030b02e-7ef2-44ef-9793-7b8db3abb7c3@gmail.com>
- In-Reply-To
- <CABPp-BHyUFpFEK1YXSYQWEXSAa2fnUTsH9nsf=LgPs=GNQG2RQ@mail.gmail.com>
On 01/11/25 00:17, Elijah Newren wrote:
Show 39 quoted lines
> On Thu, Oct 30, 2025 at 12:19 PM Siddharth Asthana
> <siddharthasthana31@gmail.com> wrote:
>> In preparation for adding the --ref-action option, convert option
>> validation to use die_for_incompatible_opt2(). This helper provides
>> standardized error messages for mutually exclusive options.
>>
>> The following commit introduces --ref-action which will be incompatible
>> with certain other options. Using die_for_incompatible_opt2() now means
>> that commit can cleanly add its validation using the same pattern,
>> keeping the validation logic consistent and maintainable.
>>
>> This also aligns git-replay's option handling with how other Git commands
>> manage option conflicts, using the established die_for_incompatible_opt*()
>> helper family.
>>
>> Signed-off-by: Siddharth Asthana <siddharthasthana31@gmail.com>
>> ---
>> builtin/replay.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/builtin/replay.c b/builtin/replay.c
>> index 6172c8aacc..b64fc72063 100644
>> --- a/builtin/replay.c
>> +++ b/builtin/replay.c
>> @@ -330,9 +330,9 @@ int cmd_replay(int argc,
>> usage_with_options(replay_usage, replay_options);
>> }
>>
>> - if (advance_name_opt && contained)
>> - die(_("options '%s' and '%s' cannot be used together"),
>> - "--advance", "--contained");
>> + die_for_incompatible_opt2(!!advance_name_opt, "--advance",
>> + contained, "--contained");
>> +
>> advance_name = xstrdup_or_null(advance_name_opt);
>>
>> repo_init_revisions(repo, &revs, prefix);
>> --
>> 2.51.0Hi Elijah,
> Thanks for splitting this one out; looks good.
Thanks for confirming! I'm glad the preparatory refactoring in its own commit makes the series easier to review.
Siddharth