{"thread":{"id":"30669","subject":"[PATCH] i18n: apply: split to fix a partial i18n message","startedAt":"2012-05-31T11:20:42Z","lastAt":"2012-05-31T20:31:02Z","messageCount":17,"participants":["Jiang Xin","Nguyễn Thái Ngọc Duy","Jonathan Nieder","Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"192557","messageId":"1338463242-10618-1-git-send-email-worldhello.net@gmail.com","threadId":"30669","inReplyTo":null,"subject":"[PATCH] i18n: apply: split to fix a partial i18n message","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-05-31T11:20:42Z","receivedAt":"2012-05-31T11:20:42Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"The 4th arg of \"new mode (%o) of %s does not match old mode (%o)%s%s\"\nis blank string or string \" of \". Even mark the string \" of \" for a\ncomplete i18n, this message is still hard to translate right.\n\nSplit it into two slight different messages would make l10n teams happy.\n\nSigned-off-by: Jiang Xin <worldhello.net@gmail.com>\n---\n builtin/apply.c | 16 ++++++++++++----\n 1 file changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex dda9ea0..b4428ea 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3262,10 +3262,18 @@ static int check_patch(struct patch *patch)\n \t\tint same = !strcmp(old_name, new_name);\n \t\tif (!patch->new_mode)\n \t\t\tpatch->new_mode = patch->old_mode;\n-\t\tif ((patch->old_mode ^ patch->new_mode) & S_IFMT)\n-\t\t\treturn error(_(\"new mode (%o) of %s does not match old mode (%o)%s%s\"),\n-\t\t\t\tpatch->new_mode, new_name, patch->old_mode,\n-\t\t\t\tsame ? \"\" : \" of \", same ? \"\" : old_name);\n+\t\tif ((patch->old_mode ^ patch->new_mode) & S_IFMT) {\n+\t\t\tif (same)\n+\t\t\t\treturn error(_(\"new mode (%o) of %s does not \"\n+\t\t\t\t\t       \"match old mode (%o)\"),\n+\t\t\t\t\tpatch->new_mode, new_name,\n+\t\t\t\t\tpatch->old_mode);\n+\t\t\telse\n+\t\t\t\treturn error(_(\"new mode (%o) of %s does not \"\n+\t\t\t\t\t       \"match old mode (%o) of %s\"),\n+\t\t\t\t\tpatch->new_mode, new_name,\n+\t\t\t\t\tpatch->old_mode, old_name);\n+\t\t}\n \t}\n \n \tif (apply_data(patch, &st, ce) < 0)\n-- \n1.7.10.2.559.g0ba0f00\n"},{"id":"192563","messageId":"1338469482-30936-1-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338463242-10618-1-git-send-email-worldhello.net@gmail.com","subject":"Re: [PATCH] i18n: apply: split to fix a partial i18n message","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:36Z","receivedAt":"2012-05-31T13:04:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, May 31, 2012 at 6:20 PM, Jiang Xin <worldhello.net@gmail.com> wrote:\n> The 4th arg of \"new mode (%o) of %s does not match old mode (%o)%s%s\"\n> is blank string or string \" of \". Even mark the string \" of \" for a\n> complete i18n, this message is still hard to translate right.\n\nYour patch looks good. I have a habit of looking for similar spots and\nthe following patches are the result. These messages are not marked\nfor translation because I think mass-marking by file or by command is\nbetter.\n\nNot sure if it's the right way to fix these though. For example, while\n1/1 looks very good from i18n perspective, code-wise it's quite ugly.\nGrouping format strings in array also prevents gcc from checking\ncorrect parameters, I think.\n\nNguyễn Thái Ngọc Duy (6):\n  Remove i18n legos in notifying new branch tracking setup\n  reflog: remove i18n legos in pruning message\n  merge-recursive: remove i18n legos in conflict messages\n  notes-merge: remove i18n legos in merge result message\n  rerere: remove i18n legos in result message\n  unpack-trees: remove i18n legos in unpack's porcelain error messages\n\n branch.c          | 48 +++++++++++++++++++++++++++++++++---------------\n builtin/reflog.c  |  8 ++++++--\n merge-recursive.c | 49 +++++++++++++++++++++++++++++++++----------------\n notes-merge.c     | 11 ++++++++---\n rerere.c          | 12 ++++++------\n unpack-trees.c    | 55 +++++++++++++++++++++++++++++++++----------------------\n 6 files changed, 119 insertions(+), 64 deletions(-)\n\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192564","messageId":"1338469482-30936-2-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/6] Remove i18n legos in notifying new branch tracking setup","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:37Z","receivedAt":"2012-05-31T13:04:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n branch.c | 48 +++++++++++++++++++++++++++++++++---------------\n 1 file changed, 33 insertions(+), 15 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex eccdaf9..d8facf7 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -74,25 +74,43 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n \t\tgit_config_set(key.buf, \"true\");\n \t}\n+\tstrbuf_release(&key);\n \n \tif (flag & BRANCH_CONFIG_VERBOSE) {\n-\t\tstrbuf_reset(&key);\n-\n-\t\tstrbuf_addstr(&key, origin ? \"remote\" : \"local\");\n-\n-\t\t/* Are we tracking a proper \"branch\"? */\n-\t\tif (remote_is_branch) {\n-\t\t\tstrbuf_addf(&key, \" branch %s\", shortname);\n-\t\t\tif (origin)\n-\t\t\t\tstrbuf_addf(&key, \" from %s\", origin);\n+\t\tif (rebasing) {\n+\t\t\tif (remote_is_branch) {\n+\t\t\t\tif (origin)\n+\t\t\t\t\tprintf(\"Branch %s set up to track remote branch %s from %s by rebasing.\\n\",\n+\t\t\t\t\t       local, shortname, origin);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"Branch %s set up to track local branch %s by rebasing.\\n\",\n+\t\t\t\t\t       local, shortname);\n+\t\t\t} else {\n+\t\t\t\tif (origin)\n+\t\t\t\t\tprintf(\"Branch %s set up to track remote ref %s by rebasing.\\n\",\n+\t\t\t\t\t       local, remote);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"Branch %s set up to track local ref %s by rebasing.\\n\",\n+\t\t\t\t\t       local, remote);\n+\t\t\t}\n+\t\t} else {\n+\t\t\tif (remote_is_branch) {\n+\t\t\t\tif (origin)\n+\t\t\t\t\tprintf(\"Branch %s set up to track remote branch %s from %s.\\n\",\n+\t\t\t\t\t       local, shortname, origin);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"Branch %s set up to track local branch %s.\\n\",\n+\t\t\t\t\t       local, shortname);\n+\t\t\t} else {\n+\t\t\t\tif (origin)\n+\t\t\t\t\tprintf(\"Branch %s set up to track remote ref %s.\\n\",\n+\t\t\t\t\t       local, remote);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"Branch %s set up to track local ref %s.\\n\",\n+\t\t\t\t\t       local, remote);\n+\t\t\t}\n \t\t}\n-\t\telse\n-\t\t\tstrbuf_addf(&key, \" ref %s\", remote);\n-\t\tprintf(\"Branch %s set up to track %s%s.\\n\",\n-\t\t       local, key.buf,\n-\t\t       rebasing ? \" by rebasing\" : \"\");\n \t}\n-\tstrbuf_release(&key);\n }\n \n /*\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192565","messageId":"1338469482-30936-3-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:38Z","receivedAt":"2012-05-31T13:04:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/reflog.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 062d7da..6cedcec 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -330,8 +330,12 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n \t\tprintf(\"keep %s\", message);\n \treturn 0;\n  prune:\n-\tif (!cb->newlog || cb->cmd->verbose)\n-\t\tprintf(\"%sprune %s\", cb->newlog ? \"\" : \"would \", message);\n+\tif (!cb->newlog || cb->cmd->verbose) {\n+\t\tif (cb->newlog)\n+\t\t\tprintf(\"prune %s\", message);\n+\t\telse\n+\t\t\tprintf(\"would prune %s\", message);\n+\t}\n \treturn 0;\n }\n \n-- \n1.7.10.2.549.g9354186\n"},{"id":"192566","messageId":"1338469482-30936-4-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 3/6] merge-recursive: remove i18n legos in conflict messages","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:39Z","receivedAt":"2012-05-31T13:04:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n merge-recursive.c | 49 +++++++++++++++++++++++++++++++++----------------\n 1 file changed, 33 insertions(+), 16 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 680937c..1cc6360 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1018,9 +1018,27 @@ static void handle_change_delete(struct merge_options *o,\n \t\t\t\t const unsigned char *o_sha, int o_mode,\n \t\t\t\t const unsigned char *a_sha, int a_mode,\n \t\t\t\t const unsigned char *b_sha, int b_mode,\n-\t\t\t\t const char *change, const char *change_past)\n+\t\t\t\t const char *change)\n {\n \tchar *renamed = NULL;\n+\tint idx;\n+\n+\tconst char *msg[] = {\n+\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree.\",\n+\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree.\",\n+\t};\n+\tconst char *renamed_msg[] = {\n+\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree at %s.\",\n+\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree at %s.\",\n+\t};\n+\n+\tif (!strcmp(change, \"rename\"))\n+\t\tidx = 0;\n+\telse if (!strcmp(change, \"modify\"))\n+\t\tidx = 1;\n+\telse\n+\t\tdie(\"BUG: unsupport action %s\", change);\n+\n \tif (dir_in_way(path, !o->call_depth)) {\n \t\trenamed = unique_path(o, path, a_sha ? o->branch1 : o->branch2);\n \t}\n@@ -1034,22 +1052,21 @@ static void handle_change_delete(struct merge_options *o,\n \t\tremove_file_from_cache(path);\n \t\tupdate_file(o, 0, o_sha, o_mode, renamed ? renamed : path);\n \t} else if (!a_sha) {\n-\t\toutput(o, 1, \"CONFLICT (%s/delete): %s deleted in %s \"\n-\t\t       \"and %s in %s. Version %s of %s left in tree%s%s.\",\n-\t\t       change, path, o->branch1,\n-\t\t       change_past, o->branch2, o->branch2, path,\n-\t\t       NULL == renamed ? \"\" : \" at \",\n-\t\t       NULL == renamed ? \"\" : renamed);\n+\t\tif (renamed)\n+\t\t\toutput(o, 1, renamed_msg[idx], path, o->branch1,\n+\t\t\t       o->branch2, o->branch2, path, renamed);\n+\t\telse\n+\t\t\toutput(o, 1, msg[idx], path, o->branch1,\n+\t\t\t       o->branch2, o->branch2, path);\n \t\tupdate_file(o, 0, b_sha, b_mode, renamed ? renamed : path);\n \t} else {\n-\t\toutput(o, 1, \"CONFLICT (%s/delete): %s deleted in %s \"\n-\t\t       \"and %s in %s. Version %s of %s left in tree%s%s.\",\n-\t\t       change, path, o->branch2,\n-\t\t       change_past, o->branch1, o->branch1, path,\n-\t\t       NULL == renamed ? \"\" : \" at \",\n-\t\t       NULL == renamed ? \"\" : renamed);\n-\t\tif (renamed)\n+\t\tif (renamed) {\n+\t\t\toutput(o, 1, renamed_msg[idx], path, o->branch2,\n+\t\t\t       o->branch1, o->branch1, path, renamed);\n \t\t\tupdate_file(o, 0, a_sha, a_mode, renamed);\n+\t\t} else\n+\t\t\toutput(o, 1, msg[idx], path, o->branch2,\n+\t\t\t       o->branch1, o->branch1, path);\n \t\t/*\n \t\t * No need to call update_file() on path when !renamed, since\n \t\t * that would needlessly touch path.  We could call\n@@ -1085,7 +1102,7 @@ static void conflict_rename_delete(struct merge_options *o,\n \t\t\t     orig->sha1, orig->mode,\n \t\t\t     a_sha, a_mode,\n \t\t\t     b_sha, b_mode,\n-\t\t\t     \"rename\", \"renamed\");\n+\t\t\t     \"rename\");\n \n \tif (o->call_depth) {\n \t\tremove_file_from_cache(dest->path);\n@@ -1568,7 +1585,7 @@ static void handle_modify_delete(struct merge_options *o,\n \t\t\t     o_sha, o_mode,\n \t\t\t     a_sha, a_mode,\n \t\t\t     b_sha, b_mode,\n-\t\t\t     \"modify\", \"modified\");\n+\t\t\t     \"modify\");\n }\n \n static int merge_content(struct merge_options *o,\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192567","messageId":"1338469482-30936-5-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 4/6] notes-merge: remove i18n legos in merge result message","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:40Z","receivedAt":"2012-05-31T13:04:40Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n notes-merge.c | 11 ++++++++---\n 1 file changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 74aa77c..43d5ce0 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -523,9 +523,14 @@ static int merge_from_diffs(struct notes_merge_options *o,\n \tconflicts = merge_changes(o, changes, &num_changes, t);\n \tfree(changes);\n \n-\tif (o->verbosity >= 4)\n-\t\tprintf(\"Merge result: %i unmerged notes and a %s notes tree\\n\",\n-\t\t\tconflicts, t->dirty ? \"dirty\" : \"clean\");\n+\tif (o->verbosity >= 4) {\n+\t\tif (t->dirty)\n+\t\t\tprintf(\"Merge result: %i unmerged notes and a dirty notes tree\\n\",\n+\t\t\t       conflicts);\n+\t\telse\n+\t\t\tprintf(\"Merge result: %i unmerged notes and a clean notes tree\\n\",\n+\t\t\t       conflicts);\n+\t}\n \n \treturn conflicts ? -1 : 1;\n }\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192568","messageId":"1338469482-30936-6-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 5/6] rerere: remove i18n legos in result message","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:41Z","receivedAt":"2012-05-31T13:04:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n rerere.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/rerere.c b/rerere.c\nindex dcb525a..da18fc3 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -544,13 +544,13 @@ static int do_plain_rerere(struct string_list *rr, int fd)\n \n \t\tif (has_rerere_resolution(name)) {\n \t\t\tif (!merge(name, path)) {\n-\t\t\t\tif (rerere_autoupdate)\n+\t\t\t\tconst char *msg;\n+\t\t\t\tif (rerere_autoupdate) {\n \t\t\t\t\tstring_list_insert(&update, path);\n-\t\t\t\tfprintf(stderr,\n-\t\t\t\t\t\"%s '%s' using previous resolution.\\n\",\n-\t\t\t\t\trerere_autoupdate\n-\t\t\t\t\t? \"Staged\" : \"Resolved\",\n-\t\t\t\t\tpath);\n+\t\t\t\t\tmsg = \"Staged '%s' using previous resolution.\\n\";\n+\t\t\t\t} else\n+\t\t\t\t\tmsg = \"Resolved '%s' using previous resolution.\\n\";\n+\t\t\t\tfprintf(stderr, msg, path);\n \t\t\t\tgoto mark_resolved;\n \t\t\t}\n \t\t}\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192569","messageId":"1338469482-30936-7-git-send-email-pclouds@gmail.com","threadId":"30669","inReplyTo":"1338469482-30936-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 6/6] unpack-trees: remove i18n legos in unpack's porcelain error messages","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:04:42Z","receivedAt":"2012-05-31T13:04:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n unpack-trees.c | 55 +++++++++++++++++++++++++++++++++----------------------\n 1 file changed, 33 insertions(+), 22 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ad40109..41c5714 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -53,35 +53,46 @@ static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,\n \t\t\t\t  const char *cmd)\n {\n-\tint i;\n+\tint i, idx;\n \tconst char **msgs = opts->msgs;\n-\tconst char *msg;\n-\tchar *tmp;\n-\tconst char *cmd2 = strcmp(cmd, \"checkout\") ? cmd : \"switch branches\";\n-\tif (advice_commit_before_merge)\n-\t\tmsg = \"Your local changes to the following files would be overwritten by %s:\\n%%s\"\n-\t\t\t\"Please, commit your changes or stash them before you can %s.\";\n+\tstruct strbuf msg = STRBUF_INIT;\n+\tconst char *overwrite_advice[] = {\n+\t\t\"Please, commit your changes or stash them before you can merge.\",\n+\t\t\"Please, commit your changes or stash them before you can switch branches.\"\n+\t};\n+\tconst char *remove_untracked_advice[] = {\n+\t\t\"Please move or remove them before you can merge.\",\n+\t\t\"Please move or remove them before you can switch branches.\"\n+\t};\n+\n+\tif (!strcmp(cmd, \"merge\"))\n+\t\tidx = 0;\n+\telse if (!strcmp(cmd, \"checkout\"))\n+\t\tidx = 1;\n \telse\n-\t\tmsg = \"Your local changes to the following files would be overwritten by %s:\\n%%s\";\n-\ttmp = xmalloc(strlen(msg) + strlen(cmd) + strlen(cmd2) - 2);\n-\tsprintf(tmp, msg, cmd, cmd2);\n-\tmsgs[ERROR_WOULD_OVERWRITE] = tmp;\n-\tmsgs[ERROR_NOT_UPTODATE_FILE] = tmp;\n+\t\tdie(\"BUG: unsupported command %s\", cmd);\n+\n+\tstrbuf_addf(&msg, \"Your local changes to the following files \"\n+\t\t    \"would be overwritten by %s:\\n%%s\", cmd);\n+\tif (advice_commit_before_merge)\n+\t\tstrbuf_addstr(&msg, overwrite_advice[idx]);\n+\tmsgs[ERROR_WOULD_OVERWRITE] = strbuf_detach(&msg, NULL);\n+\tmsgs[ERROR_NOT_UPTODATE_FILE] = msgs[ERROR_WOULD_OVERWRITE];\n \n \tmsgs[ERROR_NOT_UPTODATE_DIR] =\n \t\t\"Updating the following directories would lose untracked files in it:\\n%s\";\n \n+\tstrbuf_addf(&msg, \"The following untracked working tree \"\n+\t\t    \"files would be removed by %s:\\n%%s\", cmd);\n \tif (advice_commit_before_merge)\n-\t\tmsg = \"The following untracked working tree files would be %s by %s:\\n%%s\"\n-\t\t\t\"Please move or remove them before you can %s.\";\n-\telse\n-\t\tmsg = \"The following untracked working tree files would be %s by %s:\\n%%s\";\n-\ttmp = xmalloc(strlen(msg) + strlen(cmd) + strlen(\"removed\") + strlen(cmd2) - 4);\n-\tsprintf(tmp, msg, \"removed\", cmd, cmd2);\n-\tmsgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = tmp;\n-\ttmp = xmalloc(strlen(msg) + strlen(cmd) + strlen(\"overwritten\") + strlen(cmd2) - 4);\n-\tsprintf(tmp, msg, \"overwritten\", cmd, cmd2);\n-\tmsgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = tmp;\n+\t\tstrbuf_addstr(&msg, remove_untracked_advice[idx]);\n+\tmsgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = strbuf_detach(&msg, NULL);\n+\n+\tstrbuf_addf(&msg, \"The following untracked working tree \"\n+\t\t    \"files would be overwritten by %s:\\n%%s\", cmd);\n+\tif (advice_commit_before_merge)\n+\t\tstrbuf_addstr(&msg, remove_untracked_advice[idx]);\n+\tmsgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = strbuf_detach(&msg, NULL);\n \n \t/*\n \t * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we\n-- \n1.7.10.2.549.g9354186\n"},{"id":"192574","messageId":"20120531134538.GA10523@burratino","threadId":"30669","inReplyTo":"1338469482-30936-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-05-31T13:45:38Z","receivedAt":"2012-05-31T13:45:38Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> --- a/builtin/reflog.c\n> +++ b/builtin/reflog.c\n> @@ -330,8 +330,12 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n>  \t\tprintf(\"keep %s\", message);\n>  \treturn 0;\n>   prune:\n> -\tif (!cb->newlog || cb->cmd->verbose)\n> -\t\tprintf(\"%sprune %s\", cb->newlog ? \"\" : \"would \", message);\n> +\tif (!cb->newlog || cb->cmd->verbose) {\n> +\t\tif (cb->newlog)\n> +\t\t\tprintf(\"prune %s\", message);\n> +\t\telse\n> +\t\t\tprintf(\"would prune %s\", message);\n> +\t}\n\nThanks.  Style: how about\n\n\tif (!cb->newlog)\n\t\tprintf(\"would prune %s\", message);\n\telse if (cb->cmd->verbose)\n\t\tprintf(\"prune %s\", message);\n\n?  I think that would be more readable than the lego original.\n\nBTW I'm not sure if this message would be a good candidate for\ntranslation.  Especially in the --dry-run case, it feels like output\nthat is intended to be simple enough for scripts to parse.  (Though on\nthe other hand, I don't know of any scripts or use cases that actually\nparse it, so maybe nobody would mind.)\n"},{"id":"192575","messageId":"20120531135222.GB10523@burratino","threadId":"30669","inReplyTo":"1338469482-30936-4-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 3/6] merge-recursive: remove i18n legos in conflict messages","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-05-31T13:52:22Z","receivedAt":"2012-05-31T13:52:22Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> +\tconst char *msg[] = {\n> +\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree.\",\n> +\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree.\",\n> +\t};\n> +\tconst char *renamed_msg[] = {\n> +\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree at %s.\",\n> +\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree at %s.\",\n> +\t};\n\nIs lego by sentence ok?  i.e., having 4 translated messages:\n\n\tCONFLICT (rename/delete): %s deleted in %s and renamed in %s.\n\tCONFLICT (modify/delete): %s deleted in %s and modified in %s.\n\tVersion %s of %s left in tree.\n\tVersion %s of %s left in tree at %s.\n"},{"id":"192576","messageId":"CACsJy8Dnk6Nnkh94OMx4L-=8CUZK22yG8_BA6EUtW1o+=qyGxg@mail.gmail.com","threadId":"30669","inReplyTo":"20120531135222.GB10523@burratino","subject":"Re: [PATCH 3/6] merge-recursive: remove i18n legos in conflict messages","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T13:56:00Z","receivedAt":"2012-05-31T13:56:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, May 31, 2012 at 8:52 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> +     const char *msg[] = {\n>> +             \"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree.\",\n>> +             \"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree.\",\n>> +     };\n>> +     const char *renamed_msg[] = {\n>> +             \"CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree at %s.\",\n>> +             \"CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree at %s.\",\n>> +     };\n>\n> Is lego by sentence ok?  i.e., having 4 translated messages:\n>\n>        CONFLICT (rename/delete): %s deleted in %s and renamed in %s.\n>        CONFLICT (modify/delete): %s deleted in %s and modified in %s.\n>        Version %s of %s left in tree.\n>        Version %s of %s left in tree at %s.\n\nYeah, should have separated these sentences, less work for translators.\n-- \nDuy\n"},{"id":"192577","messageId":"20120531140024.GC10523@burratino","threadId":"30669","inReplyTo":"1338469482-30936-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/6] Remove i18n legos in notifying new branch tracking setup","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-05-31T14:00:24Z","receivedAt":"2012-05-31T14:00:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> Not sure if it's the right way to fix these though. For example, while\n> 1/1 looks very good from i18n perspective, code-wise it's quite ugly.\n> Grouping format strings in array also prevents gcc from checking\n> correct parameters, I think.\n[...]\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -74,25 +74,43 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n[...]\n> -\t\tstrbuf_addstr(&key, origin ? \"remote\" : \"local\");\n> -\n> -\t\t/* Are we tracking a proper \"branch\"? */\n> -\t\tif (remote_is_branch) {\n> -\t\t\tstrbuf_addf(&key, \" branch %s\", shortname);\n> -\t\t\tif (origin)\n> -\t\t\t\tstrbuf_addf(&key, \" from %s\", origin);\n> +\t\tif (rebasing) {\n> +\t\t\tif (remote_is_branch) {\n> +\t\t\t\tif (origin)\n> +\t\t\t\t\tprintf(\"Branch %s set up to track remote branch %s from %s by rebasing.\\n\",\n> +\t\t\t\t\t       local, shortname, origin);\n> +\t\t\t\telse\n[...]\n> +\t\t\t} else {\n> +\t\t\t\tif (origin)\n[...]\n> +\t\t\t}\n> +\t\t} else {\n> +\t\t\tif (remote_is_branch) {\n[...]\n\nI think a table-driven version of this switchboard would be much\neasier to read, even if it would hurt gcc's -Wformat checking.  If the\n-Wformat safety is too precious to lose, would something like the\nfollowing work?\n\n\tswitch (tracking_msg_flags) {\n\tcase REBASING | REMOTE_IS_BRANCH | ORIGIN:\n\t\tprintf(_(\"Branch %s set up to track remote branch %s ...\"),\n\t\t\t...\n\t\tbreak;\n\tcase REBASING | REMOTE_IS_BRANCH:\n\t\tprintf(_(...\n"},{"id":"192578","messageId":"CACsJy8Bgzkc51N+t=0NyOasJRd2y3U+pyZCGa-qGoDuTQuyOgg@mail.gmail.com","threadId":"30669","inReplyTo":"20120531134538.GA10523@burratino","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T14:00:29Z","receivedAt":"2012-05-31T14:00:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, May 31, 2012 at 8:45 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Thanks.  Style: how about\n>\n>        if (!cb->newlog)\n>                printf(\"would prune %s\", message);\n>        else if (cb->cmd->verbose)\n>                printf(\"prune %s\", message);\n>\n> ?  I think that would be more readable than the lego original.\n\nthanks\n\n> BTW I'm not sure if this message would be a good candidate for\n> translation.  Especially in the --dry-run case, it feels like output\n> that is intended to be simple enough for scripts to parse.  (Though on\n> the other hand, I don't know of any scripts or use cases that actually\n> parse it, so maybe nobody would mind.)\n\nit's gray area. reflog is not categorized as plumbing. Maybe adding\n--plumbing for scripts?\n-- \nDuy\n"},{"id":"192579","messageId":"20120531141020.GD10523@burratino","threadId":"30669","inReplyTo":"CACsJy8Bgzkc51N+t=0NyOasJRd2y3U+pyZCGa-qGoDuTQuyOgg@mail.gmail.com","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-05-31T14:10:20Z","receivedAt":"2012-05-31T14:10:20Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n>                                                        Maybe adding\n> --plumbing for scripts?\n\nThat wouldn't take care of existing scripts, and new scripts should\nuse LC_ALL=C to defend themselves when they don't want to be impacted\nby i18n.\n\nDo you have some other reason in mind that a script should choose to\npass --plumbing here?  Is it an output format flag specific to 'git\nreflog expire', in the spirit of status --porcelain, or a more generic\n\"I care about output stability\" flag that spans multiple commands?\n\nJonathan\n"},{"id":"192581","messageId":"CACsJy8AAnDDGSusfd2EaKW-sj=kM=xE5tET0RprEyszOBYOztg@mail.gmail.com","threadId":"30669","inReplyTo":"20120531141020.GD10523@burratino","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-31T14:18:20Z","receivedAt":"2012-05-31T14:18:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, May 31, 2012 at 9:10 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nguyen Thai Ngoc Duy wrote:\n>\n>>                                                        Maybe adding\n>> --plumbing for scripts?\n>\n> That wouldn't take care of existing scripts, and new scripts should\n> use LC_ALL=C to defend themselves when they don't want to be impacted\n> by i18n.\n>\n> Do you have some other reason in mind that a script should choose to\n> pass --plumbing here?  Is it an output format flag specific to 'git\n> reflog expire', in the spirit of status --porcelain, or a more generic\n> \"I care about output stability\" flag that spans multiple commands?\n\nI was thinking (but without checking) that this is the only way a\nscript can check for expired reflog entries. Maybe something more\nscript friendly, like ref names only.\n-- \nDuy\n"},{"id":"192605","messageId":"7vlik86xqd.fsf@alter.siamese.dyndns.org","threadId":"30669","inReplyTo":"20120531134538.GA10523@burratino","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-31T17:56:10Z","receivedAt":"2012-05-31T17:56:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Thanks.  Style: how about\n>\n> \tif (!cb->newlog)\n> \t\tprintf(\"would prune %s\", message);\n> \telse if (cb->cmd->verbose)\n> \t\tprintf(\"prune %s\", message);\n>\n> ?  I think that would be more readable than the lego original.\n\nThat is very much more preferred.\n\n> BTW I'm not sure if this message would be a good candidate for\n> translation.\n\nThese are for human consumption; they used to go to standard error\nstream back when it was written at 4264dc1 (git reflog expire,\n2006-12-19).\n"},{"id":"192619","messageId":"20120531203102.GA27332@burratino","threadId":"30669","inReplyTo":"7vlik86xqd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/6] reflog: remove i18n legos in pruning message","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-05-31T20:31:02Z","receivedAt":"2012-05-31T20:31:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> These are for human consumption; they used to go to standard error\n> stream back when it was written at 4264dc1 (git reflog expire,\n> 2006-12-19).\n\nGood.  Thanks for clarifying and for looking that up.\n\nWhy was this changed to write to standard output in 1389d9dd (reflog\nexpire --fix-stale, 2007-01-06)?  Would changing it back some time\nto follow the usual \"progress and diagnostics go to stderr\" pattern\nbe worthwhile?\n---\n builtin/reflog.c |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git i/builtin/reflog.c w/builtin/reflog.c\nindex 062d7dad..90e820a0 100644\n--- i/builtin/reflog.c\n+++ w/builtin/reflog.c\n@@ -327,11 +327,11 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n \t\thashcpy(cb->last_kept_sha1, nsha1);\n \t}\n \tif (cb->cmd->verbose)\n-\t\tprintf(\"keep %s\", message);\n+\t\tfprintf(stderr, \"keep %s\", message);\n \treturn 0;\n  prune:\n \tif (!cb->newlog || cb->cmd->verbose)\n-\t\tprintf(\"%sprune %s\", cb->newlog ? \"\" : \"would \", message);\n+\t\tfprintf(stderr, \"%sprune %s\", cb->newlog ? \"\" : \"would \", message);\n \treturn 0;\n }\n \n@@ -646,10 +646,10 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \tif (cb.stalefix) {\n \t\tinit_revisions(&cb.revs, prefix);\n \t\tif (cb.verbose)\n-\t\t\tprintf(\"Marking reachable objects...\");\n+\t\t\tfprintf(stderr, \"Marking reachable objects...\");\n \t\tmark_reachable_objects(&cb.revs, 0, NULL);\n \t\tif (cb.verbose)\n-\t\t\tputchar('\\n');\n+\t\t\tfputc('\\n', stderr);\n \t}\n \n \tif (do_all) {\n-- \n"}]}