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

Re: [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2017, 17:16 UTC
Message-ID
<xmqq8tnkvyj6.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170401090350.t2tlpul2hm55xt6b@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> I think we actually prefer just:
>
>   >dir/b
>
> in our tests. The advantages over touch are:
>
>   1. It is clear that the output will be empty afterwards (whereas with
>      touch, it might just update the timestamp on an existing file).
>
>   2. It's faster, since it doesn't require an extra process.
>
> It's equivalent to ": >dir/b". I think you'll find all three forms in
> our test suite, but ">dir/b" is the most common.
Another one.
    3. Avoiding "touch" when we only want to ensure existence of a
       file and sticking to ">dir/b" (with or without ":" no-op)
       lets us reserve "touch" for the intended use of the command.
       When seeing a "touch", the reader is signalled that the
       script cares about the timestamp of the target file updated.

Among the three, this one is the most important reason from the point of view of making the codebase maintainable in the longer term. By forcing the writer to think when choosing between ">target" and "touch target", we reduce the mental load of the readers. As is true for most things in computer field, read happens more often than write while maintaining the code, and that is why this matters.

Previous: Jeff KingNext: Michael Haggerty
Message 11 of 19 in “[GSoC] remove_subtree(): reimplement using iterators”
  1. 0/6 [GSoC] remove_subtree(): reimplement using iteratorsDaniel Ferreira, Mar 30, 2017
  2. 1/6 dir_iterator: add helpers to dir_iterator_advanceDaniel Ferreira, Mar 30, 2017
  3. 2/6 dir_iterator: refactor state machine modelDaniel Ferreira, Mar 30, 2017
  4. Michael HaggertyMar 30, 2017
  5. 3/6 dir_iterator: iterate over dir after its contentsDaniel Ferreira, Mar 30, 2017
  6. Michael HaggertyMar 30, 2017
  7. 4/6 dir_iterator: add tests for dir_iterator APIDaniel Ferreira, Mar 30, 2017
  8. Michael HaggertyMar 30, 2017
  9. Daniel Ferreira (theiostream)Mar 30, 2017
  10. Jeff KingApr 1, 2017
  11. Junio C HamanoApr 1, 2017
  12. Michael HaggertyMar 30, 2017
  13. Michael HaggertyMar 30, 2017
  14. Daniel Ferreira (theiostream)Mar 30, 2017
  15. 5/6 remove_subtree(): reimplement using iteratorsDaniel Ferreira, Mar 30, 2017
  16. 6/6 remove_subtree(): test removing nested directoriesDaniel Ferreira, Mar 30, 2017
  17. Michael HaggertyMar 30, 2017
  18. Michael HaggertyMar 30, 2017
  19. Duy NguyenMar 30, 2017

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.