test_expect_success 'plain nested in bare' '
(
- unset GIT_DIR GIT_WORK_TREE &&
+ sane_unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor.git &&
cd bare-ancestor.git &&
mkdir plain-nested &&
test_expect_success 'plain through aliased command, outside any git repo' '
(
- unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
+ sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
HOME=$(pwd)/alias-config &&
export HOME &&
mkdir alias-config &&
test_expect_failure 'plain nested through aliased command' '
(
- unset GIT_DIR GIT_WORK_TREE &&
+ sane_unset GIT_DIR GIT_WORK_TREE &&
git init plain-ancestor-aliased &&
cd plain-ancestor-aliased &&
echo "[alias] aliasedinit = init" >>.git/config &&
test_expect_failure 'plain nested in bare through aliased command' '
(
- unset GIT_DIR GIT_WORK_TREE &&
+ sane_unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor-aliased.git &&
cd bare-ancestor-aliased.git &&
echo "[alias] aliasedinit = init" >>config &&
! 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