# regarding fix on "git clone $there $here"

4 messages from 2018-05-09 to 2018-05-09. Participants: Leslie Wang, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/48432

## Leslie Wang, 2018-05-09 05:25

Subject: regarding fix on "git clone $there $here"
Message-ID: <2F384E33-2101-4D90-986B-FAE2FC2AD7C5@pensando.io>
URL: https://gitlist.dev/e/2F384E33-2101-4D90-986B-FAE2FC2AD7C5%40pensando.io

```
Dear git experts,

Recently we try to upgrade ubuntu from 17.10 to 18.04, then we found one inconsistent behavior on git clone.

At 2.14.1 or 2.15.1, if I run command like 
 - mkdir /tmp/111
 - git clone git@github.com:111/111 /tmp/111

because it will failure, then /tmp/111 will be removed automatically.

However, at latest 2.17.0 which is part of ubuntu 18.04, seems like git clone failure will not auto remove this folder. I notice 2.16.2 and 2.17.0 release note includes this fix. So just wonder to know if prior behavior was think of bug, and this fix has change the behavior. 

 * "git clone $there $here" is allowed even when here directory exists
   as long as it is an empty directory, but the command incorrectly
   removed it upon a failure of the operation.

Thanks & Regards
Leslie Wang
```

## Jeff King, 2018-05-09 06:41

Subject: Re: regarding fix on "git clone $there $here"
Message-ID: <20180509064131.GA26636@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20180509064131.GA26636%40sigill.intra.peff.net
In-Reply-To: <2F384E33-2101-4D90-986B-FAE2FC2AD7C5@pensando.io>

```
On Tue, May 08, 2018 at 10:25:58PM -0700, Leslie Wang wrote:

> Recently we try to upgrade ubuntu from 17.10 to 18.04, then we found
> one inconsistent behavior on git clone.
> 
> At 2.14.1 or 2.15.1, if I run command like 
>  - mkdir /tmp/111
>  - git clone git@github.com:111/111 /tmp/111
> 
> because it will failure, then /tmp/111 will be removed automatically.
> 
> However, at latest 2.17.0 which is part of ubuntu 18.04, seems like
> git clone failure will not auto remove this folder. I notice 2.16.2
> and 2.17.0 release note includes this fix. So just wonder to know if
> prior behavior was think of bug, and this fix has change the behavior. 
> 
>  * "git clone $there $here" is allowed even when here directory exists
>    as long as it is an empty directory, but the command incorrectly
>    removed it upon a failure of the operation.

Right, the old behavior was considered a bug. Git didn't create the
directory, so when rolling back its changes on failure, it shouldn't
delete it either.

-Peff

```

## Junio C Hamano, 2018-05-09 06:44

Subject: Re: regarding fix on "git clone $there $here"
Message-ID: <xmqqin7xl446.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqin7xl446.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <2F384E33-2101-4D90-986B-FAE2FC2AD7C5@pensando.io>

```
Leslie Wang <qiwa@pensando.io> writes:

> At 2.14.1 or 2.15.1, if I run command like 
>  - mkdir /tmp/111
>  - git clone git@github.com:111/111 /tmp/111
>
> because it will failure, then /tmp/111 will be removed automatically.

Yes, this was a (longstanding) bug that nobody bothered to fix for a
long time.  As "git clone" did not create /tmp/111 but it was given
to it by the external world, it shouldn't remove it upon failure.
Of course, if you omit the "mkdir" in the above sequence and let
"git clone" create /tmp/111, tne Git will remove it upon failure as
part of the clean-up.


```

## Leslie Wang, 2018-05-09 16:47

Subject: Re: regarding fix on "git clone $there $here"
Message-ID: <F55100F9-134B-41DF-8707-AA9F354E68C4@pensando.io>
URL: https://gitlist.dev/e/F55100F9-134B-41DF-8707-AA9F354E68C4%40pensando.io
In-Reply-To: <xmqqin7xl446.fsf@gitster-ct.c.googlers.com>

```
Thanks for the confirmation. It is very helpful!

Best Regards
Leslie Wang



> On May 8, 2018, at 11:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Leslie Wang <qiwa@pensando.io> writes:
> 
>> At 2.14.1 or 2.15.1, if I run command like 
>> - mkdir /tmp/111
>> - git clone git@github.com:111/111 /tmp/111
>> 
>> because it will failure, then /tmp/111 will be removed automatically.
> 
> Yes, this was a (longstanding) bug that nobody bothered to fix for a
> long time.  As "git clone" did not create /tmp/111 but it was given
> to it by the external world, it shouldn't remove it upon failure.
> Of course, if you omit the "mkdir" in the above sequence and let
> "git clone" create /tmp/111, tne Git will remove it upon failure as
> part of the clean-up.
> 


```
