提交 4ad8332e 编写于 作者: J Jonathan Nieder 提交者: Junio C Hamano

t0001: test git init when run via an alias

Add some tests to document the correct behavior of (possibly aliased)
init when run within and outside a git directory.

If I set up a simple git alias “quietinit = init --quiet”, usually it
will work just like ‘git init --quiet’.

There are some differences, unfortunately, since in the process of
checking for aliases, git has to look for a .git/config file.  If ‘git
quietinit’ is run from a subdirectory of an existing git repository,
that repository’s configuration will affect the configuration of the
new repository.  In particular, the new repository can inherit
bogus values for core.bare and core.worktree.
Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 83518360
......@@ -33,6 +33,62 @@ test_expect_success 'plain' '
check_config plain/.git false unset
'
test_expect_success 'plain nested in bare' '
(
unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor.git &&
cd bare-ancestor.git &&
mkdir plain-nested &&
cd plain-nested &&
git init
) &&
check_config bare-ancestor.git/plain-nested/.git false unset
'
test_expect_success 'plain through aliased command, outside any git repo' '
(
unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
HOME=$(pwd)/alias-config &&
export HOME &&
mkdir alias-config &&
echo "[alias] aliasedinit = init" >alias-config/.gitconfig &&
GIT_CEILING_DIRECTORIES=$(pwd) &&
export GIT_CEILING_DIRECTORIES &&
mkdir plain-aliased &&
cd plain-aliased &&
git aliasedinit
) &&
check_config plain-aliased/.git false unset
'
test_expect_failure 'plain nested through aliased command' '
(
unset GIT_DIR GIT_WORK_TREE &&
git init plain-ancestor-aliased &&
cd plain-ancestor-aliased &&
echo "[alias] aliasedinit = init" >>.git/config &&
mkdir plain-nested &&
cd plain-nested &&
git aliasedinit
) &&
check_config plain-ancestor-aliased/plain-nested/.git false unset
'
test_expect_failure 'plain nested in bare through aliased command' '
(
unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor-aliased.git &&
cd bare-ancestor-aliased.git &&
echo "[alias] aliasedinit = init" >>config &&
mkdir plain-nested &&
cd plain-nested &&
git aliasedinit
) &&
check_config bare-ancestor-aliased.git/plain-nested/.git false unset
'
test_expect_success 'plain with GIT_WORK_TREE' '
if (
unset GIT_DIR
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册