Re: [PATCH v2 1/1] git clone: don't clone into non-empty directory
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 6, 2020, 22:40 UTC
- Message-ID
- <xmqqv9j08dxo.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200702081335.16786-2-ben@wijen.net>
Ben Wijen <ben@wijen.net> writes:
> When using git clone with --separate-git-dir realgitdir and > realgitdir already exists, it's content is destroyed. > > So, make sure we don't clone into an existing non-empty directory.
This came from d45420c1 (clone: do not clean up directories we didn't create, 2018-01-02), where we claimed
Because we know that the only directory we'll write into is
an empty one, we can handle this case by just passing the
KEEP_TOPLEVEL flag to our recursive delete (if we could
write into populated directories, we'd have to keep track of
what we wrote and what we did not, which would be much
harder).The assumed use case is that somebody created an empty directory for our use in a grandparent directory where we have no write permission and gave it to us, and we want to do a "git clone" into it while keeping that directory alive. But we didn't make sure the directory was not empty ourselves---we just assumed it to be empty.
And the originally envisioned use case does not have anything to do with the use of --separate-git-dir at all. So from that point of view, this change does not break the originally envisioned use case, so this probably is not regressing any existing and valid use case that may not involve "--separate-git-dir", but I'd rather see that the commit message explain these things to its readers to justify itself.
Thanks.