Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Ben Wijen <ben@wijen.net>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] git clone: don't clone into non-empty directory
Date: Wed, 1 Jul 2020 12:10:11 -0400
Message-ID: <CAPig+cTEpajuD98RH5xepJ+rK2f75SROrTvgjzKnyfjxbuA1AQ@mail.gmail.com> (raw)
In-Reply-To: <20200701093653.3706-3-ben@wijen.net>

On Wed, Jul 1, 2020 at 5:46 AM Ben Wijen <ben@wijen.net> wrote:
> When using git clone with --separate-git-dir realgitdir and
> realgitdir already exists, it's content is destroyed.
>
> Make sure we don't clone into an existing non-empty directory.
>
> Signed-off-by: Ben Wijen <ben@wijen.net>
> ---
> diff --git a/builtin/clone.c b/builtin/clone.c
> @@ -1021,6 +1021,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>                 die(_("destination path '%s' already exists and is not "
>                         "an empty directory."), dir);
>
> +       if (real_git_dir) {
> +               real_dest_exists = path_exists(real_git_dir);
> +               if (real_dest_exists && !is_empty_dir(real_git_dir))

"git init --separate-git-dir=" checks only whether the path exists,
and errors out if it does; it doesn't care whether the directory is
empty or not. I'm wondering, therefore, if this check should be
tightened to more closely align the behavior of the two commands.
(Using the tighter semantic now doesn't prohibit loosening it in the
future, whereas it's harder to tighten behavior which started out
loose.)

> +                       die(_("destination path '%s' already exists and is not "
> +                               "an empty directory."), real_git_dir);

This message might be a bit clearer if "destination" is changed to
"repository". (And drop the bit about not being empty -- if we go that
route.)

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  9:36 [PATCH 0/2] git clone with --separate-git-dir destroys existing directory content Ben Wijen
2020-07-01  9:36 ` [PATCH 1/2] git clone: check for non-empty directory Ben Wijen
2020-07-01 16:00   ` Eric Sunshine
2020-07-01 17:40     ` Eric Sunshine
2020-07-02  5:32     ` Eric Sunshine
2020-07-01  9:36 ` [PATCH 2/2] git clone: don't clone into " Ben Wijen
2020-07-01 16:10   ` Eric Sunshine [this message]
2020-07-02  7:50     ` Ben
2020-07-01 15:39 ` [PATCH 0/2] git clone with --separate-git-dir destroys existing directory content Eric Sunshine
2020-07-02  8:13   ` [PATCH v2 0/1] git clone: don't clone into non-empty directory Ben Wijen
2020-07-02  8:13   ` [PATCH v2 1/1] " Ben Wijen
2020-07-06 22:40     ` Junio C Hamano
2020-07-10  8:47       ` [PATCH v3 0/1] " Ben Wijen
2020-07-10  8:47       ` [PATCH v3 1/1] " Ben Wijen

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

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

  git send-email \
    --in-reply-to=CAPig+cTEpajuD98RH5xepJ+rK2f75SROrTvgjzKnyfjxbuA1AQ@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=ben@wijen.net \
    --cc=git@vger.kernel.org \
    /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

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git