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

Re: [PATCH v2] config: add '--sources' option to print the source of a config value

From
Jeff King <peff@peff.net>
Date
Feb 10, 2016, 15:40 UTC
Message-ID
<20160210154006.GA19867@sigill.intra.peff.net>
In-Reply-To
<CAHGBnuMMN_xEVDJ_dqWgL6QCGK08hy=ggg=6PzkSCinHr=QeFg@mail.gmail.com>
On Wed, Feb 10, 2016 at 04:33:11PM +0100, Sebastian Schuberth wrote:
Show 16 quoted lines
> > where two of the prefixes have nothing in the second slot. I expected
> > something more like:
> >
> >   file:<filename>\t</value...>
> >   blob:<blob>\t<value...>
> >   stdin\t<value...>
> >   cmd\t<value...>
> >
> > with a single delimited slot for the source, which can then be broken
> > down further if desired.  I can't think of any reason to prefer one over
> > the other rather than personal preference, though. They can both be
> > parsed unambiguously.
> 
> I also would have expected sopme like the latter, except that I'd also
> expect a colon after "stdin" and "cmd" (or "cmdline", as said above).
> I.e. the colon should be part of the prefix to mark it as such.

Yeah, I waffled on that. Having a colon means you can definitely parse to the first ":" without looking at what the prefix is. But if you don't know what the prefix is, I don't know what good that does you. IOW, I'd expect it to be parsed like:

  if (/^file:(.*)/) {
    # source is file $1
  } elsif (/^blob:(.*)/) {
    # source is blob $1
  } elsif (/^stdin/) {
    # source is stdin
  } elsif (/^cmdline/) {
    # source is cmdline
  } else {
    die "eh? I don't know about $_ at all!"
  }

That's perl, but I think most languages make prefix-parsing like that easy. I dunno. I doubt it matters all that much, and we are deep into personal preference. There's already plenty to bikeshed on the option name :)

-Peff
Previous: Sebastian SchuberthNext: Sebastian Schuberth
Message 7 of 10 in “config: add '--sources' option to print the source of a config value”
  1. config: add '--sources' option to print the source of a config valuelarsxschneider@gmail.com, Feb 10, 2016
  2. Ramsay JonesFeb 10, 2016
  3. Sebastian SchuberthFeb 10, 2016
  4. Ramsay JonesFeb 10, 2016
  5. Jeff KingFeb 10, 2016
  6. Sebastian SchuberthFeb 10, 2016
  7. Jeff KingFeb 10, 2016
  8. Sebastian SchuberthFeb 10, 2016
  9. Jeff KingFeb 10, 2016
  10. Eric SunshineFeb 10, 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.