mirror of
https://github.com/git/git.git
synced 2025-01-27 09:53:42 +08:00
Merge branch 'es/init-no-separate-git-dir-in-bare'
The purpose of "git init --separate-git-dir" is to initialize a new project with the repository separate from the working tree, or, in the case of an existing project, to move the repository (the .git/ directory) out of the working tree. It does not make sense to use --separate-git-dir with a bare repository for which there is no working tree, so disallow its use with bare repositories. * es/init-no-separate-git-dir-in-bare: init: disallow --separate-git-dir with bare repository
This commit is contained in:
commit
a654836d96
@ -563,6 +563,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
|
argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
|
||||||
|
|
||||||
|
if (real_git_dir && is_bare_repository_cfg == 1)
|
||||||
|
die(_("--separate-git-dir and --bare are mutually exclusive"));
|
||||||
|
|
||||||
if (real_git_dir && !is_absolute_path(real_git_dir))
|
if (real_git_dir && !is_absolute_path(real_git_dir))
|
||||||
real_git_dir = real_pathdup(real_git_dir, 1);
|
real_git_dir = real_pathdup(real_git_dir, 1);
|
||||||
|
|
||||||
@ -658,6 +661,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
|
|||||||
get_git_work_tree());
|
get_git_work_tree());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (real_git_dir)
|
||||||
|
die(_("--separate-git-dir incompatible with bare repository"));
|
||||||
if (work_tree)
|
if (work_tree)
|
||||||
set_git_work_tree(work_tree);
|
set_git_work_tree(work_tree);
|
||||||
}
|
}
|
||||||
|
@ -316,6 +316,19 @@ test_expect_success 'init with separate gitdir' '
|
|||||||
test_path_is_dir realgitdir/refs
|
test_path_is_dir realgitdir/refs
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'explicit bare & --separate-git-dir incompatible' '
|
||||||
|
test_must_fail git init --bare --separate-git-dir goop.git bare.git 2>err &&
|
||||||
|
test_i18ngrep "mutually exclusive" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'implicit bare & --separate-git-dir incompatible' '
|
||||||
|
test_when_finished "rm -rf bare.git" &&
|
||||||
|
mkdir -p bare.git &&
|
||||||
|
test_must_fail env GIT_DIR=. \
|
||||||
|
git -C bare.git init --separate-git-dir goop.git 2>err &&
|
||||||
|
test_i18ngrep "incompatible" err
|
||||||
|
'
|
||||||
|
|
||||||
test_lazy_prereq GETCWD_IGNORES_PERMS '
|
test_lazy_prereq GETCWD_IGNORES_PERMS '
|
||||||
base=GETCWD_TEST_BASE_DIR &&
|
base=GETCWD_TEST_BASE_DIR &&
|
||||||
mkdir -p $base/dir &&
|
mkdir -p $base/dir &&
|
||||||
|
Loading…
Reference in New Issue
Block a user