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

[PATCH 4/5] git-commit: remove lego in i18n messages

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 30, 2012, 15:33 UTC
Message-ID
<1335799995-7667-5-git-send-email-avarab@gmail.com>
In-Reply-To
<1335799995-7667-1-git-send-email-avarab@gmail.com>

Remove the whence_s() function and messages that dependen on it in favor of messages that use either "merge" or "cherry-pick" directly.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit.c |   52 +++++++++++++++++++++++-----------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index b257ae8..c7c491e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -194,24 +194,6 @@ static void determine_whence(struct wt_status *s)
 		s->whence = whence;
 }
 
-static const char *whence_s(void)
-{
-	const char *s = "";
-
-	switch (whence) {
-	case FROM_COMMIT:
-		break;
-	case FROM_MERGE:
-		s = _("merge");
-		break;
-	case FROM_CHERRY_PICK:
-		s = _("cherry-pick");
-		break;
-	}
-
-	return s;
-}
-
 static void rollback_index_files(void)
 {
 	switch (commit_style) {
@@ -453,8 +435,12 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 	 */
 	commit_style = COMMIT_PARTIAL;
 
-	if (whence != FROM_COMMIT)
-		die(_("cannot do a partial commit during a %s."), whence_s());
+	if (whence != FROM_COMMIT) {
+		if (whence == FROM_MERGE)
+			die(_("cannot do a partial commit during a merge."));
+		else if (whence == FROM_CHERRY_PICK)
+			die(_("cannot do a partial commit during a cherry-pick."));
+	}
 
 	memset(&partial, 0, sizeof(partial));
 	partial.strdup_strings = 1;
@@ -796,13 +782,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		char *ai_tmp, *ci_tmp;
 		if (whence != FROM_COMMIT)
 			status_printf_ln(s, GIT_COLOR_NORMAL,
-				_("\n"
-				"It looks like you may be committing a %s.\n"
-				"If this is not correct, please remove the file\n"
-				"	%s\n"
-				"and try again.\n"
-				""),
-				whence_s(),
+			    whence == FROM_MERGE
+				? _("\n"
+					"It looks like you may be committing a merge.\n"
+					"If this is not correct, please remove the file\n"
+					"	%s\n"
+					"and try again.\n")
+				: _("\n"
+					"It looks like you may be committing a cherry-pick.\n"
+					"If this is not correct, please remove the file\n"
+					"	%s\n"
+					"and try again.\n"),
 				git_path(whence == FROM_MERGE
 					 ? "MERGE_HEAD"
 					 : "CHERRY_PICK_HEAD"));
@@ -1072,8 +1062,12 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	/* Sanity check options */
 	if (amend && !current_head)
 		die(_("You have nothing to amend."));
-	if (amend && whence != FROM_COMMIT)
-		die(_("You are in the middle of a %s -- cannot amend."), whence_s());
+	if (amend && whence != FROM_COMMIT) {
+		if (whence == FROM_MERGE)
+			die(_("You are in the middle of a merge -- cannot amend."));
+		else if (whence == FROM_CHERRY_PICK)
+			die(_("You are in the middle of a cherry-pick -- cannot amend."));
+	}
 	if (fixup_message && squash_message)
 		die(_("Options --squash and --fixup cannot be used together"));
 	if (use_message)
-- 
1.7.10.546.gbaa1a.dirty
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 9 of 12 in “i18n: TRANSLATORS commends and LEGO--”
  1. 0/5 i18n: TRANSLATORS commends and LEGO--Ævar Arnfjörð Bjarmason, Apr 30, 2012
  2. 1/5 diff: move TRANSLATORS comments so they're picked upÆvar Arnfjörð Bjarmason, Apr 30, 2012
  3. Junio C HamanoApr 30, 2012
  4. Ævar Arnfjörð BjarmasonApr 30, 2012
  5. 2/5 i18n: Add more TRANSLATORS commentsÆvar Arnfjörð Bjarmason, Apr 30, 2012
  6. Junio C HamanoApr 30, 2012
  7. 3/5 git-branch: remove lego in i18n messagesÆvar Arnfjörð Bjarmason, Apr 30, 2012
  8. Junio C HamanoApr 30, 2012
  9. 4/5 git-commit: remove lego in i18n messagesÆvar Arnfjörð Bjarmason, Apr 30, 2012
  10. 5/5 git-commit: remove lego in i18n messagesÆvar Arnfjörð Bjarmason, Apr 30, 2012
  11. Junio C HamanoApr 30, 2012
  12. Ævar Arnfjörð BjarmasonApr 30, 2012

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.