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

Re: [PATCH v4] json_writer: new routines to create data in JSON format

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2018, 01:22 UTC
Message-ID
<xmqq8tad9epn.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<ad15ccab-088d-b827-a9fa-c83d397c3479@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 12 quoted lines
> BTW, I forgot to mention that you had some whitespace problems
> with this patch, viz:
>
>   $ git log --oneline -1 --check master-json
>   ab643d838 (master-json) json_writer: new routines to create data in JSON format
>   t/helper/test-json-writer.c:280: trailing whitespace.
>   + */ 
>   t/t0019-json-writer.sh:179: indent with spaces.
>   +        "g": 0,
>   t/t0019-json-writer.sh:180: indent with spaces.
>   +        "h": 1
>   $ 

Yes, and the here-doc that shows expected output looked somewhat old-fashioned without using <<- indent.

Writing it in a way like this might be a reasonable workaround for "indent with spaces", which is only about the leading blank used to indent the line:

<--HT-->sed -e "s/^\|//" <<-\EOF <--HT-->| ... <--HT-->| "g": 0, <--HT-->| "h": 0, <--HT-->| ... <--HT-->EOF

That is, (1) Use the same number of HT as the line that begins the here-doc to indent the expected output; (2) but explicitly mark the left-most column with '|' or something; and then (3) write 8 or more spaces liberally as needed to reproduce the expected output.

I called it a "workaround", as another possibility is to loosen the whitespace rule in t/.gitattributes; we _could_ declare that indent with spaces is OK in these scripts as they contain many expected output examples in here-doc form.

The trailing whitespace after closing C-comment is simply a style violation that is not excuable (I think I've dealt with it when I queued the patch); it should just be fixed.

Thanks.
Previous: Ramsay JonesNext: Duy Nguyen
Message 11 of 14 in “routines to generate JSON data”
  1. routines to generate JSON datagit@jeffhostetler.com, Mar 26, 2018
  2. json_writer: new routines to create data in JSON formatgit@jeffhostetler.com, Mar 26, 2018
  3. Ramsay JonesMar 27, 2018
  4. Jeff HostetlerMar 27, 2018
  5. Ramsay JonesMar 27, 2018
  6. Jeff HostetlerMar 27, 2018
  7. Wink SavilleMar 27, 2018
  8. Randall S. BeckerMar 27, 2018
  9. Junio C HamanoMar 28, 2018
  10. Ramsay JonesMar 27, 2018
  11. Junio C HamanoMar 28, 2018
  12. Duy NguyenJun 2, 2018
  13. Jeff KingJun 2, 2018
  14. Jeff HostetlerJun 4, 2018

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.