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

Re: [PATCH] replace 'test -[efd]' with 'test_path_is_[file,dir,executable]'

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2025, 04:16 UTC
Message-ID
<xmqqwm9c2uef.fsf@gitster.g>
In-Reply-To
<cioavyfxwgdhfzuodb7dnwzmvsui4xcxi6mljnlszjwebogajg@taejma43hgtx>
Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
Show 22 quoted lines
> On Sun, Jun 15, 2025 at 11:08:27PM -0800, Rodrigo Michelassi wrote:
>> From: rodrigocmichelassi <rodmichelassi@gmail.com>
>> 
>> 'test_path_is_file', 'test_path_is_dir' and 'test_file_is_executable' are modern path checking methods in Git's development. Replace the basic shell commands 'test -f', 'test -d' and 'test -e', respectively, with this approach
>
> Splitting this long line, into multiple lines of about 70ish columns is
> better, see the relevant documents in Documentation/ for useful suggestions.
>
>> Signed-off-by: Rodrigo Michelassi <rodmichelassi@gmail.com>
>
> This certifies that you are the author of the code, an therefore should go
> after Isabella's, who might be the original author which you improved upon.
>
>> @@ -474,7 +474,7 @@ test_expect_success 'local clone --shared from linked checkout' '
>>  
>>  test_expect_success '"add" worktree with --no-checkout' '
>>  	git worktree add --no-checkout -b swamp swamp &&
>> -	! test -e swamp/init.t &&
>> +	! test_path_is_executable swamp/init.t &&
>
> this is not acurate translation, `test -e` is true if there is any "file"
> with that name, the equivalent for that helper function would be `test -x`

Yes, "test_path_is_missing" is what you want here, without any "!", to make sure that the path does not exist.

Previous: Carlo Marcelo Arenas Belón
Message 6 of 6 in “replace 'test -[efd]' with 'test_path_is_[file,dir,executable]'”
  1. replace 'test -[efd]' with 'test_path_is_[file,dir,executable]'Rodrigo Michelassi, Jun 16, 2025
  2. Eric SunshineJun 16, 2025
  3. Junio C HamanoJun 16, 2025
  4. Eric SunshineJun 16, 2025
  5. Carlo Marcelo Arenas BelónJun 16, 2025
  6. Junio C HamanoJun 16, 2025

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.