From 66c9ec25553ce7332c46e2017b9c4d7c26310fff Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Thu, 10 Nov 2005 14:12:19 +0100 Subject: Let git-clone/git-fetch follow HTTP redirections Otherwise, git-clone silently failed to clone a remote repository where redirections (ie. a response with a "Location" header line) are used. This includes the fixes from Nick Hengeveld. Signed-off-by: Josef Weidendorfer Signed-off-by: Junio C Hamano --- git-clone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 4fdd652514..aafcc18aba 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -23,7 +23,7 @@ fi http_fetch () { # $1 = Remote, $2 = Local - curl -nsf $curl_extra_args "$1" >"$2" + curl -nsfL $curl_extra_args "$1" >"$2" } clone_dumb_http () { -- cgit v1.3-5-g9baa From 0e9ab02da77fcf59fdb7d8201d3c5546cd346e63 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 11 Nov 2005 00:19:04 -0500 Subject: git-clone: quote destination directory name git-clone doesn't quote the full path to the destination directory, which causes it to fail if the path contains spaces or other characters interpreted by the shell. [jc: obviously I was not careful enough. Pavel, thanks for catching.] Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano --- git-clone.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index aafcc18aba..f5ef70b8af 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -163,7 +163,7 @@ yes,yes) rm -f "$D/.git/TMP_ALT" if test -f "$D/.git/TMP_ALT" then - ( cd $D && + ( cd "$D" && . git-parse-remote && resolve_alternates "$repo" <"./.git/TMP_ALT" ) | while read alt @@ -191,7 +191,7 @@ yes,yes) ;; esac -cd $D || exit +cd "$D" || exit if test -f ".git/HEAD" then -- cgit v1.3-5-g9baa From 0879aa28708dcdfa255fff631781e5178755498e Mon Sep 17 00:00:00 2001 From: Andreas Ericsson Date: Thu, 10 Nov 2005 12:58:08 +0100 Subject: git-clone: Keep remote names when cloning unless explicitly told not to. With this patch the following commands all clone into the local directory "repo". If repo exists, it will still barf. git-clone git://host.xz/repo.git git-clone /path/to/repo/.git git-clone host.xz:repo.git I ended up doing the same source-to-target sed'ing for all our company projects, so it was easier to add it directly to git-clone. Signed-off-by: Andreas Ericsson Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 12 +++++++----- git-clone.sh | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'git-clone.sh') diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index fefd2985f3..83f58ae536 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -8,7 +8,7 @@ git-clone - Clones a repository. SYNOPSIS -------- -'git-clone' [-l [-s]] [-q] [-n] [-u ] +'git-clone' [-l [-s]] [-q] [-n] [-u ] [] DESCRIPTION ----------- @@ -68,9 +68,11 @@ OPTIONS be any URL git-fetch supports. :: - The name of a new directory to be cloned into. It is an - error to specify an existing directory. - + The name of a new directory to clone into. The "humanish" + part of the source repository is used if no directory is + explicitly given ("repo" for "/path/to/repo.git" and "foo" + for "host.xz:foo/.git"). Cloning into an existing directory + is not allowed. Author ------ @@ -78,7 +80,7 @@ Written by Linus Torvalds Documentation -------------- -Documentation by Junio C Hamano. +Documentation by Junio C Hamano and the git-list . GIT diff --git a/git-clone.sh b/git-clone.sh index f5ef70b8af..8e7150127a 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -96,6 +96,8 @@ if base=$(get_repo_base "$repo"); then fi dir="$2" +# Try using "humanish" part of source repo if user didn't specify one +[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*/||g') mkdir "$dir" && D=$( (cd "$dir" && git-init-db && pwd) -- cgit v1.3-5-g9baa From 7f10f7c4e4943fefbc8b8310d1d1d7753f5e3aff Mon Sep 17 00:00:00 2001 From: Andreas Ericsson Date: Thu, 10 Nov 2005 12:58:08 +0100 Subject: git-clone: Allow cloning into directories other than child of current dir. This patch adds -p to mkdir and an explicit check to see if the target directory exists (since mkdir -p doesn't throw an error if it does). Signed-off-by: Andreas Ericsson Signed-off-by: Junio C Hamano --- git-clone.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 8e7150127a..f99e0adf86 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -98,7 +98,8 @@ fi dir="$2" # Try using "humanish" part of source repo if user didn't specify one [ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*/||g') -mkdir "$dir" && +[ -e "$dir" ] && $(echo "$dir already exists."; usage) +mkdir -p "$dir" && D=$( (cd "$dir" && git-init-db && pwd) ) && -- cgit v1.3-5-g9baa