Skip to content

Commit

Permalink
mingw: respect core.hidedotfiles = false in git-init again
Browse files Browse the repository at this point in the history
This is a brown paper bag. When adding the tests, we actually failed
to verify that the config variable is heeded in git-init at all. And
when changing the original patch that marked the .git/ directory as
hidden after reading the config, it was lost on this developer that
the new code would use the hide_dotfiles variable before the config
was read.

The fix is obvious: read the (limited, pre-init) config *before*
creating the .git/ directory.

This fixes #789

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Aug 20, 2016
1 parent b1ee3f3 commit d311a7e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
14 changes: 11 additions & 3 deletions builtin/init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
if (!strcmp(k, "init.templatedir"))
return git_config_pathname(&init_db_template_dir, k, v);

if (!strcmp(k, "core.hidedotfiles")) {
if (v && !strcasecmp(v, "dotgitonly"))
hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
else
hide_dotfiles = git_config_bool(k, v);
return 0;
}

return 0;
}

Expand Down Expand Up @@ -188,9 +196,6 @@ static int create_default_files(const char *template_path)
safe_create_dir(git_path_buf(&buf, "refs/heads"), 1);
safe_create_dir(git_path_buf(&buf, "refs/tags"), 1);

/* Just look for `init.templatedir` */
git_config(git_init_db_config, NULL);

/* First copy the templates -- we might have the default
* config file there, in which case we would want to read
* from it after installing.
Expand Down Expand Up @@ -358,6 +363,9 @@ int init_db(const char *template_dir, unsigned int flags)
if (git_link)
separate_git_dir(git_dir);

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

safe_create_dir(git_dir, 0);

init_is_bare_repository = is_bare_repository();
Expand Down
12 changes: 12 additions & 0 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,16 @@ test_expect_success MINGW 'bare git dir not hidden' '
! is_hidden newdir
'

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

test_done

0 comments on commit d311a7e

Please sign in to comment.