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

Re: [PATCH] git-new-workdir: Don't fail if the target directory is empty

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2014, 19:32 UTC
Message-ID
<xmqq8uj8wbhl.fsf@gitster.dls.corp.google.com>
In-Reply-To
<s934mtwo0zv.fsf@mad-scientist.net>
Paul Smith <paul@mad-scientist.net> writes:
Show 8 quoted lines
>>> +	if test $(ls -a1 "$new_workdir/." | wc -l) -ne 2
>
>> I wonder if this check is portable for all platforms we care about,
>> but that is OK, as it should be so for the ones I think of and care
>> about ;-)
>
> Do you mean "." and ".." representing an empty directory?  That will
> work on any system where /bin/sh works, for sure.
Even on network mounts from esoteric filesystems and such?  When
    http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
mentions the "-A" option, it says:
    -A
        Write out all directory entries, including those whose names
        begin with a <period> ( '.' ) but excluding the entries dot
        and dot-dot (if they exist).

The "if they exist" part suggests, at least to me, that it is valid for a POSIX filesystem to lack these two (I suspect that one may be able to find a more definitive answer from other parts of the POSIX but I didn't bother).

Previous: Paul SmithNext: Paul Smith
Message 4 of 9 in “git-new-workdir: Don't fail if the target directory is empty”
  1. git-new-workdir: Don't fail if the target directory is emptyPaul Smith, Nov 15, 2014
  2. Junio C HamanoNov 17, 2014
  3. Paul SmithNov 18, 2014
  4. Junio C HamanoNov 18, 2014
  5. Paul SmithNov 18, 2014
  6. Junio C HamanoNov 18, 2014
  7. Paul SmithNov 18, 2014
  8. Junio C HamanoNov 18, 2014
  9. Paul SmithNov 19, 2014

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.