From: Andy Whitcroft <apw@shadowen•org>
To: Junio C Hamano <junkio@cox•net>
Cc: David Miller <davem@davemloft•net>, git@vger•kernel.org
Subject: Re: quick bare clones taking longer?
Date: Thu, 10 May 2007 18:04:55 +0100 [thread overview]
Message-ID: <464350B7.3030601@shadowen.org> (raw)
In-Reply-To: <7vd519r10c.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> Junio C Hamano <junkio@cox•net> writes:
>
>> David Miller <davem@davemloft•net> writes:
>>
>>> From: Junio C Hamano <junkio@cox•net>
>>> Date: Wed, 09 May 2007 15:59:23 -0700
>>>
>>>> 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 <junkio@cox•net>
> ---
>
> 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
prev parent reply other threads:[~2007-05-10 17:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 9:09 quick bare clones taking longer? David Miller
2007-05-09 11:09 ` Johannes Schindelin
2007-05-09 15:41 ` Junio C Hamano
2007-05-09 20:06 ` David Miller
2007-05-09 21:48 ` Junio C Hamano
2007-05-09 22:02 ` David Miller
2007-05-09 22:59 ` Junio C Hamano
2007-05-09 23:23 ` David Miller
2007-05-09 23:25 ` Junio C Hamano
2007-05-10 0:11 ` Junio C Hamano
2007-05-10 0:27 ` Junio C Hamano
2007-05-10 0:29 ` David Miller
2007-05-10 8:05 ` Matthieu Moy
2007-05-10 8:25 ` Junio C Hamano
2007-05-10 8:55 ` Matthieu Moy
2007-05-10 15:38 ` Brian Gernhardt
2007-05-12 15:25 ` Win32 version, was " Johannes Schindelin
2007-05-12 15:48 ` Brian Gernhardt
2007-05-10 8:56 ` Johannes Sixt
2007-05-10 20:52 ` Dan Nicholson
2007-05-10 21:55 ` Junio C Hamano
2007-05-10 22:08 ` Dan Nicholson
2007-05-10 23:22 ` Junio C Hamano
2007-05-10 17:04 ` Andy Whitcroft [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=464350B7.3030601@shadowen.org \
--to=apw@shadowen$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=junkio@cox$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox