git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: quick bare clones taking longer?

From
Junio C Hamano <junkio@cox.net>
Date
May 10, 2007, 00:11 UTC
Message-ID
<7vd519r10c.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vy7jxr35a.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 21 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 24 in “quick bare clones taking longer?”
  1. David MillerMay 9, 2007
  2. Johannes SchindelinMay 9, 2007
  3. Junio C HamanoMay 9, 2007
  4. David MillerMay 9, 2007
  5. Junio C HamanoMay 9, 2007
  6. David MillerMay 9, 2007
  7. Junio C HamanoMay 9, 2007
  8. David MillerMay 9, 2007
  9. Junio C HamanoMay 9, 2007
  10. Junio C HamanoMay 10, 2007
  11. Junio C HamanoMay 10, 2007
  12. David MillerMay 10, 2007
  13. Matthieu MoyMay 10, 2007
  14. Junio C HamanoMay 10, 2007
  15. Matthieu MoyMay 10, 2007
  16. Brian GernhardtMay 10, 2007
  17. Win32 version, was Re: quick bare clones taking longer?Johannes Schindelin, May 12, 2007
  18. Brian GernhardtMay 12, 2007
  19. Johannes SixtMay 10, 2007
  20. Dan NicholsonMay 10, 2007
  21. Junio C HamanoMay 10, 2007
  22. Dan NicholsonMay 10, 2007
  23. Junio C HamanoMay 10, 2007
  24. Andy WhitcroftMay 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.