aboutsummaryrefslogtreecommitdiff
path: root/t
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 /t
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 't')
-rwxr-xr-xt/t0001-init.sh46
-rwxr-xr-xt/t5601-clone.sh13
2 files changed, 59 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f68499321..b2e6919da 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -374,4 +374,50 @@ test_expect_success 'init prefers command line to GIT_DIR' '
! test -d otherdir/refs
'
+test_expect_success 'init with separate gitdir' '
+ rm -rf newdir &&
+ git init --separate-git-dir realgitdir newdir &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success 're-init to update git link' '
+ (
+ cd newdir &&
+ git init --separate-git-dir ../surrealgitdir
+ ) &&
+ echo "gitdir: `pwd`/surrealgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d surrealgitdir/refs &&
+ ! test -d realgitdir/refs
+'
+
+test_expect_success 're-init to move gitdir' '
+ rm -rf newdir realgitdir surrealgitdir &&
+ git init newdir &&
+ (
+ cd newdir &&
+ git init --separate-git-dir ../realgitdir
+ ) &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success 're-init to move gitdir symlink' '
+ rm -rf newdir realgitdir &&
+ git init newdir &&
+ (
+ cd newdir &&
+ mv .git here &&
+ ln -s here .git &&
+ git init -L ../realgitdir
+ ) &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs &&
+ ! test -d newdir/here
+'
+
test_done
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 987e0c846..c467b6797 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -192,4 +192,17 @@ test_expect_success 'do not respect url-encoding of non-url path' '
git clone x+y xy-regular
'
+test_expect_success 'clone separate gitdir' '
+ rm -rf dst &&
+ git clone --separate-git-dir realgitdir src dst &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected dst/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success 'clone separate gitdir where target already exists' '
+ rm -rf dst &&
+ test_must_fail git clone --separate-git-dir realgitdir src dst
+'
+
test_done