开发者

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: respect core.hidedotfiles = false in git init again

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.

Please note that we cannot remove the identical-looking git_config() call from create_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 any init.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: remove git_init_db_config() while fixing leaks

Signed-off-by: Andrzej Hunt

The primary goal of this change is to stop leaking init_db_template_dir.
This leak can happen because:

  1. git_init_db_config() allocates new memory into init_db_template_dir without first freeing the existing value.
  2. init_db_template_dir might already contain data, either because: 2.1 git_config() can be invoked twice with this callback in a single process - at least 2 allocations are likely.
    2.2 A single git_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 via git_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 forwarding core.* config values to platform_core_config().
However platform_core_config() already ignores non-core.* config values, so we can safely remove git_init_db_config() and invoke git_config() directly with platform_core_config() as the callback.

The platform_core_config forwarding was originally added in:

  • 2878533 (mingw: respect core.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 ("Add init.templatedir configuration variable.", 2010-02-17, Git v1.7.1-rc0 -- merge)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜