# git-clone removes destination path after permission deny

3 messages from 2018-08-16 to 2018-08-16. Participants: Agis, Jonathan Nieder.
Thread: https://gitlist.dev/t/49148

## Agis, 2018-08-16 12:08

Subject: git-clone removes destination path after permission deny
Message-ID: <A1C23FEE-55CC-4888-9BD5-1C4566E83A38@gmail.com>
URL: https://gitlist.dev/e/A1C23FEE-55CC-4888-9BD5-1C4566E83A38%40gmail.com

```
Hello.

I've recently observed the following:

    $ mkdir foo
    $ # try to clone from a repository that you have no access to
    $ git clone git@github.com:agis/private.git foo
    Cloning into 'foo'...
    Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    $ ls foo
    ls: cannot access 'foo': No such file or directory

Is this expected behavior?

Thanks in advance,
Agis

P.S. If this is something that should be fixed, I'd be happy to prepare a patch


```

## Agis, 2018-08-16 12:16

Subject: Re: git-clone removes destination path after permission deny
Message-ID: <450A55F6-A4B8-4841-8814-FC7365EFE43E@gmail.com>
URL: https://gitlist.dev/e/450A55F6-A4B8-4841-8814-FC7365EFE43E%40gmail.com
In-Reply-To: <A1C23FEE-55CC-4888-9BD5-1C4566E83A38@gmail.com>

```
Nevermind, this is does not happen in 2.18.0. Apparently it was fixed somewhere between 2.11 and 2.18.

> On 16 Aug 2018, at 15:08, Agis <agis.anast@gmail.com> wrote:
> 
> Hello.
> 
> I've recently observed the following:
> 
>    $ mkdir foo
>    $ # try to clone from a repository that you have no access to
>    $ git clone git@github.com:agis/private.git foo
>    Cloning into 'foo'...
>    Permission denied (publickey).
>    fatal: Could not read from remote repository.
> 
>    Please make sure you have the correct access rights
>    and the repository exists.
>    $ ls foo
>    ls: cannot access 'foo': No such file or directory
> 
> Is this expected behavior?
> 
> Thanks in advance,
> Agis
> 
> P.S. If this is something that should be fixed, I'd be happy to prepare a patch
> 


```

## Jonathan Nieder, 2018-08-16 23:43

Subject: Re: git-clone removes destination path after permission deny
Message-ID: <20180816234324.GA66961@aiede.svl.corp.google.com>
URL: https://gitlist.dev/e/20180816234324.GA66961%40aiede.svl.corp.google.com
In-Reply-To: <450A55F6-A4B8-4841-8814-FC7365EFE43E@gmail.com>

```
Hi,

Agis wrote:
> On 16 Aug 2018, at 15:08, Agis <agis.anast@gmail.com> wrote:

>>    $ mkdir foo
>>    $ git clone git@github.com:agis/private.git foo
>>    Cloning into 'foo'...
>>    Permission denied (publickey).
>>    fatal: Could not read from remote repository.
[...]
>>    $ ls foo
>>    ls: cannot access 'foo': No such file or directory
>>
>> Is this expected behavior?
[...]
> Nevermind, this is does not happen in 2.18.0. Apparently it was
> fixed somewhere between 2.11 and 2.18.

Indeed, this was fixed by v2.16.2~5^2 (clone: do not clean up
directories we didn't create, 2018-01-02).

Cc-ing the author of that change (Peff) so he can meet a happy
user of it. :)

Thanks and hope that helps,
Jonathan

```
