# About *git clone --depth=n* puzzle

6 messages from 2013-08-14 to 2013-08-15. Participants: XinLingchao, Stefan Beller, Jeff King, Duy Nguyen.
Thread: https://gitlist.dev/t/34691

## XinLingchao, 2013-08-14 08:20

Subject: About *git clone --depth=n* puzzle
Message-ID: <BAY169-W472B90AB796C71E8D0D038B4450@phx.gbl>
URL: https://gitlist.dev/e/BAY169-W472B90AB796C71E8D0D038B4450%40phx.gbl

```
Hi Guys,

I think I have got some trouble when I use `git clone --depth=n` command. Take a real repo for example:


`git clone https://github.com/douglarek/vimrc.git --depth=1`


then I use `git log`:
  
ˋˋˋ  
    commit d04ca09ecc723739123fae11ad56784eb0c9b36a
    Author: Lingchao Xin <douglarek@outlook.com>
    Date:   Fri Jun 7 09:39:22 2013 +0800

        Update vnudle to master branch, add wm shortcut, pylint optimization

    commit c66d827dc212f6ae8aab6b5c44631564bcbe2acd
    Author: icocoa <lingchax@outlook.com>
    Date:   Tue Mar 12 01:36:34 2013 -0700

        Merge pull request #1 from douglarek/master

        Add markdown, flake8, pylint plugin

ˋˋˋ
    but when I clone it with `file://`:

    git clone https://github.com/douglarek/vimrc.git
    git clone file://vimrc.git --depth=1 vimrc1

    I got this log:
ˋˋˋ
    commit d04ca09ecc723739123fae11ad56784eb0c9b36a
Author: Lingchao Xin <douglarek@outlook.com>
Date:   Fri Jun 7 09:39:22 2013 +0800

    Update vnudle to master branch, add wm shortcut, pylint optimization
ˋˋˋ

so the two results are not same, is it a bug? or it should be so?

My os is openSUSE 12.3 and git version 1.8.3.4; and myabe it occured in git 1.8.1.4 +.


Thanks and Best regards

Lingchao Xin 		 	   		  
```

## Stefan Beller, 2013-08-14 08:51

Subject: Re: About *git clone --depth=n* puzzle
Message-ID: <520B4529.9080304@googlemail.com>
URL: https://gitlist.dev/e/520B4529.9080304%40googlemail.com
In-Reply-To: <BAY169-W472B90AB796C71E8D0D038B4450@phx.gbl>

```
On 08/14/2013 10:20 AM, XinLingchao wrote:
> Hi Guys,
> 
> I think I have got some trouble when I use `git clone --depth=n` command. Take a real repo for example:
> 
> 
> `git clone https://github.com/douglarek/vimrc.git --depth=1`
> 
> 
> then I use `git log`:
>   
> ˋˋˋ  
>     commit d04ca09ecc723739123fae11ad56784eb0c9b36a
>     Author: Lingchao Xin <douglarek@outlook.com>
>     Date:   Fri Jun 7 09:39:22 2013 +0800
> 
>         Update vnudle to master branch, add wm shortcut, pylint optimization
> 
>     commit c66d827dc212f6ae8aab6b5c44631564bcbe2acd
>     Author: icocoa <lingchax@outlook.com>
>     Date:   Tue Mar 12 01:36:34 2013 -0700
> 
>         Merge pull request #1 from douglarek/master
> 
>         Add markdown, flake8, pylint plugin
> 
> ˋˋˋ
>     but when I clone it with `file://`:
> 
>     git clone https://github.com/douglarek/vimrc.git
>     git clone file://vimrc.git --depth=1 vimrc1
> 
>     I got this log:
> ˋˋˋ
>     commit d04ca09ecc723739123fae11ad56784eb0c9b36a
> Author: Lingchao Xin <douglarek@outlook.com>
> Date:   Fri Jun 7 09:39:22 2013 +0800
> 
>     Update vnudle to master branch, add wm shortcut, pylint optimization
> ˋˋˋ
> 
> so the two results are not same, is it a bug? or it should be so?
> 
> My os is openSUSE 12.3 and git version 1.8.3.4; and myabe it occured in git 1.8.1.4 +.
> 
> 
> Thanks and Best regards
> 
> Lingchao Xin 		 	   		  --

There was a similar discussion going on in July this year,
maybe this is an interesting read with respect to this topic
http://www.spinics.net/lists/git/msg196138.html

Stefan



```

## XinLingchao, 2013-08-14 09:19

Subject: RE: About *git clone --depth=n* puzzle
Message-ID: <BAY169-W647D5A2BFDC793ADFA5078B4450@phx.gbl>
URL: https://gitlist.dev/e/BAY169-W647D5A2BFDC793ADFA5078B4450%40phx.gbl
In-Reply-To: <520B4529.9080304@googlemail.com>

```
---------------------------------------
> Date: Wed, 14 Aug 2013 10:51:53 +0200
> From: stefanbeller@googlemail.com
> To: douglarek@outlook.com
> CC: git@vger.kernel.org; junchunx.guan@gmail.com
> Subject: Re: About *git clone --depth=n* puzzle
>
> On 08/14/2013 10:20 AM, XinLingchao wrote:
>> Hi Guys,
>>
>> I think I have got some trouble when I use `git clone --depth=n` command. Take a real repo for example:
>>
>>
>> `git clone https://github.com/douglarek/vimrc.git --depth=1`
>>
>>
>> then I use `git log`:
>>
>> ˋˋˋ
>> commit d04ca09ecc723739123fae11ad56784eb0c9b36a
>> Author: Lingchao Xin <douglarek@outlook.com>
>> Date: Fri Jun 7 09:39:22 2013 +0800
>>
>> Update vnudle to master branch, add wm shortcut, pylint optimization
>>
>> commit c66d827dc212f6ae8aab6b5c44631564bcbe2acd
>> Author: icocoa <lingchax@outlook.com>
>> Date: Tue Mar 12 01:36:34 2013 -0700
>>
>> Merge pull request #1 from douglarek/master
>>
>> Add markdown, flake8, pylint plugin
>>
>> ˋˋˋ
>> but when I clone it with `file://`:
>>
>> git clone https://github.com/douglarek/vimrc.git
>> git clone file://vimrc.git --depth=1 vimrc1
>>
>> I got this log:
>> ˋˋˋ
>> commit d04ca09ecc723739123fae11ad56784eb0c9b36a
>> Author: Lingchao Xin <douglarek@outlook.com>
>> Date: Fri Jun 7 09:39:22 2013 +0800
>>
>> Update vnudle to master branch, add wm shortcut, pylint optimization
>> ˋˋˋ
>>
>> so the two results are not same, is it a bug? or it should be so?
>>
>> My os is openSUSE 12.3 and git version 1.8.3.4; and myabe it occured in git 1.8.1.4 +.
>>
>>
>> Thanks and Best regards
>>
>> Lingchao Xin --
>
> There was a similar discussion going on in July this year,
> maybe this is an interesting read with respect to this topic
> http://www.spinics.net/lists/git/msg196138.html
>
> Stefan
>
>

Stefan, I do NOT think so, the key point is not about the depth limit, it is about whether remote clone depth equals local clone depth.

cheers

Lingchao Xin 		 	   		  
```

## Jeff King, 2013-08-14 11:59

Subject: Re: About *git clone --depth=n* puzzle
Message-ID: <20130814115956.GA29295@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130814115956.GA29295%40sigill.intra.peff.net
In-Reply-To: <BAY169-W647D5A2BFDC793ADFA5078B4450@phx.gbl>

```
On Wed, Aug 14, 2013 at 05:19:36PM +0800, XinLingchao wrote:

> > There was a similar discussion going on in July this year,
> > maybe this is an interesting read with respect to this topic
> > http://www.spinics.net/lists/git/msg196138.html
> >
> Stefan, I do NOT think so, the key point is not about the depth limit,
> it is about whether remote clone depth equals local clone depth.

I do not think it is about local vs remote, but rather about which
version of git the remote side is running. Prior to 682c7d2
(upload-pack: fix off-by-one depth calculation in shallow clone,
2013-01-11), a shallow clone always returned one extra commit. That fix
went into v1.8.2.

So if you have a post-v1.8.2 git client, a local clone will use the same
git version as the "remote" side of the connection. But if you are
contacting a remote server, the results you get will depend on what
version of git is running on the remote server.

And as the example you showed uses github.com as the remote, and as I
happen to know that GitHub's servers do not currently have 682c7d2, you
would see the old behavior.

-Peff

```

## XinLingchao, 2013-08-14 12:45

Subject: RE: About *git clone --depth=n* puzzle
Message-ID: <BAY169-W3481BBD06C4449E7C5D6F5B4450@phx.gbl>
URL: https://gitlist.dev/e/BAY169-W3481BBD06C4449E7C5D6F5B4450%40phx.gbl
In-Reply-To: <20130814115956.GA29295@sigill.intra.peff.net>

```
Peff, thanks for your detial explain,  and I think I have got the point :P

-Lingchao Xin

----------------------------------------
> Date: Wed, 14 Aug 2013 07:59:56 -0400
> From: peff@peff.net
> To: douglarek@outlook.com
> CC: stefanbeller@googlemail.com; git@vger.kernel.org; junchunx.guan@gmail.com
> Subject: Re: About *git clone --depth=n* puzzle
>
> On Wed, Aug 14, 2013 at 05:19:36PM +0800, XinLingchao wrote:
>
>>> There was a similar discussion going on in July this year,
>>> maybe this is an interesting read with respect to this topic
>>> http://www.spinics.net/lists/git/msg196138.html
>>>
>> Stefan, I do NOT think so, the key point is not about the depth limit,
>> it is about whether remote clone depth equals local clone depth.
>
> I do not think it is about local vs remote, but rather about which
> version of git the remote side is running. Prior to 682c7d2
> (upload-pack: fix off-by-one depth calculation in shallow clone,
> 2013-01-11), a shallow clone always returned one extra commit. That fix
> went into v1.8.2.
>
> So if you have a post-v1.8.2 git client, a local clone will use the same
> git version as the "remote" side of the connection. But if you are
> contacting a remote server, the results you get will depend on what
> version of git is running on the remote server.
>
> And as the example you showed uses github.com as the remote, and as I
> happen to know that GitHub's servers do not currently have 682c7d2, you
> would see the old behavior.
>
> -Peff 		 	   		  
```

## Duy Nguyen, 2013-08-15 02:08

Subject: Re: About *git clone --depth=n* puzzle
Message-ID: <CACsJy8DDf64M1qruUNH7M=eB=1cJpYuYXLEkpPUPfrREeSLEew@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8DDf64M1qruUNH7M%3DeB%3D1cJpYuYXLEkpPUPfrREeSLEew%40mail.gmail.com
In-Reply-To: <BAY169-W472B90AB796C71E8D0D038B4450@phx.gbl>

```
On Wed, Aug 14, 2013 at 3:20 PM, XinLingchao <douglarek@outlook.com> wrote:
> Hi Guys,
>
> I think I have got some trouble when I use `git clone --depth=n` command. Take a real repo for example:
>
>
> `git clone https://github.com/douglarek/vimrc.git --depth=1`
>
>
> then I use `git log`:
>
> ˋˋˋ
>     commit d04ca09ecc723739123fae11ad56784eb0c9b36a
>     Author: Lingchao Xin <douglarek@outlook.com>
>     Date:   Fri Jun 7 09:39:22 2013 +0800
>
>         Update vnudle to master branch, add wm shortcut, pylint optimization
>
>     commit c66d827dc212f6ae8aab6b5c44631564bcbe2acd
>     Author: icocoa <lingchax@outlook.com>
>     Date:   Tue Mar 12 01:36:34 2013 -0700
>
>         Merge pull request #1 from douglarek/master
>
>         Add markdown, flake8, pylint plugin
>
> ˋˋˋ
>     but when I clone it with `file://`:
>
>     git clone https://github.com/douglarek/vimrc.git
>     git clone file://vimrc.git --depth=1 vimrc1
>
>     I got this log:
> ˋˋˋ
>     commit d04ca09ecc723739123fae11ad56784eb0c9b36a
> Author: Lingchao Xin <douglarek@outlook.com>
> Date:   Fri Jun 7 09:39:22 2013 +0800
>
>     Update vnudle to master branch, add wm shortcut, pylint optimization
> ˋˋˋ
>
> so the two results are not same, is it a bug? or it should be so?
>
> My os is openSUSE 12.3 and git version 1.8.3.4; and myabe it occured in git 1.8.1.4 +.

The fix is at the server side. >=1.8.2 corrects --depth, which is what
you use for file://. github is still on 1.8.1.6, which does not have
that fix. Oh and the commit is 682c7d2 (upload-pack: fix off-by-one
depth calculation in shallow clone - 2013-01-11)
-- 
Duy

```
