Skip to contentSkip to conversation

quick bare clones taking longer?

DISCUSSION David Miller 8 participants 24 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

master.kernel.org just upgraded to git-1.5.1.4 and I notice that doing something like this:

	git clone --bare -n -l -s ../torvalds/linux-2.6.git test-2.6.git

is no longer an instantaneous operation, it seems to be doing a lot of stuff now:

Initialized empty Git repository in /home/davem/git/test-2.6.git/
remote: Generating pack...
remote: Done counting 480025 objects.
remote: Deltifying 480025 objects.
remote: 100% (480025/480025) done
Indexing 480025 objects.
remote: Total 480025 (delta 385878), reused 473265 (delta 379369)
100% (480025/480025) done
Resolving 385878 deltas.
100% (385878/385878) done

Is there a new way to get a quick clone?

Thanks!

#1 lore raw
Quoted 19 lines · David Miller

master.kernel.org just upgraded to git-1.5.1.4 and I notice that doing something like this:

	git clone --bare -n -l -s ../torvalds/linux-2.6.git test-2.6.git

is no longer an instantaneous operation, it seems to be doing a lot of stuff now:

Initialized empty Git repository in /home/davem/git/test-2.6.git/
remote: Generating pack...
remote: Done counting 480025 objects.
remote: Deltifying 480025 objects.
remote: 100% (480025/480025) done
Indexing 480025 objects.
remote: Total 480025 (delta 385878), reused 473265 (delta 379369)
100% (480025/480025) done
Resolving 385878 deltas.
100% (385878/385878) done

Quoted 1 line

Is there a new way to get a quick clone?

There is something very wrong. "-l -s" should never go to the "remote: Generating pack..." codepath. Is that reproducible? Could you try "sh -x git-clone" it?

#2 lore raw

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 08:41:20 -0700

Quoted 2 lines

There is something very wrong. "-l -s" should never go to the "remote: Generating pack..." codepath. Is that reproducible?

Every single time on master.kernel.org

Quoted 1 line

Could you try "sh -x git-clone" it?

Sure:

+ unset CDPATH
+ '[' -n '' ']'
+ quiet=
+ local=no
+ use_local=no
+ local_shared=no
+ unset template
+ no_checkout=
+ upload_pack=
+ bare=
+ reference=
+ origin=
+ origin_override=
+ use_separate_remote=t
+ depth=
+ no_progress=
+ test -t 1
+ case "$#,$1" in
+ bare=yes
+ shift
+ case "$#,$1" in
+ no_checkout=yes
+ shift
+ case "$#,$1" in
+ use_local=yes
+ shift
+ case "$#,$1" in
+ local_shared=yes
+ use_local=yes
+ shift
+ case "$#,$1" in
+ break
+ repo=../torvalds/linux-2.6.git
+ test -n ../torvalds/linux-2.6.git
+ test yes = yes
+ test yes = ''
+ no_checkout=yes
+ use_separate_remote=
+ test -z ''
+ origin=origin
++ get_repo_base ../torvalds/linux-2.6.git
+ base=
+ dir=test-2.6.git
+ '[' -z test-2.6.git ']'
+ '[' -e test-2.6.git ']'
+ mkdir -p test-2.6.git
++ cd test-2.6.git
++ pwd
+ D=/home/davem/git/test-2.6.git
+ trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
+ case "$bare" in
+ GIT_DIR=/home/davem/git/test-2.6.git
+ export GIT_DIR
+ git-init
Initialized empty Git repository in /home/davem/git/test-2.6.git/
+ test -n ''
+ rm -f /home/davem/git/test-2.6.git/CLONE_HEAD
+ case "$local,$use_local" in
+ case "$repo" in
+ case "$upload_pack" in
+ git-fetch-pack --all -k ../torvalds/linux-2.6.git
remote: Generating pack...

etc.

Oh, /home/davem/git is a soft symlink to /pub/scm/linux/kernel/git/davem, maybe that is confusing git to make it think the repo is not local.

#3 lore raw
Quoted 46 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 08:41:20 -0700

Quoted 2 lines

There is something very wrong. "-l -s" should never go to the "remote: Generating pack..." codepath. Is that reproducible?

Every single time on master.kernel.org

Quoted 1 line

Could you try "sh -x git-clone" it?

Sure:

+ unset CDPATH
+ '[' -n '' ']'
+ quiet=
+ local=no
+ use_local=no
+ local_shared=no
+ unset template
+ no_checkout=
+ upload_pack=
+ bare=
+ reference=
+ origin=
+ origin_override=
+ use_separate_remote=t
+ depth=
+ no_progress=
+ test -t 1
+ case "$#,$1" in
+ bare=yes
+ shift
+ case "$#,$1" in
+ no_checkout=yes
+ shift
+ case "$#,$1" in
+ use_local=yes
+ shift
+ case "$#,$1" in
+ local_shared=yes
+ use_local=yes
+ shift
+ case "$#,$1" in
+ break
+ repo=../torvalds/linux-2.6.git
+ test -n ../torvalds/linux-2.6.git

Quoted 8 lines

+ test yes = yes
+ test yes = ''
+ no_checkout=yes
+ use_separate_remote=
+ test -z ''
+ origin=origin
++ get_repo_base ../torvalds/linux-2.6.git
+ base=

This part puzzles me. The only way I could reproduce this was:

$ ls -F victim victim.git
ls: victim: No such file or directory
victim.git:
./   HEAD	config	 description	       hooks/  lost-found/  refs/
../  branches/	config~  gitcvs.master.sqlite  info/   objects/     remotes/
$ mkdir j
$ cd j
$ git clone --bare -l -s -n ../victim new.git

That is, I did not have ../victim but I did have ../victim.git/ repository, and I gave the former to "git clone".

But that suggests that you do not have ../torvalds/linux-2.6.git directory but instead have ../torvalds/linux-2.6.git.git/ which sound a bit insane.

Puzzled...

#4 lore raw

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 14:48:38 -0700

Quoted 18 lines
Quoted 6 lines

+ no_checkout=yes
+ use_separate_remote=
+ test -z ''
+ origin=origin
++ get_repo_base ../torvalds/linux-2.6.git
+ base=

This part puzzles me. The only way I could reproduce this was:

$ ls -F victim victim.git
ls: victim: No such file or directory
victim.git:
./   HEAD	config	 description	       hooks/  lost-found/  refs/
../  branches/	config~  gitcvs.master.sqlite  info/   objects/     remotes/
$ mkdir j
$ cd j
$ git clone --bare -l -s -n ../victim new.git
Quoted 8 lines

That is, I did not have ../victim but I did have ../victim.git/ repository, and I gave the former to "git clone".

But that suggests that you do not have ../torvalds/linux-2.6.git directory but instead have ../torvalds/linux-2.6.git.git/ which sound a bit insane.

Puzzled...

This deeply puzzles me too.

I'm just not going to go into my git directory using that symlink in my home directory any more. :-)

#5 lore raw
Quoted 28 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 14:48:38 -0700

Quoted 25 lines
Quoted 6 lines

+ no_checkout=yes
+ use_separate_remote=
+ test -z ''
+ origin=origin
++ get_repo_base ../torvalds/linux-2.6.git
+ base=

This part puzzles me. The only way I could reproduce this was:

$ ls -F victim victim.git
ls: victim: No such file or directory
victim.git:
./   HEAD	config	 description	       hooks/  lost-found/  refs/
../  branches/	config~  gitcvs.master.sqlite  info/   objects/     remotes/
$ mkdir j
$ cd j
$ git clone --bare -l -s -n ../victim new.git

That is, I did not have ../victim but I did have ../victim.git/ repository, and I gave the former to "git clone".

But that suggests that you do not have ../torvalds/linux-2.6.git directory but instead have ../torvalds/linux-2.6.git.git/ which sound a bit insane.

Quoted 6 lines
Quoted 1 line

Puzzled...

This deeply puzzles me too.

I'm just not going to go into my git directory using that symlink in my home directory any more. :-)

Ahhh, symlink!

get_repo_base does this:

        get_repo_base() {
                (cd "$1" && (cd .git ; pwd)) 2> /dev/null
        }

and is used like this:

# Turn the source into an absolute path if # it is local
if base=$(get_repo_base "$repo"); then
repo="$base"
local=yes
fi

That is, get_repo_base does:

* first try to cd to ../torvalds/linux-2.6.git; if it fails then give up.

* then further cd down to .git if we can but do not worry about it if we can't. Report where we are and succeed.

If the above "fails", the caller considers the cloned-from repository a non-local one, and turns off -l -s optimization.

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

#6 lore raw

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 15:59:23 -0700

Quoted 3 lines

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

Indeed:

[davem@hera ~]$ pwd
/home/davem
[davem@hera ~]$ cd git
[davem@hera git]$ pwd
/home/davem/git
[davem@hera git]$ /bin/pwd
/home/ftp/pub/scm/linux/kernel/git/davem
[davem@hera git]$

#7 lore raw
Quoted 9 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 15:59:23 -0700

Quoted 3 lines

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

Indeed:

Quoted 8 lines

[davem@hera ~]$ pwd
/home/davem
[davem@hera ~]$ cd git
[davem@hera git]$ pwd
/home/davem/git
[davem@hera git]$ /bin/pwd
/home/ftp/pub/scm/linux/kernel/git/davem
[davem@hera git]$

Thanks.

#8 lore raw
Quoted 20 lines · Junio C Hamano
Quoted 9 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 15:59:23 -0700

Quoted 3 lines

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

Indeed:

Quoted 8 lines

[davem@hera ~]$ pwd
/home/davem
[davem@hera ~]$ cd git
[davem@hera git]$ pwd
/home/davem/git
[davem@hera git]$ /bin/pwd
/home/ftp/pub/scm/linux/kernel/git/davem
[davem@hera git]$

Quoted 1 line

Thanks.

This would fix it, but I find this kind of ugly.

-- >8 --
git-clone: don't get fooled by $PWD

If you have /home/me/git symlink pointing at /pub/git/mine, trying to clone from /pub/git/his/ using relative path would not work as expected:

	$ cd /home/me
        $ cd git
        $ ls ../
        his    mine
        $ git clone -l -s -n ../his/stuff.git

This is because "cd ../his/stuff.git" done inside git-clone to check if the repository is local is confused by $PWD, which is set to /home/me, and tries to go to /home/his/stuff.git which is different from /pub/git/his/stuff.git.

We could probably say "set -P" (or "cd -P") instead, if we know the shell is POSIX, but the way the patch is coded is probably more portable.

---

git-clone.sh +8 -1
index cad5c0c..c5852a2 100755
@@ -18,7 +18,14 @@ usage() {
 }
 
 get_repo_base() {
-	(cd "$1" && (cd .git ; pwd)) 2> /dev/null
+	(
+		cd "`/bin/pwd`" &&
+		cd "$1" &&
+		(
+			cd .git
+			pwd
+		)
+	) 2>/dev/null
 }
 
 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
#9 lore raw
Quoted 59 lines · Junio C Hamano
Quoted 18 lines · Junio C Hamano
Quoted 8 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 15:59:23 -0700

Quoted 3 lines

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

Indeed:

Quoted 8 lines

[davem@hera ~]$ pwd
/home/davem
[davem@hera ~]$ cd git
[davem@hera git]$ pwd
/home/davem/git
[davem@hera git]$ /bin/pwd
/home/ftp/pub/scm/linux/kernel/git/davem
[davem@hera git]$

Quoted 1 line

Thanks.

This would fix it, but I find this kind of ugly.

-- >8 --
git-clone: don't get fooled by $PWD

If you have /home/me/git symlink pointing at /pub/git/mine, trying to clone from /pub/git/his/ using relative path would not work as expected:

	$ cd /home/me
        $ cd git
        $ ls ../
        his    mine
        $ git clone -l -s -n ../his/stuff.git

This is because "cd ../his/stuff.git" done inside git-clone to check if the repository is local is confused by $PWD, which is set to /home/me, and tries to go to /home/his/stuff.git which is different from /pub/git/his/stuff.git.

We could probably say "set -P" (or "cd -P") instead, if we know the shell is POSIX, but the way the patch is coded is probably more portable.

---

git-clone.sh +1 -1
index cad5c0c..c5852a2 100755
@@ -18,7 +18,14 @@ usage() {
 }
 
 get_repo_base() {
-	(cd "$1" && (cd .git ; pwd)) 2> /dev/null
+	(

git-clone.sh usage() { · line 31

Quoted 10 lines
git-clone.sh +7 -0
+		cd "`/bin/pwd`" &&
+		cd "$1" &&
+		(
+			cd .git
+			pwd
+		)
+	) 2>/dev/null
 }
 
 if [ -n "$GIT_SSL_NO_VERIFY" ]; then

That is pretty much how I have seen this solved in the past. One thing while you are playing with this code. There seems to be an extra sub-shell in there unnecesarily and the error redirection seems a little aggressive?

This seems to be semantically equivalent:

get_repo_base() {
	(
		cd "`/bin/pwd`" &&
		cd "$1" &&
		{
			cd .git 2>/dev/null
			pwd
		}
	)
}

-apw

#10 lore raw
In reply to Junio C Hamano
Quoted 22 lines · Junio C Hamano
Quoted 20 lines · Junio C Hamano
Quoted 17 lines · David Miller

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 15:59:23 -0700

Quoted 3 lines

The above sequence is called before we create the new directory and chdir to it. Maybe pwd has funny behaviour (e.g. $PWD) and we need to explicitly say /bin/pwd or somesuch...

Indeed:

[davem@hera ~]$ pwd
/home/davem
[davem@hera ~]$ cd git
[davem@hera git]$ pwd
/home/davem/git
[davem@hera git]$ /bin/pwd
/home/ftp/pub/scm/linux/kernel/git/davem
[davem@hera git]$

Quoted 3 lines
Quoted 1 line

Thanks.

This would fix it, but I find this kind of ugly.

Side note. Earlier you said:

master.kernel.org just upgraded to git-1.5.1.4 and I notice that doing something like this:

           git clone --bare -n -l -s ../torvalds/linux-2.6.git test-2.6.git

is no longer an instantaneous operation, it seems to be doing a lot of stuff now:

But I do not see any difference between v1.5.1.3 and v1.5.1.4 in this area. In fact, that get_repo_base() shell function has not changed since v0.99.

#11 lore raw

From: Junio C Hamano <[email protected]>
Date: Wed, 09 May 2007 17:27:41 -0700

Quoted 5 lines

Side note. Earlier you said:

master.kernel.org just upgraded to git-1.5.1.4 and I notice that doing something like this:

Quoted 8 lines
           git clone --bare -n -l -s ../torvalds/linux-2.6.git test-2.6.git

is no longer an instantaneous operation, it seems to be doing a lot of stuff now:

But I do not see any difference between v1.5.1.3 and v1.5.1.4 in this area. In fact, that get_repo_base() shell function has not changed since v0.99.

Correct. I happened to create and start using that symlink around the same time they upgraded, that's why I made that (false) connection.

There is no connection between git version and this problem, it's just the symlink thing.

#12 lore raw
In reply to Junio C Hamano

git-clone.sh usage() { · line 29

Quoted 11 lines · Junio C Hamano

get_repo_base() {

git-clone.sh +8 -1
-	(cd "$1" && (cd .git ; pwd)) 2> /dev/null
+	(
+		cd "`/bin/pwd`" &&
+		cd "$1" &&
+		(
+			cd .git
+			pwd
+		)
+	) 2>/dev/null
 }

Will this work on windows?

Signature · 1 line
Matthieu
#13 lore raw
Quoted 15 lines · Matthieu Moy

git-clone.sh usage() { · line 29

Quoted 11 lines · Junio C Hamano

get_repo_base() {

git-clone.sh +8 -1
-     (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+     (
+             cd "`/bin/pwd`" &&
+             cd "$1" &&
+             (
+                     cd .git
+                     pwd
+             )
+     ) 2>/dev/null
 }
Quoted 1 line

Will this work on windows?

Yes. As does the alternative that uses cd -P. MinGW uses bash (3.1 here).

-- Hannes

#14 lore raw
Quoted 17 lines · Johannes Sixt <J.Sixt <at> eudaptics.com> writes:
Quoted 15 lines · Matthieu Moy
Quoted 11 lines · Junio C Hamano <junkio <at> cox.net> writes:

get_repo_base() {

git-clone.sh +8 -1
-     (cd "$1" && (cd .git ; pwd)) 2> /dev/null
+     (
+             cd "`/bin/pwd`" &&
+             cd "$1" &&
+             (
+                     cd .git
+                     pwd
+             )
+     ) 2>/dev/null
 }
Quoted 4 lines
Quoted 1 line

Will this work on windows?

Yes. As does the alternative that uses cd -P. MinGW uses bash (3.1 here).

In fact, all POSIX shells should support `cd -P' according to the spec, so it should probably just be used directly instead of hoping that /bin/pwd exists.

(cd -P "$1" && (cd .git ; pwd)) 2>/dev/null

http://www.opengroup.org/onlinepubs/009695399/utilities/cd.html

--
Dan

#15 lore raw
Quoted 6 lines · Dan Nicholson

In fact, all POSIX shells should support `cd -P' according to the spec, so it should probably just be used directly instead of hoping that /bin/pwd exists.

(cd -P "$1" && (cd .git ; pwd)) 2>/dev/null

http://www.opengroup.org/onlinepubs/009695399/utilities/cd.html

Yes but no ;-). I've said this a few times on the list in the past, but I'll repeat it again for new people.

We reject something whose portability in question by saying "It's not _even in_ POSIX". We on the other hand try to refrain from saying "POSIX says you are supposed to have it, so screw people that are not fully POSIX".

#16 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Dan Nicholson

In fact, all POSIX shells should support `cd -P' according to the spec, so it should probably just be used directly instead of hoping that /bin/pwd exists.

(cd -P "$1" && (cd .git ; pwd)) 2>/dev/null

http://www.opengroup.org/onlinepubs/009695399/utilities/cd.html

Quoted 7 lines

Yes but no ;-). I've said this a few times on the list in the past, but I'll repeat it again for new people.

We reject something whose portability in question by saying "It's not _even in_ POSIX". We on the other hand try to refrain from saying "POSIX says you are supposed to have it, so screw people that are not fully POSIX".

Yes, I suppose. At the same time, git already implicitly requires more than, say, a Bourne shell. Functions, $( ) command substitution, ${} parameter expansion, $(( )) arithmetic expansion, etc. These are all standard in a POSIX shell, but may or may not exist in other shell variants.

--
Dan

#17 lore raw
Quoted 9 lines · Dan Nicholson

On 5/10/07, Junio C Hamano <[email protected]> wrote:
...

Quoted 4 lines

We reject something whose portability is in question by saying "It's not _even in_ POSIX". We on the other hand try to refrain from saying "POSIX says you are supposed to have it, so screw people that are not fully POSIX".

Yes, I suppose. At the same time, git already implicitly requires more than, say, a Bourne shell.

Yes, and the line is fuzzy and case by case. I am playing it safe as we are in pre-release freeze, also I condider /bin/pwd much more universally available than "cd -P".

#18 lore raw
In reply to Matthieu Moy
Quoted 15 lines · Matthieu Moy

git-clone.sh usage() { · line 29

Quoted 11 lines · Junio C Hamano

get_repo_base() {

git-clone.sh +8 -1
-	(cd "$1" && (cd .git ; pwd)) 2> /dev/null
+	(
+		cd "`/bin/pwd`" &&
+		cd "$1" &&
+		(
+			cd .git
+			pwd
+		)
+	) 2>/dev/null
 }

Will this work on windows?

Is that a serious question?

If so, my answer is "I do not know, but the update is not any more complex than the existing code -- both are perfectly fine POSIX shell". Besides, if there are enough users who care about Windows, there must be some competent ones among them, and we will hear from them soon enough with an improvement patch.

If not, welcome to my killfile ;-).

NB. No, the last one is not serious. I do not have a killfile.

#19 lore raw
Quoted 1 line · Junio C Hamano

Is that a serious question?

It is. I have to admit that my knowledge about POSIX kind of things on windows approaches zero, but a hardcoded /bin/something path sounds suspicious to me.

Nothing more, nothing less in my question.

Signature · 1 line
Matthieu
#20 lore raw
Quoted 7 lines · Matthieu Moy
Quoted 1 line · Junio C Hamano

Is that a serious question?

It is. I have to admit that my knowledge about POSIX kind of things on windows approaches zero, but a hardcoded /bin/something path sounds suspicious to me.

I think every POSIX environment provides _something_ for /bin and /usr/bin. There are too many scripts that start "#!/bin/bash" or "#!/usr/bin/env interpreter" for it not to. And to be POSIX, the basic utilities (like pwd and env) should be in there. Someday Git may work on Windows without a funny (for MS) environment. But that day is not today. Tomorrow doesn't look too good either. ;-)

~~ Brian

#21 lore raw

Win32 version, was Re: quick bare clones taking longer?

Hi,

Quoted 2 lines · Brian Gernhardt

Someday Git may work on Windows without a funny (for MS) environment. But that day is not today. Tomorrow doesn't look too good either. ;-)

It sure sounds like you would like that day rather sooner than later. In related news, that day will be sooner rather than later, if people who actually care deeply about this _do_ something about it.

Hth,
Dscho

#22 lore raw

Re: Win32 version, was Re: quick bare clones taking longer?

Quoted 8 lines · Johannes Schindelin
Quoted 2 lines · Brian Gernhardt

Someday Git may work on Windows without a funny (for MS) environment. But that day is not today. Tomorrow doesn't look too good either. ;-)

It sure sounds like you would like that day rather sooner than later. In related news, that day will be sooner rather than later, if people who actually care deeply about this _do_ something about it.

Actually, at the moment, my only Windows environment is inside a VM box on my Mac. So as long as it works on my Mac, I don't care how long it takes. And I have neither the time nor build environment to try to fix it. If that changes, I'll produce patches like a good code monkey.

~~ Brian

#23 lore raw
In reply to David Miller

Hi,

Quoted 19 lines · David Miller

master.kernel.org just upgraded to git-1.5.1.4 and I notice that doing something like this:

	git clone --bare -n -l -s ../torvalds/linux-2.6.git test-2.6.git

is no longer an instantaneous operation, it seems to be doing a lot of stuff now:

Initialized empty Git repository in /home/davem/git/test-2.6.git/
remote: Generating pack...
remote: Done counting 480025 objects.
remote: Deltifying 480025 objects.
remote: 100% (480025/480025) done
Indexing 480025 objects.
remote: Total 480025 (delta 385878), reused 473265 (delta 379369)
100% (480025/480025) done
Resolving 385878 deltas.
100% (385878/385878) done

Quoted 1 line

Is there a new way to get a quick clone?

I just checked out 1.5.1.4, built it, and cannot reproduce this behaviour. It's as fast as ever.

Ciao,
Dscho