# [PATCH 2/2] git-clone: Allow cloning into directories other than child of current dir.

1 messages from 2005-11-10 to 2005-11-10. Participants: Andreas Ericsson.
Thread: https://gitlist.dev/t/2427

## Andreas Ericsson, 2005-11-10 11:58

Subject: [PATCH 2/2] git-clone: Allow cloning into directories other than child of current dir.
Message-ID: <20051110115808.466765BB44@nox.op5.se>
URL: https://gitlist.dev/e/20051110115808.466765BB44%40nox.op5.se

```

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 <ae@op5.se>

---

 git-clone.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

applies-to: 28cfa6f299b27be02a24b6887f9b82b42c0e08cd
48b959195a979b113e51e898ac878a0fd7cfb30a
diff --git a/git-clone.sh b/git-clone.sh
index 70cf7a2..4b98fb1 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#/*\.git$##' -e 's#.*[/:]##')
-mkdir "$dir" &&
+[ -e "$dir" ] && $(echo "$dir already exists."; usage)
+mkdir -p "$dir" &&
 D=$(
 	(cd "$dir" && git-init-db && pwd)
 ) &&
---
0.99.9.GIT

```
