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

Re: [PATCH v1] name-hash: properly fold directory names in adjust_dirname_case()

From
Ben Peart <peartben@gmail.com>
Date
Feb 8, 2018, 17:45 UTC
Message-ID
<8a6b704f-409d-9a29-2229-d792d0f503ae@gmail.com>
In-Reply-To
<20180208172153.GA30760@tor.lan>
On 2/8/2018 12:21 PM, Torsten Bögershausen wrote:
Show 32 quoted lines
> On Wed, Feb 07, 2018 at 07:41:56PM -0500, Ben Peart wrote:
> []
> 
>> diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
>> index b29d749bb7..219c96594c 100755
>> --- a/t/t0050-filesystem.sh
>> +++ b/t/t0050-filesystem.sh
>> @@ -80,7 +80,17 @@ test_expect_success 'merge (case change)' '
>>   	git merge topic
>>   '
>>   
>> -
>> +test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
>> +	git reset --hard initial &&
>> +	mkdir -p dir1 &&
>> +	mkdir -p dir1/dir2 &&
>> +	touch dir1/dir2/a &&
>> +	touch dir1/dir2/b &&
>> +	git add dir1/dir2/a &&
>> +	git add dir1/DIR2/b &&
>> +	camel=$(git ls-files | grep dir2) &&
>> +	test $(echo "$camel" | wc -l) = 2
>> +'
>>   
> 
> There is nothing wrong with with "wc -l", but:
> a more new-style would probably use test_line_count() here.
> 
> My personal favorite would be to spell out what we expect and run a diff.
> When it fails, we can see what fails, and the function would look
> like this:
> 

I agree with you completely that this is a better format and is easier to read. All the new tests I've been writing follow this same pattern.

In this particular test file, I opted (for better and for worse) to stick with the style of all the other tests rather than 1) have this one test be very different than all the others or 2) rewriting all the existing tests in the new style.

Show 19 quoted lines
> 
> test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
> 	git reset --hard initial &&
> 	mkdir -p dir1 &&
> 	mkdir -p dir1/dir2 &&
> 	touch dir1/dir2/a &&
> 	touch dir1/dir2/b &&
> 	git add dir1/dir2/a &&
> 	git add dir1/DIR2/b &&
> 	git ls-files | grep dir2 | sort >actual &&
> 	cat >expected <<-\EOF &&
> 	dir1/dir2/a
> 	dir1/dir2/b
> 	EOF
> 	test_cmp expected actual
> '
> 
> 
> 
Previous: Torsten BögershausenNext: Junio C Hamano
Message 4 of 8 in “name-hash: properly fold directory names in adjust_dirname_case()”
  1. name-hash: properly fold directory names in adjust_dirname_case()Ben Peart, Feb 8, 2018
  2. David TurnerFeb 8, 2018
  3. Torsten BögershausenFeb 8, 2018
  4. Ben PeartFeb 8, 2018
  5. Junio C HamanoFeb 8, 2018
  6. Junio C HamanoFeb 8, 2018
  7. name-hash: properly fold directory names in adjust_dirname_case()Ben Peart, Feb 8, 2018
  8. Torsten BögershausenFeb 9, 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.