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

Re: [PATCH 1/1] t1403: prefer test_path_exists helper function

From
Mahendra Dani <danimahendra0904@gmail.com>
Date
Mar 4, 2025, 17:35 UTC
Message-ID
<CABGrwBBaHzM9tE6vWkuMSZuUbHVWwCZVTgkvMb04C=NYyGCLAw@mail.gmail.com>
In-Reply-To
<xmqqwmd4r9jx.fsf@gitster.g>
On Tue, Mar 4, 2025 at 10:57 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 25 quoted lines
>
> Mahendra Dani <danimahendra0904@gmail.com> writes:
>
> > On Tue, Mar 4, 2025 at 5:35 PM Junio C Hamano <gitster@pobox.com> wrote:
> >>
> >> Mahendra Dani <danimahendra0904@gmail.com> writes:
> >>
> >> >> >       remove_object() {
> >> >> >               file=$(sha1_file "$*") &&
> >> >> > -             test -e "$file" &&
> >> >> > +             test_path_exists "$file" &&
> >> >> >               rm -f "$file"
> >> >> >       } &&
> >>
> >> You may want to think about why there is "-f" there.  If we remove
> >> it, do we still need to have any check there?
> >
> > Here, the "-f" flag in `rm -f "$file"` does not produce an error message even
> > if the file does not exist [1], thus the `test -e "$file"` check was redundant,
> > as pointed out by Patrick in [2].
>
> So what happens if you dropped "-f" as I hinted?  We'll notice the
> lack of file and the command exits with non-zero status.  So "test -e"
> was not necessary in the first place, was it?
>

Yes, due to the use of the "-f" flag, it's not necessary to explicitly check the lack of file using `test -e`. But if we drop the "-f" flag, we will have to check the lack of file using `test -e` or `test_path_is_file()`.

Thanks, Mahendra

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 31 in “t1403: prefer test_path_exists helper function”
  1. Mahendra DaniMar 1, 2025
  2. 1/1 t1403: prefer test_path_exists helper functionMahendra Dani, Mar 1, 2025
  3. Patrick SteinhardtMar 3, 2025
  4. Mahendra DaniMar 4, 2025
  5. Junio C HamanoMar 4, 2025
  6. Mahendra DaniMar 4, 2025
  7. Junio C HamanoMar 4, 2025
  8. Mahendra DaniMar 4, 2025
  9. Junio C HamanoMar 4, 2025
  10. Mahendra DaniMar 4, 2025
  11. Junio C HamanoMar 4, 2025
  12. Eric SunshineMar 4, 2025
  13. Junio C HamanoMar 4, 2025
  14. Eric SunshineMar 4, 2025
  15. Eric SunshineMar 4, 2025
  16. Junio C HamanoMar 4, 2025
  17. [GSOC][PATCH v2 0/1] t1403: verify path exists and is a fileMahendra Dani, Mar 4, 2025
  18. [GSOC][PATCH v3 0/1] t1403: verify path exists and is a fileMahendra Dani, Mar 4, 2025
  19. 1/1 t1403: verify that path exists and is a fileMahendra Dani, Mar 4, 2025
  20. Junio C HamanoMar 4, 2025
  21. Junio C HamanoMar 4, 2025
  22. Mahendra DaniMar 4, 2025
  23. 0/1 t1403: verify path exists and is a fileMahendra Dani, Mar 4, 2025
  24. 0/1 t1403: verify path exists and is a fileMahendra Dani, Mar 4, 2025
  25. 1/1 t1403: verify that path exists and is a fileMahendra Dani, Mar 4, 2025
  26. Junio C HamanoMar 4, 2025
  27. Mahendra DaniMar 4, 2025
  28. Junio C HamanoMar 4, 2025
  29. 1/1 t1403: verify that path exists and is a fileMahendra Dani, Mar 4, 2025
  30. Patrick SteinhardtMar 4, 2025
  31. Mahendra DaniMar 4, 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.