Git Mailing List Archive on
 help / color / Atom feed
From: Eric Sunshine <>
To: Ben Wijen <>
Cc: Git List <>
Subject: Re: [PATCH 1/2] git clone: check for non-empty directory
Date: Wed, 1 Jul 2020 12:00:45 -0400
Message-ID: <> (raw)
In-Reply-To: <>

On Wed, Jul 1, 2020 at 5:46 AM Ben Wijen <> wrote:
> When using git clone with --separate-git-dir realgitdir and
> realgitdir already exists, it's content is destroyed.
> Extend test to make sure content is left intact
> Signed-off-by: Ben Wijen <>
> ---
> diff --git a/t/ b/t/
> @@ -271,7 +271,8 @@ test_expect_success 'fetch from gitfile parent' '
>  test_expect_success 'clone separate gitdir where target already exists' '
>         rm -rf dst &&
> -       test_must_fail git clone --separate-git-dir realgitdir src dst
> +       test_must_fail git clone --separate-git-dir realgitdir src dst &&
> +       test -f realgitdir/config
>  '

This addresses the immediate problem of the directory content being
destroyed, which is good. But, we can future-proof it even more by
also verifying (to some degree) that the existing content has not been
disturbed. Doing so would give us greater confidence against some
future change breaking "realgitdir" in some fashion other than merely
emptying it. For instance, we might do this:

    rm -rf dst &&
    echo foo=bar >realgitdir/config &&
    test_must_fail git clone --separate-git-dir realgitdir src dst &&
    grep foo=bar realgitdir/config

One other observation: To preserve bisectability (git-bisect) of
git.git itself, we want to ensure that the entire test suite still
passes at each point in a patch series. Making this change to the test
in its own patch introduces a failure into the test suite, which is
undesirable. One way to address this shortcoming would be to
temporarily change this test from 'test_must_succeed' to
'test_must_fail', and then flip it back to 'test_must_succeed' in
patch 2/2. A cleaner approach is simply to combine the two patches so
that the fix and updated test are bundled together (which makes sense
anyhow in this case since this patch is so short and need not stand on
its own).

  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 [this message]
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
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:

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

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Mailing List Archive on

Archives are clonable:
	git clone --mirror 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/ \
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone