# Bug in shallow clone?

3 messages from 2014-05-28 to 2014-05-28. Participants: Thomas Kieffer, Duy Nguyen, Dennis Kaarsemaker.
Thread: https://gitlist.dev/t/36773

## Thomas Kieffer, 2014-05-28 14:02

Subject: Bug in shallow clone?
Message-ID: <5385EC5B.8050400@web.de>
URL: https://gitlist.dev/e/5385EC5B.8050400%40web.de

```
Hi there Git developers,

I'm not sure if I found a bug in the command

git clone repo.git cloned_repo --depth 1

I follow these steps:

git init
echo "First commit" >> test.txt
git add -A
git commit -am "First commit"

echo "Second commit" >> test.txt
git commit -am "Second commit"

echo "Third commit" >> test.txt
git commit -am "Third commit"

git clone --bare . ./bare.git

I then clone the bare repository with --depth 1.

git clone file:///path/to/bare.git ./clone --depth 1

It always returns the last two commits. If I specify --depth 2 it 
returns the last 3 commits.

If I use --depth 1 on a Github repository it works as expected.

Am I doing something wrong or is it really a bug?

Kind Regards,

Thomas Kieffer


BTW.: Git is amazing and I love it :)

```

## Duy Nguyen, 2014-05-28 14:16

Subject: Re: Bug in shallow clone?
Message-ID: <CACsJy8AmxNDcxtT0XiR8-j=sO0Eo8t5E2apf5SuYU6+EogNm7w@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8AmxNDcxtT0XiR8-j%3DsO0Eo8t5E2apf5SuYU6%2BEogNm7w%40mail.gmail.com
In-Reply-To: <5385EC5B.8050400@web.de>

```
On Wed, May 28, 2014 at 9:02 PM, Thomas Kieffer <ThomasKieffer@web.de> wrote:
> I then clone the bare repository with --depth 1.
>
> git clone file:///path/to/bare.git ./clone --depth 1
>
> It always returns the last two commits. If I specify --depth 2 it returns
> the last 3 commits.
>
> If I use --depth 1 on a Github repository it works as expected.
>
> Am I doing something wrong or is it really a bug?

Depth calculation has been corrected lately. It depends on your
version, maybe it's older than 1.8.2? If it's the latest, we screwed
something up again..
-- 
Duy

```

## Dennis Kaarsemaker, 2014-05-28 14:29

Subject: Re: Bug in shallow clone?
Message-ID: <1401287364.3329.0.camel@seahawk>
URL: https://gitlist.dev/e/1401287364.3329.0.camel%40seahawk
In-Reply-To: <CACsJy8AmxNDcxtT0XiR8-j=sO0Eo8t5E2apf5SuYU6+EogNm7w@mail.gmail.com>

```
On wo, 2014-05-28 at 21:16 +0700, Duy Nguyen wrote:
> On Wed, May 28, 2014 at 9:02 PM, Thomas Kieffer <ThomasKieffer@web.de> wrote:
> > I then clone the bare repository with --depth 1.
> >
> > git clone file:///path/to/bare.git ./clone --depth 1
> >
> > It always returns the last two commits. If I specify --depth 2 it returns
> > the last 3 commits.
> >
> > If I use --depth 1 on a Github repository it works as expected.
> >
> > Am I doing something wrong or is it really a bug?
> 
> Depth calculation has been corrected lately. It depends on your
> version, maybe it's older than 1.8.2? If it's the latest, we screwed
> something up again..

2.0.0-rc4 does this correctly.
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net

```
