{"thread":{"id":"28037","subject":"[PATCH v2 0/5] gettext: add gettextln, eval_gettextln to encode common idiom","startedAt":"2011-08-07T11:58:12Z","lastAt":"2011-08-07T11:58:17Z","messageCount":6,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"173081","messageId":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":null,"subject":"[PATCH v2 0/5] gettext: add gettextln, eval_gettextln to encode common idiom","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:12Z","receivedAt":"2011-08-07T11:58:12Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Currently, if you want to use gettext or eval_gettext to format a message\nyou may have to add a separate echo statement and a surrounding subshell\nin order to interpolate the required trailing new line.\n\nThis patch introduces two new helper functions, gettextln and eval_gettextln\nwhich append a trailing newline to the gettext output.\n\nThis allows constructions of the form:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\t(\n\t\t\tgettext \"You need to give me at least one good and one bad revisions.\n(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" &&\n\t\t\techo\n\t\t) >&2\n\telse\n\t...\n\nto be expressed more concisely as:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\tgettextln \"You need to give me at least one good and one bad revisions.\n(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" >&2\n\telse\n\t...\n\nApplies cleanly to master and pu.\n\nRevisions\n=========\nv2: \n\tSplit modifications to git-sh-i18n.sh into separate commit.\n\tExtended application to:\n\t\t git-am.sh\n\t\t git-pull.sh\n\t\t git-stash.sh\n\t\t git-submodule.sh\n\tRemoved application to git-bisect.sh, pending stabilisation of this series and js/bisect-no-checkout in next or master.\n\t\nv1: Initial RFC. Included example of application to git-bisect.sh.\n\nFuture\n======\n\tApply to git-bisect.sh\n\nJon Seymour (5):\n  gettext: add gettextln, eval_gettextln to encode common idiom\n  git-am: take advantage of gettextln and eval_gettextln.\n  pull: take advantage of eval_gettextln\n  stash: take advantage of eval_gettextln\n  submodule: take advantage of gettextln and eval_gettextln.\n\n git-am.sh        |   31 ++++++++++++++-----------------\n git-pull.sh      |    7 ++-----\n git-sh-i18n.sh   |   19 +++++++++++++++++++\n git-stash.sh     |    9 +++------\n git-submodule.sh |   18 ++++++------------\n 5 files changed, 44 insertions(+), 40 deletions(-)\n\n-- \n1.7.6.363.g9b380.dirty\n"},{"id":"173083","messageId":"1312718297-10999-2-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v2 1/5] gettext: add gettextln, eval_gettextln to encode common idiom","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:13Z","receivedAt":"2011-08-07T11:58:13Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Currently, if you want to use gettext or eval_gettext to format a message\nyou may have to add a separate echo statement and a surrounding subshell\nin order to interpolate the required trailing new line.\n\nThis patch introduces two new helper functions, gettextln and eval_gettextln\nwhich append a trailing newline to the gettext output.\n\nThis allows constructions of the form:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\t(\n\t\t\tgettext \"You need to give me at least one good and one bad revisions.\n(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" &&\n\t\t\techo\n\t\t) >&2\n\telse\n\t...\n\nto be expressed more concisely as:\n\n\tif test -s \"$GIT_DIR/BISECT_START\"\n\tthen\n\t\tgettextln \"You need to give me at least one good and one bad revisions.\n(You can use \\\"git bisect bad\\\" and \\\"git bisect good\\\" for that.)\" >&2\n\telse\n\t...\n\nAcked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-sh-i18n.sh |   19 +++++++++++++++++++\n 1 files changed, 19 insertions(+), 0 deletions(-)\n\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 32ca59d..e672366 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -11,19 +11,38 @@ then\n \t\tprintf \"%s\" \"$1\"\n \t}\n \n+\tgettextln() {\n+\t\tprintf \"%s\\n\" \"$1\"\n+\t}\n+\n \teval_gettext () {\n \t\tprintf \"%s\" \"$1\" | (\n \t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n \t\t\tgit sh-i18n--envsubst \"$1\"\n \t\t)\n \t}\n+\n+\teval_gettextln () {\n+\t\tprintf \"%s\\n\" \"$1\" | (\n+\t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n+\t\t\tgit sh-i18n--envsubst \"$1\"\n+\t\t)\n+\t}\n else\n \tgettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n \n+\tgettextln () {\n+\t\tprintf \"%s\\n\" \"# GETTEXT POISON #\"\n+\t}\n+\n \teval_gettext () {\n \t\tprintf \"%s\" \"# GETTEXT POISON #\"\n \t}\n+\n+\teval_gettextln () {\n+\t\tprintf \"%s\\n\" \"# GETTEXT POISON #\"\n+\t}\n fi\n \n-- \n1.7.6.363.g9b380.dirty\n"},{"id":"173082","messageId":"1312718297-10999-3-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v2 2/5] git-am: take advantage of gettextln and eval_gettextln.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:14Z","receivedAt":"2011-08-07T11:58:14Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-am.sh |   31 ++++++++++++++-----------------\n 1 files changed, 14 insertions(+), 17 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 463c741..6177567 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -89,11 +89,8 @@ safe_to_abort () {\n \tthen\n \t\treturn 0\n \tfi\n-\t(\n-\t\tgettext \"You seem to have moved HEAD since the last 'am' failure.\n-Not rewinding to ORIG_HEAD\" &&\n-\t\techo\n-\t) >&2\n+\t\tgettextln \"You seem to have moved HEAD since the last 'am' failure.\n+Not rewinding to ORIG_HEAD\" >&2\n \treturn 1\n }\n \n@@ -102,9 +99,9 @@ stop_here_user_resolve () {\n \t    printf '%s\\n' \"$resolvemsg\"\n \t    stop_here $1\n     fi\n-    eval_gettext \"When you have resolved this problem run \\\"\\$cmdline --resolved\\\".\n+    eval_gettextln \"When you have resolved this problem run \\\"\\$cmdline --resolved\\\".\n If you would prefer to skip this patch, instead run \\\"\\$cmdline --skip\\\".\n-To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"; echo\n+To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n \n     stop_here $1\n }\n@@ -118,7 +115,7 @@ go_next () {\n \n cannot_fallback () {\n \techo \"$1\"\n-\tgettext \"Cannot fall back to three-way merge.\"; echo\n+\tgettextln \"Cannot fall back to three-way merge.\"\n \texit 1\n }\n \n@@ -611,9 +608,9 @@ do\n \t\t\tgo_next && continue\n \n \t\ttest -s \"$dotest/patch\" || {\n-\t\t\teval_gettext \"Patch is empty.  Was it split wrong?\n+\t\t\teval_gettextln \"Patch is empty.  Was it split wrong?\n If you would prefer to skip this patch, instead run \\\"\\$cmdline --skip\\\".\n-To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"; echo\n+To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n \t\t\tstop_here $this\n \t\t}\n \t\trm -f \"$dotest/original-commit\" \"$dotest/author-script\"\n@@ -648,7 +645,7 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"; ec\n \n \tif test -z \"$GIT_AUTHOR_EMAIL\"\n \tthen\n-\t\tgettext \"Patch does not have a valid e-mail address.\"; echo\n+\t\tgettextln \"Patch does not have a valid e-mail address.\"\n \t\tstop_here $this\n \tfi\n \n@@ -699,7 +696,7 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"; ec\n \t    action=again\n \t    while test \"$action\" = again\n \t    do\n-\t\tgettext \"Commit Body is:\"; echo\n+\t\tgettextln \"Commit Body is:\"\n \t\techo \"--------------------------\"\n \t\tcat \"$dotest/final-commit\"\n \t\techo \"--------------------------\"\n@@ -763,16 +760,16 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"; ec\n \t\t# working tree.\n \t\tresolved=\n \t\tgit diff-index --quiet --cached HEAD -- && {\n-\t\t\tgettext \"No changes - did you forget to use 'git add'?\n+\t\t\tgettextln \"No changes - did you forget to use 'git add'?\n If there is nothing left to stage, chances are that something else\n-already introduced the same changes; you might want to skip this patch.\"; echo\n+already introduced the same changes; you might want to skip this patch.\"\n \t\t\tstop_here_user_resolve $this\n \t\t}\n \t\tunmerged=$(git ls-files -u)\n \t\tif test -n \"$unmerged\"\n \t\tthen\n-\t\t\tgettext \"You still have unmerged paths in your index\n-did you forget to use 'git add'?\"; echo\n+\t\t\tgettextln \"You still have unmerged paths in your index\n+did you forget to use 'git add'?\"\n \t\t\tstop_here_user_resolve $this\n \t\tfi\n \t\tapply_status=0\n@@ -797,7 +794,7 @@ did you forget to use 'git add'?\"; echo\n \tfi\n \tif test $apply_status != 0\n \tthen\n-\t\teval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo\n+\t\teval_gettextln 'Patch failed at $msgnum $FIRSTLINE'\n \t\tstop_here_user_resolve $this\n \tfi\n \n-- \n1.7.6.363.g9b380.dirty\n"},{"id":"173084","messageId":"1312718297-10999-4-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v2 3/5] pull: take advantage of eval_gettextln","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:15Z","receivedAt":"2011-08-07T11:58:15Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-pull.sh |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex a10b129..d3ffd8f 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -217,12 +217,9 @@ then\n \t# $orig_head commit, but we are merging into $curr_head.\n \t# First update the working tree to match $curr_head.\n \n-\t(\n-\t\teval_gettext \"Warning: fetch updated the current branch head.\n+\teval_gettextln \"Warning: fetch updated the current branch head.\n Warning: fast-forwarding your working tree from\n-Warning: commit \\$orig_head.\" &&\n-\t\techo\n-\t) >&2\n+Warning: commit \\$orig_head.\" >&2\n \tgit update-index -q --refresh\n \tgit read-tree -u -m \"$orig_head\" \"$curr_head\" ||\n \t\tdie \"$(eval_gettext \"Cannot fast-forward your working tree.\n-- \n1.7.6.363.g9b380.dirty\n"},{"id":"173085","messageId":"1312718297-10999-5-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v2 4/5] stash: take advantage of eval_gettextln","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:16Z","receivedAt":"2011-08-07T11:58:16Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-stash.sh |    9 +++------\n 1 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex f4e6f05..31dec0a 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -198,8 +198,8 @@ save_stash () {\n \t\t\t#    $ git stash save --blah-blah 2>&1 | head -n 2\n \t\t\t#    error: unknown option for 'stash save': --blah-blah\n \t\t\t#           To provide a message, use git stash save -- '--blah-blah'\n-\t\t\teval_gettext \"$(\"error: unknown option for 'stash save': \\$option\n-       To provide a message, use git stash save -- '\\$option'\")\"; echo\n+\t\t\teval_gettextln \"$(\"error: unknown option for 'stash save': \\$option\n+       To provide a message, use git stash save -- '\\$option'\")\"\n \t\t\tusage\n \t\t\t;;\n \t\t*)\n@@ -470,10 +470,7 @@ apply_stash () {\n \t\tstatus=$?\n \t\tif test -n \"$INDEX_OPTION\"\n \t\tthen\n-\t\t\t(\n-\t\t\t\tgettext \"Index was not unstashed.\" &&\n-\t\t\t\techo\n-\t\t\t) >&2\n+\t\t\tgettextln \"Index was not unstashed.\" >&2\n \t\tfi\n \t\texit $status\n \tfi\n-- \n1.7.6.363.g9b380.dirty\n"},{"id":"173086","messageId":"1312718297-10999-6-git-send-email-jon.seymour@gmail.com","threadId":"28037","inReplyTo":"1312718297-10999-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v2 5/5] submodule: take advantage of gettextln and eval_gettextln.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-07T11:58:17Z","receivedAt":"2011-08-07T11:58:17Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-submodule.sh |   18 ++++++------------\n 1 files changed, 6 insertions(+), 12 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex bc1d3fa..986c5d6 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -223,12 +223,9 @@ cmd_add()\n \n \tif test -z \"$force\" && ! git add --dry-run --ignore-missing \"$path\" > /dev/null 2>&1\n \tthen\n-\t\t(\n-\t\t\teval_gettext \"The following path is ignored by one of your .gitignore files:\n+\t\teval_gettextln \"The following path is ignored by one of your .gitignore files:\n \\$path\n-Use -f if you really want to add it.\" &&\n-\t\t\techo\n-\t\t) >&2\n+Use -f if you really want to add it.\" >&2\n \t\texit 1\n \tfi\n \n@@ -237,7 +234,7 @@ Use -f if you really want to add it.\" &&\n \tthen\n \t\tif test -d \"$path\"/.git -o -f \"$path\"/.git\n \t\tthen\n-\t\t\teval_gettext \"Adding existing repo at '\\$path' to the index\"; echo\n+\t\t\teval_gettextln \"Adding existing repo at '\\$path' to the index\"\n \t\telse\n \t\t\tdie \"$(eval_gettext \"'\\$path' already exists and is not a valid git repo\")\"\n \t\tfi\n@@ -696,10 +693,7 @@ cmd_summary() {\n \t\t\t\t;; # removed\n \t\t\t*)\n \t\t\t\t# unexpected type\n-\t\t\t\t(\n-\t\t\t\t\teval_gettext \"unexpected mode \\$mod_dst\" &&\n-\t\t\t\t\techo\n-\t\t\t\t) >&2\n+\t\t\t\teval_gettextln \"unexpected mode \\$mod_dst\" >&2\n \t\t\t\tcontinue ;;\n \t\t\tesac\n \t\tfi\n@@ -786,9 +780,9 @@ cmd_summary() {\n \tdone |\n \tif test -n \"$for_status\"; then\n \t\tif [ -n \"$files\" ]; then\n-\t\t\tgettext \"# Submodules changed but not updated:\"; echo\n+\t\t\tgettextln \"# Submodules changed but not updated:\"\n \t\telse\n-\t\t\tgettext \"# Submodule changes to be committed:\"; echo\n+\t\t\tgettextln \"# Submodule changes to be committed:\"\n \t\tfi\n \t\techo \"#\"\n \t\tsed -e 's|^|# |' -e 's|^# $|#|'\n-- \n1.7.6.363.g9b380.dirty\n"}]}