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

Re: [PATCH v3 3/4] t1300: add more tests for whitespace and inline comments

From
DSDragan Simic <dsimic@manjaro.org>
Date
Mar 20, 2024, 06:46 UTC
Message-ID
<32c4718d09ff6675e37587e15e785413@manjaro.org>
In-Reply-To
<xmqqzfutjtfo.fsf@gitster.g>
On 2024-03-20 07:42, Junio C Hamano wrote:
Show 38 quoted lines
> Dragan Simic <dsimic@manjaro.org> writes:
> 
>> +test_expect_success 'setup whitespace config' '
>> +	tr "X" "\011" >.git/config <<-\EOF
>> +	[section]
>> +		Xsolid = rock
>> +		Xsparse = big XX blue
>> +		XsparseAndTail = big XX blue
>> +		XsparseAndTailQuoted = "big XX blue "
>> +		XsparseAndBiggerTail = big XX blue X X
>> +		XsparseAndBiggerTailQuoted = "big XX blue X X"
>> +		XsparseAndBiggerTailQuotedPlus = "big XX blue X X"X
>> +		XheadAndTail = Xbig blue
>> +		XheadAndTailQuoted = "Xbig blue "
>> +		XheadAndTailQuotedPlus = "Xbig blue "
>> +		Xannotated = big blueX# to be discarded
>> +		XannotatedQuoted = "big blue"X# to be discarded
>> +	EOF
>> +'
> 
> If you want to write tests where leading and trailing whitespace
> matter in them, making these invisible characters visible is a good
> way to convey your intention to your readers.
> 
> 	sed -e "s/Q/	/g" \
> 	    -e "s/^|//" \
> 	    -e "s/[$]$//" <<-\EOF
> 	|[section]
> 	|	solid = rock  $
> 	|	sparse = tab and space Q $
> 	EOF
> 
> This is still true even if we assume there is no patch corruption
> while the e-mail is in transit.  It is safe to assume that the
> receiving end of your patches uses "git am --whitespace=fix" and a
> common way to protect against it is to use the opposite of "cat -e"
> as a convention, additional to the "'|' is the left edge of paper"
> and "Q stands for HT" conventions.

Agreed, will make it so in the v4. I already had some thoughts about protecting the trailing whitespace, and making obvious it wasn't included by mistake.

Though, I'll have to use 'X' istead of 'Q' for HTs, because the option names already contain 'Q' characters.

Previous: Junio C HamanoNext: Dragan Simic
Message 8 of 16 in “Fix a bug in configuration parsing, and improve tests and documentation”
  1. 0/4 Fix a bug in configuration parsing, and improve tests and documentationDragan Simic, Mar 18, 2024
  2. 1/4 config: minor addition of whitespaceDragan Simic, Mar 18, 2024
  3. Junio C HamanoMar 20, 2024
  4. Dragan SimicMar 20, 2024
  5. 2/4 config: really keep value-internal whitespace verbatimDragan Simic, Mar 18, 2024
  6. 3/4 t1300: add more tests for whitespace and inline commentsDragan Simic, Mar 18, 2024
  7. Junio C HamanoMar 20, 2024
  8. Dragan SimicMar 20, 2024
  9. Dragan SimicMar 20, 2024
  10. Junio C HamanoMar 20, 2024
  11. Dragan SimicMar 20, 2024
  12. 4/4 config.txt: describe handling of whitespace furtherDragan Simic, Mar 18, 2024
  13. Junio C HamanoMar 20, 2024
  14. Dragan SimicMar 20, 2024
  15. Junio C HamanoMar 20, 2024
  16. Dragan SimicMar 20, 2024

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.