worktree: standardize incompatibility messages
Use the standard parameterized message for reporting incompatible options for worktree add. This reduces the number of strings to translate and makes the UI slightly more consistent. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 6, 2023 at 12:52 UTC
62bc6dd33c9cfc3fe155f46dc91d1c9056464dde
2 files changed
+10
-9
builtin/worktree.c
+9
-8
@@ -730,11 +730,11 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
730
}
731
732
if (opt_track) {
733
- die(_("'%s' and '%s' cannot be used together"), "--orphan",
734
- "--track");
733
+ die(_("options '%s' and '%s' cannot be used together"),
734
+ "--orphan", "--track");
735
} else if (!opts->checkout) {
736
- die(_("'%s' and '%s' cannot be used together"), "--orphan",
737
- "--no-checkout");
736
+ die(_("options '%s' and '%s' cannot be used together"),
737
+ "--orphan", "--no-checkout");
738
}
739
return 1;
740
}
@@ -806,13 +806,14 @@ static int add(int ac, const char **av, const char *prefix)
806
if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
807
die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
808
if (opts.detach && opts.orphan)
809
- die(_("options '%s', and '%s' cannot be used together"),
809
+ die(_("options '%s' and '%s' cannot be used together"),
810
"--orphan", "--detach");
811
if (opts.orphan && opt_track)
812
- die(_("'%s' and '%s' cannot be used together"), "--orphan", "--track");
812
+ die(_("options '%s' and '%s' cannot be used together"),
813
+ "--orphan", "--track");
814
if (opts.orphan && !opts.checkout)
814
- die(_("'%s' and '%s' cannot be used together"), "--orphan",
815
- "--no-checkout");
815
+ die(_("options '%s' and '%s' cannot be used together"),
816
+ "--orphan", "--no-checkout");
817
if (opts.orphan && ac == 2)
818
die(_("'%s' and '%s' cannot be used together"), "--orphan",
819
_("<commit-ish>"));
t/t2400-worktree-add.sh
+1
-1
@@ -711,7 +711,7 @@ test_dwim_orphan () {
711
local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
712
local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
713
local invalid_ref_regex="^fatal: invalid reference: " &&
714
- local bad_combo_regex="^fatal: '[-a-z]*' and '[-a-z]*' cannot be used together" &&
714
+ local bad_combo_regex="^fatal: options '[-a-z]*' and '[-a-z]*' cannot be used together" &&
715
716
local git_ns="repo" &&
717
local dashc_args="-C $git_ns" &&