aboutsummaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-03-19 22:16:56 +0700
committerJunio C Hamano <gitster@pobox.com>2011-03-19 21:48:19 -0700
commitb57fb80a7d7d19102b31ab94a28ed43ea1ee07bb (patch)
treec960ce2a4e566f9341f1623cf1f632cbda591166 /builtin/clone.c
parent9d379f4fd0a845aba3efa44b254d8e3905c3c029 (diff)
downloadgit-b57fb80a7d7d19102b31ab94a28ed43ea1ee07bb.tar.gz
git-b57fb80a7d7d19102b31ab94a28ed43ea1ee07bb.tar.xz
init, clone: support --separate-git-dir for .git file
--separate-git-dir tells git to create git dir at the specified location, instead of where it is supposed to be. A .git file that points to that location will be put in place so that it appears normal to repo discovery process. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 404f58968..097beca3a 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -42,6 +42,7 @@ static int option_local, option_no_hardlinks, option_shared, option_recursive;
static char *option_template, *option_reference, *option_depth;
static char *option_origin = NULL;
static char *option_branch = NULL;
+static const char *real_git_dir;
static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress;
@@ -80,6 +81,8 @@ static struct option builtin_clone_options[] = {
"path to git-upload-pack on the remote"),
OPT_STRING(0, "depth", &option_depth, "depth",
"create a shallow clone of that depth"),
+ OPT_STRING('L', "separate-git-dir", &real_git_dir, "gitdir",
+ "separate git dir from working tree"),
OPT_END()
};
@@ -466,7 +469,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (safe_create_leading_directories_const(git_dir) < 0)
die("could not create leading directories of '%s'", git_dir);
- set_git_dir(real_path(git_dir));
+
+ set_git_dir_init(git_dir, real_git_dir, 0);
+ if (real_git_dir)
+ git_dir = real_git_dir;
if (0 <= option_verbosity)
printf("Cloning into %s%s...\n",