Re: [PATCH] submodule deinit: clarify work tree removal message
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 17, 2013, 05:16 UTC
- Message-ID
- <7vppxthh44.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CABURp0rkeYc7K0COhc1+96Q2Ox2TaNRpMSmQYOiwBpgPJbsafA@mail.gmail.com>
Phil Hord <phil.hord@gmail.com> writes:
Show 10 quoted lines
> On Mon, Apr 1, 2013 at 3:02 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> Okay, so here is the patch for that. If someone could point out
>> a portable and efficient way to check if a directory is already
>> empty I would be happy to use that to silence the "Cleaned
>> directory" message currently printed also when deinit is run on
>> an already empty directory.
>
> isemptydir() {
> test -d "$(find $1 -maxdepth 0 -empty)"
> }Hrm, -maxdepth and -empty are not even in POSIX. Folks on GNU platforms and BSDs (I checked NetBSD 6 and OpenBSD 5.2) should be fine, but it makes other platforms unhappy.
What is this check used for? To avoid running "rmdir" on non-empty ones? Saying "cleaning foo/" (or "cleaned foo/") when foo/ is already empty is not a crime; not omitting an empty one may actually be a better behaviour from the point of view of repeatability and uniformity.