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

[PATCH 3/6] merge-recursive: remove i18n legos in conflict messages

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 7, 2012, 12:05 UTC
Message-ID
<1339070715-31417-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1339070715-31417-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 The two sentence strings are broken down to one sentence each. Less work for
 translators when these are marked i18n.
 merge-recursive.c |   60 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 680937c..1f16e04 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1018,9 +1018,28 @@ static void handle_change_delete(struct merge_options *o,
 				 const unsigned char *o_sha, int o_mode,
 				 const unsigned char *a_sha, int a_mode,
 				 const unsigned char *b_sha, int b_mode,
-				 const char *change, const char *change_past)
+				 const char *change)
 {
 	char *renamed = NULL;
+	struct strbuf sb = STRBUF_INIT;
+	int idx;
+
+	const char *msg[] = {
+		"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.",
+		"CONFLICT (modify/delete): %s deleted in %s and modified in %s.",
+	};
+	const char *renamed_msg[] = {
+		"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.",
+		"CONFLICT (modify/delete): %s deleted in %s and modified in %s.",
+	};
+
+	if (!strcmp(change, "rename"))
+		idx = 0;
+	else if (!strcmp(change, "modify"))
+		idx = 1;
+	else
+		die("BUG: unsupport action %s", change);
+
 	if (dir_in_way(path, !o->call_depth)) {
 		renamed = unique_path(o, path, a_sha ? o->branch1 : o->branch2);
 	}
@@ -1034,22 +1053,30 @@ static void handle_change_delete(struct merge_options *o,
 		remove_file_from_cache(path);
 		update_file(o, 0, o_sha, o_mode, renamed ? renamed : path);
 	} else if (!a_sha) {
-		output(o, 1, "CONFLICT (%s/delete): %s deleted in %s "
-		       "and %s in %s. Version %s of %s left in tree%s%s.",
-		       change, path, o->branch1,
-		       change_past, o->branch2, o->branch2, path,
-		       NULL == renamed ? "" : " at ",
-		       NULL == renamed ? "" : renamed);
+		if (renamed) {
+			strbuf_addf(&sb, renamed_msg[idx], path, o->branch1, o->branch2);
+			strbuf_addf(&sb, " Version %s of %s left in tree at %s.",
+				    o->branch2, path, renamed);
+		} else {
+			strbuf_addf(&sb, msg[idx], path, o->branch1, o->branch2);
+			strbuf_addf(&sb, " Version %s of %s left in tree.",
+				    o->branch2, path);
+		}
+		output(o, 1, "%s", sb.buf);
+
 		update_file(o, 0, b_sha, b_mode, renamed ? renamed : path);
 	} else {
-		output(o, 1, "CONFLICT (%s/delete): %s deleted in %s "
-		       "and %s in %s. Version %s of %s left in tree%s%s.",
-		       change, path, o->branch2,
-		       change_past, o->branch1, o->branch1, path,
-		       NULL == renamed ? "" : " at ",
-		       NULL == renamed ? "" : renamed);
-		if (renamed)
+		if (renamed) {
+			strbuf_addf(&sb, renamed_msg[idx], path, o->branch2, o->branch1);
+			strbuf_addf(&sb, " Version %s of %s left in tree at %s.",
+				    o->branch2, path, renamed);
 			update_file(o, 0, a_sha, a_mode, renamed);
+		} else {
+			strbuf_addf(&sb, msg[idx], path, o->branch2, o->branch1);
+			strbuf_addf(&sb, " Version %s of %s left in tree.",
+				    o->branch2, path);
+		}
+		output(o, 1, "%s", sb.buf);
 		/*
 		 * No need to call update_file() on path when !renamed, since
 		 * that would needlessly touch path.  We could call
@@ -1058,6 +1085,7 @@ static void handle_change_delete(struct merge_options *o,
 		 */
 	}
 	free(renamed);
+	strbuf_release(&sb);
 }
 
 static void conflict_rename_delete(struct merge_options *o,
@@ -1085,7 +1113,7 @@ static void conflict_rename_delete(struct merge_options *o,
 			     orig->sha1, orig->mode,
 			     a_sha, a_mode,
 			     b_sha, b_mode,
-			     "rename", "renamed");
+			     "rename");
 
 	if (o->call_depth) {
 		remove_file_from_cache(dest->path);
@@ -1568,7 +1596,7 @@ static void handle_modify_delete(struct merge_options *o,
 			     o_sha, o_mode,
 			     a_sha, a_mode,
 			     b_sha, b_mode,
-			     "modify", "modified");
+			     "modify");
 }
 
 static int merge_content(struct merge_options *o,
-- 
1.7.8
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 7 in “Remove i18n legos in notifying new branch tracking setup”
  1. 1/6 Remove i18n legos in notifying new branch tracking setupNguyễn Thái Ngọc Duy, Jun 7, 2012
  2. 2/6 reflog: remove i18n legos in pruning messageNguyễn Thái Ngọc Duy, Jun 7, 2012
  3. 3/6 merge-recursive: remove i18n legos in conflict messagesNguyễn Thái Ngọc Duy, Jun 7, 2012
  4. 4/6 notes-merge: remove i18n legos in merge result messageNguyễn Thái Ngọc Duy, Jun 7, 2012
  5. 5/6 rerere: remove i18n legos in result messageNguyễn Thái Ngọc Duy, Jun 7, 2012
  6. 6/6 unpack-trees: remove i18n legos in unpack's porcelain error messagesNguyễn Thái Ngọc Duy, Jun 7, 2012
  7. Junio C HamanoJun 7, 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.