]> git.ipfire.org Git - thirdparty/git.git/commitdiff
replay: use die_for_incompatible_opt2() for option validation
authorSiddharth Asthana <siddharthasthana31@gmail.com>
Wed, 5 Nov 2025 19:15:59 +0000 (00:45 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Nov 2025 21:34:55 +0000 (13:34 -0800)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/replay.c

index 6172c8aacc9873f417446ad88f7b04901264ef98..b64fc72063ee8ef512cf85a30b5d6eaa038d2380 100644 (file)
@@ -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);