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

Re: [PATCH] i18n: config: unfold error messages marked for translation

From
Vasco Almeida <vascomalmeida@sapo.pt>
Date
Jul 28, 2016, 10:38 UTC
Message-ID
<1469702302.1884.8.camel@sapo.pt>
In-Reply-To
<xmqqy44mvol9.fsf@gitster.mtv.corp.google.com>
A Qua, 27-07-2016 às 13:00 -0700, Junio C Hamano escreveu:
Show 54 quoted lines
> Vasco Almeida <vascomalmeida@sapo.pt> writes:
> 
> > 
> > +
> > +	switch (cf->origin_type) {
> > +	case CONFIG_ORIGIN_BLOB:
> > +		error_msg = xstrfmt(_("bad config line %d in blob
> > %s"),
> > +				      cf->linenr, cf->name);
> > +		break;
> > +	case CONFIG_ORIGIN_FILE:
> > +		error_msg = xstrfmt(_("bad config line %d in file
> > %s"),
> > +				      cf->linenr, cf->name);
> > +		break;
> 
> Hmm, if we were to switch the message based on the origin type, then
> things like this:
> 
> > 
> > +	case CONFIG_ORIGIN_STDIN:
> > +		error_msg = xstrfmt(_("bad config line %d in
> > standard input %s"),
> > +				      cf->linenr, cf->name);
> > +		break;
> 
> and this:
> 
> > 
> > +	case CONFIG_ORIGIN_STDIN:
> > +		die(errno == ERANGE
> > +		    ? _("bad numeric config value '%s' for '%s' in
> > standard input %s: out of range")
> > +		    : _("bad numeric config value '%s' for '%s' in
> > standard input %s: invalid unit"),
> > +		    value, name, cf->name);
> 
> that does not have any useful cf->name can be improved even more, no?
> 
> The only reason why we pass an empty string here:
> 
> > 
> >  static int git_config_from_stdin(config_fn_t fn, void *data)
> >  {
> > -	return do_config_from_file(fn, "standard input", "", NULL,
> > stdin, data);
> > +	return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "",
> > NULL, stdin, data);
> >  }
> 
> is because do_config_from_file() function whose primary purpose is
> to read from file was reused, the interface to that function
> requires the filename there for reporting, and we do not have
> anything useful when reading from the standard input.

Probably that is why I have omitted cf->name for CONFIG_ORIGIN_STDIN instance first time I sent this patch [1]. This patch was dropped from previous i18n batch because it conflicted with other changes in flux. Forgot about that and, for no good reason, added cf->name. Thank you for pointing out.

[1] http://www.mail-archive.com/git%40vger.kernel.org/msg96368.html
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “i18n: config: unfold error messages marked for translation”
  1. i18n: config: unfold error messages marked for translationVasco Almeida, Jul 27, 2016
  2. Junio C HamanoJul 27, 2016
  3. Vasco AlmeidaJul 28, 2016
  4. Junio C HamanoJul 27, 2016
  5. i18n: config: unfold error messages marked for translationVasco Almeida, Jul 28, 2016
  6. Junio C HamanoJul 28, 2016
  7. Jeff KingJul 28, 2016

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.