Re: quick bare clones taking longer?

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: quick bare clones taking longer?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:09

Junio C Hamano [off-list ref] writes:
David Miller [off-list ref] writes:
quoted
From: Junio C Hamano <redacted>
Date: Wed, 09 May 2007 15:59:23 -0700
quoted
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]$ 
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.

Signed-off-by: Junio C Hamano <redacted>
---
diff --git a/git-clone.sh b/git-clone.sh
index cad5c0c..c5852a2 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -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

Re: quick bare clones taking longer?

From: Andy Whitcroft <hidden>
Date: 2016-06-15 22:43:09

Junio C Hamano wrote:
quoted hunk
Junio C Hamano [off-list ref] writes:
quoted
David Miller [off-list ref] writes:
quoted
From: Junio C Hamano <redacted>
Date: Wed, 09 May 2007 15:59:23 -0700
quoted
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]$ 
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.

Signed-off-by: Junio C Hamano <redacted>
---
diff --git a/git-clone.sh b/git-clone.sh
index cad5c0c..c5852a2 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -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
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help