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

Re: [PATCHv2] add: ignore only ignored files

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Nov 24, 2014, 10:29 UTC
Message-ID
<54730897.3000507@drmicha.warpmail.net>
In-Reply-To
<5470A4C0.3070501@web.de>
Torsten Bögershausen schrieb am 22.11.2014 um 15:59:
Show 17 quoted lines
>>> +test_expect_success 'error out when attempting to add ignored ones but add others' '
>>> +	touch a.if &&
>>> +	test_must_fail git add a.?? &&
>>> +	! (git ls-files | grep "\\.ig") &&
>>> +	(git ls-files | grep a.if)
>>> +'
>>
>> I am somewhat allergic to pipes in our test suite, because they can mask
>> errors (especially with a negated grep, because we do not know if they
>> correctly produced any output at all). But I guess this is matching the
>> surrounding code, and it is quite unlikely for `ls-files` to fail in any
>> meaningful way here. So I think it's fine.
>>
>> -Peff
> 
> 2 small comments:
> Why the escaped "\\.ig" and the unescaped "a.if"  ?

Well, the first one is copied straight from another test and the second one is by me. ;)

I want to test that no files ending in .ig are added, but that one file a.if is added. Knowing how the test is structured, it is higly unlikely that other people will add a file where the dot in a.if matches something other than a dot, but in the case of .ig I wouldn't be so sure. We could take the extra safety measure and quote "a\\.if" also, but to me that seems to make the test less readable.

Show 20 quoted lines
> The other question, this is a more general one, strikes me every time I see
> ! grep
> 
> Should we avoid it by writing "test_must_fail" instead of "!" ?
> (The current code base has a mixture of both)
> 
> The following came into my mind when working on another grepy thing,
> and it may be unnecessary clumsy:
> 
> test_expect_success 'error out when attempting to add ignored ones but add others' '
> 	touch a.if &&
> 	test_must_fail git add a.?? &&
> 	git ls-files >files.txt &&
> 	test_must_fail grep a.ig files.txt >/dev/null &&
> 	grep a.if files.txt >/dev/null &&
> 	rm files.txt
> '
> 
> (It feels as if there should be a "grepnot" ;-)
> 
I guess that was clarified in the ongoing discussion.
> The 3rd comment:
> Thanks for taking this up!
Just scratching my own itches mostly these days :)
Michael
Previous: Jeff KingNext: Michael J Gruber
Message 21 of 22 in “add: ignore only ignored files”
  1. add: ignore only ignored filesMichael J Gruber, Nov 19, 2014
  2. Junio C HamanoNov 19, 2014
  3. Jeff KingNov 19, 2014
  4. Junio C HamanoNov 19, 2014
  5. Michael J GruberNov 20, 2014
  6. Jeff KingNov 20, 2014
  7. Junio C HamanoNov 20, 2014
  8. Jeff KingNov 20, 2014
  9. Michael J GruberNov 21, 2014
  10. [PATCHv2] add: ignore only ignored filesMichael J Gruber, Nov 21, 2014
  11. Jeff KingNov 21, 2014
  12. Torsten BögershausenNov 22, 2014
  13. Jeff KingNov 22, 2014
  14. Torsten BögershausenNov 22, 2014
  15. Jeff KingNov 23, 2014
  16. Junio C HamanoNov 23, 2014
  17. Jeff KingNov 23, 2014
  18. Junio C HamanoNov 24, 2014
  19. Torsten BögershausenNov 24, 2014
  20. Jeff KingNov 25, 2014
  21. Michael J GruberNov 24, 2014
  22. Michael J GruberNov 24, 2014

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.