Thread (9 messages) 9 messages, 4 authors, 2018-05-29
STALE3043d

[RFC PATCH 0/3] usage: prefix all lines in `vreportf()`, not just the first

From: Martin Ågren <hidden>
Date: 2018-05-25 21:01:24

On 25 May 2018 at 11:14, Junio C Hamano [off-list ref] wrote:
Junio C Hamano [off-list ref] writes:
quoted
quoted
+                    warning("the '-l' option is an alias for '--create-reflog' and");
+                    warning("has no effect in list mode. This option will soon be");
+                    warning("removed and you should omit it (or use '--list' instead).");
By the way, this is one of these times when I feel that we should
have a better multi-line message support in die/error/warning/info
functions.  Ideally, I should be able to write
[...]
        warning(_("the '-l' option is an alias for '--create-reflog' and\n"
                  "has no effect in list mode, This option will soon be\n"
                  "removed and you should omit it (or use '--list' instead)."));
[...]
and warning() would:

 - do the sprintf formatting thing as necessary to prepare a long multi-line
   message;

 - chomp that into lines at '\n' boundary; and

 - give each of these lines with _("warning: ") prefixed.

That way, translators can choose to make the resulting message to
different number of lines from the original easily.
How about something like this? The first two patches implement the
above three points, except for the translation of "warning: ".

The third patch is the main reason this is marked RFC. It translates
"warning: " and similar, and breaks quite a few tests under
GETTEXT_POISON since we grep for, e.g., "warning" on stderr. I could
annotate those tests, but since I'm running out of time anyway, I
thought I'd post this as a heads-up of "I'm looking into this".

I do wonder: If our tests rely on grepping for "warning" (for pretty
good reasons), how many scripts out there do something similar (for
maybe-not-so-good reasons, but still)? Do we want to avoid breaking
them?

Also left to do is to convert any existing lego-ing users to the
single-string form that Junio wished for above.

Martin

Martin Ågren (3):
  usage: extract `prefix_suffix_lines()` from `advise()`
  usage: prefix all lines in `vreportf()`, not just the first
  usage: translate the "error: "-prefix and others

 t/t1011-read-tree-sparse-checkout.sh |  6 ++---
 t/t1506-rev-parse-diagnosis.sh       |  2 +-
 t/t1600-index.sh                     |  6 ++---
 t/t3600-rm.sh                        | 36 ++++++++++++-------------
 t/t5512-ls-remote.sh                 |  6 ++---
 t/t7607-merge-overwrite.sh           |  6 ++---
 t/t7609-merge-co-error-msgs.sh       | 39 ++++++++++++++--------------
 git-compat-util.h                    |  8 ++++++
 advice.c                             | 18 ++++++-------
 usage.c                              | 28 ++++++++++++++++----
 10 files changed, 89 insertions(+), 66 deletions(-)

-- 
2.17.0.1181.g093e983b05
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help