Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git init with core.hidedotfiles #131

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions builtin/init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
if (!strcmp(k, "init.templatedir"))
dscho marked this conversation as resolved.
Show resolved Hide resolved
return git_config_pathname(&init_db_template_dir, k, v);

if (starts_with(k, "core."))
return platform_core_config(k, v, cb);

return 0;
}

Expand Down Expand Up @@ -185,6 +188,7 @@ static int create_default_files(const char *template_path,
struct strbuf err = STRBUF_INIT;

/* Just look for `init.templatedir` */
init_db_template_dir = NULL; /* re-set in case it was set before */
git_config(git_init_db_config, NULL);

/*
Expand Down Expand Up @@ -361,6 +365,9 @@ int init_db(const char *git_dir, const char *real_git_dir,
}
startup_info->have_repository = 1;

/* Just look for `core.hidedotfiles` */
git_config(git_init_db_config, NULL);

safe_create_dir(git_dir, 0);

init_is_bare_repository = is_bare_repository();
Expand Down
11 changes: 11 additions & 0 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,17 @@ test_expect_success 're-init from a linked worktree' '
)
'

test_expect_success MINGW 'core.hidedotfiles = false' '
git config --global core.hidedotfiles false &&
rm -rf newdir &&
mkdir newdir &&
(
sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
git -C newdir init
) &&
! is_hidden newdir/.git
'

test_expect_success MINGW 'redirect std handles' '
GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&
test .git = "$(cat output.txt)" &&
Expand Down