git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/7] worktree: standardize incompatibility messages

From
René Scharfe <l.s.r@web.de>
Date
Dec 6, 2023, 11:52 UTC
Message-ID
<20231206115215.94467-7-l.s.r@web.de>
In-Reply-To
<20231206115215.94467-1-l.s.r@web.de>

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>
---
 builtin/worktree.c      | 17 +++++++++--------
 t/t2400-worktree-add.sh |  2 +-
 2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 62b7e26f4b..036ceaa981 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -730,11 +730,11 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
 	}

 	if (opt_track) {
-		die(_("'%s' and '%s' cannot be used together"), "--orphan",
-		    "--track");
+		die(_("options '%s' and '%s' cannot be used together"),
+		    "--orphan", "--track");
 	} else if (!opts->checkout) {
-		die(_("'%s' and '%s' cannot be used together"), "--orphan",
-		    "--no-checkout");
+		die(_("options '%s' and '%s' cannot be used together"),
+		    "--orphan", "--no-checkout");
 	}
 	return 1;
 }
@@ -806,13 +806,14 @@ static int add(int ac, const char **av, const char *prefix)
 	if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
 		die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
 	if (opts.detach && opts.orphan)
-		die(_("options '%s', and '%s' cannot be used together"),
+		die(_("options '%s' and '%s' cannot be used together"),
 		    "--orphan", "--detach");
 	if (opts.orphan && opt_track)
-		die(_("'%s' and '%s' cannot be used together"), "--orphan", "--track");
+		die(_("options '%s' and '%s' cannot be used together"),
+		    "--orphan", "--track");
 	if (opts.orphan && !opts.checkout)
-		die(_("'%s' and '%s' cannot be used together"), "--orphan",
-		    "--no-checkout");
+		die(_("options '%s' and '%s' cannot be used together"),
+		    "--orphan", "--no-checkout");
 	if (opts.orphan && ac == 2)
 		die(_("'%s' and '%s' cannot be used together"), "--orphan",
 		    _("<commit-ish>"));
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index df4aff7825..245656b53a 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -711,7 +711,7 @@ test_dwim_orphan () {
 	local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
 	local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
 	local invalid_ref_regex="^fatal: invalid reference: " &&
-	local bad_combo_regex="^fatal: '[-a-z]*' and '[-a-z]*' cannot be used together" &&
+	local bad_combo_regex="^fatal: options '[-a-z]*' and '[-a-z]*' cannot be used together" &&

 	local git_ns="repo" &&
 	local dashc_args="-C $git_ns" &&
--
2.43.0
Previous: René ScharfeNext: Patrick Steinhardt
Message 19 of 20 in “standardize incompatibility messages”
  1. 0/7 standardize incompatibility messagesRené Scharfe, Dec 6, 2023
  2. 3/7 revision: use die_for_incompatible_opt3() for --graph/--reverse/--walk-reflogsRené Scharfe, Dec 6, 2023
  3. Patrick SteinhardtDec 6, 2023
  4. René ScharfeDec 6, 2023
  5. Eric SunshineDec 6, 2023
  6. René ScharfeDec 6, 2023
  7. 4/7 revision, rev-parse: factorize incompatibility messages about --exclude-hiddenRené Scharfe, Dec 6, 2023
  8. Patrick SteinhardtDec 6, 2023
  9. René ScharfeDec 6, 2023
  10. Patrick SteinhardtDec 6, 2023
  11. René ScharfeDec 6, 2023
  12. Taylor BlauDec 6, 2023
  13. Patrick SteinhardtDec 7, 2023
  14. 1/7 push: use die_for_incompatible_opt4() for --delete/--tags/--all/--mirrorRené Scharfe, Dec 6, 2023
  15. 2/7 repack: use die_for_incompatible_opt3() for -A/-k/--cruftRené Scharfe, Dec 6, 2023
  16. Taylor BlauDec 6, 2023
  17. 5/7 clean: factorize incompatibility messageRené Scharfe, Dec 6, 2023
  18. 7/7 worktree: simplify incompatibility message for --orphan and commit-ishRené Scharfe, Dec 6, 2023
  19. 6/7 worktree: standardize incompatibility messagesRené Scharfe, Dec 6, 2023
  20. Patrick SteinhardtDec 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.