{"thread":{"id":"30737","subject":"[PATCH 2/6] reflog: remove i18n legos in pruning message","startedAt":"2012-06-07T12:05:10Z","lastAt":"2012-06-07T18:44:03Z","messageCount":7,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"193056","messageId":"1339070715-31417-1-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"0001-Remove-i18n-legos-in-notifying-new-branch-tracking-s.patch","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-06-07T12:05:10Z","receivedAt":"2012-06-07T12:05:10Z","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 More compact code compared to the lasst version while maintaining\n -Wformat's effectiveness.\n\n branch.c |   38 +++++++++++++++++++++++---------------\n 1 files changed, 23 insertions(+), 15 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex eccdaf9..2bef1e7 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -74,25 +74,33 @@ 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\t}\n+\t\tif (remote_is_branch && origin)\n+\t\t\tprintf(rebasing ?\n+\t\t\t       \"Branch %s set up to track remote branch %s from %s by rebasing.\\n\" :\n+\t\t\t       \"Branch %s set up to track remote branch %s from %s.\\n\",\n+\t\t\t       local, shortname, origin);\n+\t\telse if (remote_is_branch && !origin)\n+\t\t\tprintf(rebasing ?\n+\t\t\t       \"Branch %s set up to track local branch %s by rebasing.\\n\" :\n+\t\t\t       \"Branch %s set up to track local branch %s.\\n\",\n+\t\t\t       local, shortname);\n+\t\telse if (!remote_is_branch && origin)\n+\t\t\tprintf(rebasing ?\n+\t\t\t       \"Branch %s set up to track remote ref %s by rebasing.\\n\" :\n+\t\t\t       \"Branch %s set up to track remote ref %s.\\n\",\n+\t\t\t       local, remote);\n+\t\telse if (!remote_is_branch && !origin)\n+\t\t\tprintf(rebasing ?\n+\t\t\t       \"Branch %s set up to track local ref %s by rebasing.\\n\" :\n+\t\t\t       \"Branch %s set up to track local ref %s.\\n\",\n+\t\t\t       local, remote);\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\t\tdie(\"BUG: impossible combination of %d and %p\",\n+\t\t\t    remote_is_branch, origin);\n \t}\n-\tstrbuf_release(&key);\n }\n \n /*\n-- \n1.7.8\n"},{"id":"193055","messageId":"1339070715-31417-2-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"1339070715-31417-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-06-07T12:05:11Z","receivedAt":"2012-06-07T12:05:11Z","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 Jonathan's version\n\n builtin/reflog.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 062d7da..b3c9e27 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -330,8 +330,10 @@ 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)\n+\t\tprintf(\"would prune %s\", message);\n+\telse if (cb->cmd->verbose)\n+\t\tprintf(\"prune %s\", message);\n \treturn 0;\n }\n \n-- \n1.7.8\n"},{"id":"193057","messageId":"1339070715-31417-3-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"1339070715-31417-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-06-07T12:05:12Z","receivedAt":"2012-06-07T12:05:12Z","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 The two sentence strings are broken down to one sentence each. Less work for\n translators when these are marked i18n.\n\n merge-recursive.c |   60 ++++++++++++++++++++++++++++++++++++++--------------\n 1 files changed, 44 insertions(+), 16 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 680937c..1f16e04 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1018,9 +1018,28 @@ 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+\tstruct strbuf sb = STRBUF_INIT;\n+\tint idx;\n+\n+\tconst char *msg[] = {\n+\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.\",\n+\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %s.\",\n+\t};\n+\tconst char *renamed_msg[] = {\n+\t\t\"CONFLICT (rename/delete): %s deleted in %s and renamed in %s.\",\n+\t\t\"CONFLICT (modify/delete): %s deleted in %s and modified in %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 +1053,30 @@ 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\tstrbuf_addf(&sb, renamed_msg[idx], path, o->branch1, o->branch2);\n+\t\t\tstrbuf_addf(&sb, \" Version %s of %s left in tree at %s.\",\n+\t\t\t\t    o->branch2, path, renamed);\n+\t\t} else {\n+\t\t\tstrbuf_addf(&sb, msg[idx], path, o->branch1, o->branch2);\n+\t\t\tstrbuf_addf(&sb, \" Version %s of %s left in tree.\",\n+\t\t\t\t    o->branch2, path);\n+\t\t}\n+\t\toutput(o, 1, \"%s\", sb.buf);\n+\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\tstrbuf_addf(&sb, renamed_msg[idx], path, o->branch2, o->branch1);\n+\t\t\tstrbuf_addf(&sb, \" Version %s of %s left in tree at %s.\",\n+\t\t\t\t    o->branch2, path, renamed);\n \t\t\tupdate_file(o, 0, a_sha, a_mode, renamed);\n+\t\t} else {\n+\t\t\tstrbuf_addf(&sb, msg[idx], path, o->branch2, o->branch1);\n+\t\t\tstrbuf_addf(&sb, \" Version %s of %s left in tree.\",\n+\t\t\t\t    o->branch2, path);\n+\t\t}\n+\t\toutput(o, 1, \"%s\", sb.buf);\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@@ -1058,6 +1085,7 @@ static void handle_change_delete(struct merge_options *o,\n \t\t */\n \t}\n \tfree(renamed);\n+\tstrbuf_release(&sb);\n }\n \n static void conflict_rename_delete(struct merge_options *o,\n@@ -1085,7 +1113,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 +1596,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.8\n"},{"id":"193058","messageId":"1339070715-31417-4-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"1339070715-31417-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-06-07T12:05:13Z","receivedAt":"2012-06-07T12:05:13Z","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 |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 74aa77c..29c6411 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -524,8 +524,10 @@ static int merge_from_diffs(struct notes_merge_options *o,\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+\t\tprintf(t->dirty ?\n+\t\t       \"Merge result: %i unmerged notes and a dirty notes tree\\n\" :\n+\t\t       \"Merge result: %i unmerged notes and a clean notes tree\\n\",\n+\t\t       conflicts);\n \n \treturn conflicts ? -1 : 1;\n }\n-- \n1.7.8\n"},{"id":"193059","messageId":"1339070715-31417-5-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"1339070715-31417-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-06-07T12:05:14Z","receivedAt":"2012-06-07T12:05:14Z","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 files 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.8\n"},{"id":"193060","messageId":"1339070715-31417-6-git-send-email-pclouds@gmail.com","threadId":"30737","inReplyTo":"1339070715-31417-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-06-07T12:05:15Z","receivedAt":"2012-06-07T12:05:15Z","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 files 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.8\n"},{"id":"193096","messageId":"7v8vfzgdxo.fsf@alter.siamese.dyndns.org","threadId":"30737","inReplyTo":"1339070715-31417-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/6] Remove i18n legos in notifying new branch tracking setup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-07T18:44:03Z","receivedAt":"2012-06-07T18:44:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  More compact code compared to the lasst version while maintaining\n>  -Wformat's effectiveness.\n\nI'd hesitate to burden translators with new set of strings this late\nin the cycle.  The changes look reasonable, though.  Let's merge\nthis early in the next cycle and mark the strings for translation.\n\nThanks.\n"}]}