msysgit: option to not set hidden flag
I'm using msysgit and for files starting开发者_StackOverflow社区 with a slash, e.g. .classpath
it automatically sets the hidden flag which makes it impossible for IDEs to overwrite it. How to prevent setting this hidden flag?
Add --global to make this the default behaviour for all new repos:
git config --global core.hidedotfiles "false"
git config core.hidedotfiles "false"
Make sure to use Git 2.22 (Q2 2019) when setting the core.hidedotfiles
, before creating new repositories.
Before, "git init
" forgot to read platform-specific repository configuration, which made Windows port to ignore settings of core.hidedotfiles
, for example.
See commit 2878533 (11 Mar 2019) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit 6364386, 16 Apr 2019)
mingw
: respectcore.hidedotfiles = false
ingit init
again
This is a brown paper bag.
When adding the tests, we actually failed to verify that the config variable is heeded ingit 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 thehide_dotfiles
variable before the config was read.
The fix is obvious: read the
(limited, pre-init)
config before creating the.git/
directory.
Please note that we cannot remove the identical-looking
git_config()
call fromcreate_default_files()
: we create the.git/
directory between those calls.
If we removed it, and if the parent directory is in a Git worktree, and if that worktree's.git/config
contained anyinit.templatedir
setting, we would all of a sudden pick that up.
This fixes git-for-windows#789
This is more robust with Git 2.32 (Q2 2021), where some leaks are plugged.
See commit 68ffe09, commit 64cc539, commit 0171dbc (21 Mar 2021), and commit 04fe4d7, commit e4de450, commit aa1b639, commit 0c45427, commit e901de6, commit f63b888 (14 Mar 2021) by Andrzej Hunt (ahunt
).
(Merged by Junio C Hamano -- gitster
-- in commit 642a400, 07 Apr 2021)
init
: removegit_init_db_config()
while fixing leaksSigned-off-by: Andrzej Hunt
The primary goal of this change is to stop leaking
init_db_template_dir
.
This leak can happen because:
git_init_db_config()
allocates new memory intoinit_db_template_dir
without first freeing the existing value.init_db_template_dir
might already contain data, either because: 2.1git_config()
can be invoked twice with this callback in a single process - at least 2 allocations are likely.
2.2 A singlegit_config()
allocation can invoke the callback multiple times for a given key (see further explanation in the function docs) - each of those calls will trigger another leak.The simplest fix for the leak would be to
free(init_db_template_dir)
before overwriting it.
Instead we choose to convert to fetching init.templatedir viagit_config_get_value()
as that is more explicit, more efficient, and avoids allocations (the returned result is owned by the config cache, so we aren't responsible for freeing it).If we remove
init_db_template_dir,
git_init_db_config()
ends up being responsible only for forwardingcore.*
config values toplatform_core_config()
.
Howeverplatform_core_config()
already ignoresnon-core.*
config values, so we can safely removegit_init_db_config()
and invokegit_config()
directly withplatform_core_config()
as the callback.The
platform_core_config
forwarding was originally added in:
- 2878533 (
mingw
: respectcore.hidedotfiles = false
in git-init again, 2019-03-11, Git v2.22.0-rc0 -- merge listed in batch #5)- And I suspect the potential for a leak existed since the original implementation of
git_init_db_config
in: 90b4518 ("Addinit.templatedir
configuration variable.", 2010-02-17, Git v1.7.1-rc0 -- merge)
精彩评论