git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Daniel Ferreira \(theiostream\)" <bnmvco@gmail.com>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Git Mailing List <git@vger.kernel.org>,
	Stefan Beller <sbeller@google.com>,
	Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API
Date: Sat, 01 Apr 2017 10:16:29 -0700	[thread overview]
Message-ID: <xmqq8tnkvyj6.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170401090350.t2tlpul2hm55xt6b@sigill.intra.peff.net> (Jeff King's message of "Sat, 1 Apr 2017 05:03:50 -0400")

Jeff King <peff@peff.net> writes:

> 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.


  reply	other threads:[~2017-04-01 17:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  3:32 [PATCH v5 0/6] [GSoC] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-03-30  3:32 ` [PATCH v5 1/6] dir_iterator: add helpers to dir_iterator_advance Daniel Ferreira
2017-03-30  3:32 ` [PATCH v5 2/6] dir_iterator: refactor state machine model Daniel Ferreira
2017-03-30  8:18   ` Michael Haggerty
2017-03-30  3:32 ` [PATCH v5 3/6] dir_iterator: iterate over dir after its contents Daniel Ferreira
2017-03-30 11:03   ` Michael Haggerty
2017-03-30  3:32 ` [PATCH v5 4/6] dir_iterator: add tests for dir_iterator API Daniel Ferreira
2017-03-30  7:46   ` Michael Haggerty
2017-03-30 18:25     ` Daniel Ferreira (theiostream)
2017-04-01  9:03       ` Jeff King
2017-04-01 17:16         ` Junio C Hamano [this message]
2017-03-30  7:48   ` Michael Haggerty
2017-03-30  8:05   ` Michael Haggerty
2017-03-30 18:26     ` Daniel Ferreira (theiostream)
2017-03-30  3:32 ` [PATCH v5 5/6] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-03-30  3:32 ` [PATCH v5 6/6] remove_subtree(): test removing nested directories Daniel Ferreira
2017-03-30 11:07   ` Michael Haggerty
2017-03-30 11:27 ` [PATCH v5 0/6] [GSoC] remove_subtree(): reimplement using iterators Michael Haggerty
2017-03-30 12:10   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8tnkvyj6.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=bnmvco@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).