Skip to contentSkip to conversation

Bug in shallow clone?

DISCUSSION Thomas Kieffer 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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 :)

#1 lore raw
Quoted 10 lines · Thomas Kieffer

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..

Signature · 1 line
Duy
#2 lore raw
Quoted 8 lines · Duy Nguyen
Quoted 7 lines · Thomas Kieffer

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.

Quoted 7 lines
Quoted 3 lines

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.

Signature · 2 lines
Dennis Kaarsemaker
http://www.kaarsemaker.net