Skip to content

Commit

Permalink
Merge pull request git-for-windows#451: Initialize virtual filesystem…
Browse files Browse the repository at this point in the history
… settings only once

Users are noticing slowdowns with things checking GIT_VIRTUALFILESYSTEM_TEST
environment multiple times. This is likely due to checking for the virtual
filesystem while engaging with the FS Monitor feature.

Use a `static` variable to avoid initializing these globals multiple times.

Resolves git-for-windows#450.
  • Loading branch information
derrickstolee authored Oct 17, 2021
2 parents 712e3c3 + b5de7a9 commit dd53e79
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,11 @@ int git_config_get_max_percent_split_change(void)

int git_config_get_virtualfilesystem(void)
{
/* Run only once. */
static int virtual_filesystem_result = -1;
if (virtual_filesystem_result >= 0)
return virtual_filesystem_result;

if (git_config_get_pathname("core.virtualfilesystem", &core_virtualfilesystem))
core_virtualfilesystem = getenv("GIT_VIRTUALFILESYSTEM_TEST");

Expand All @@ -2593,11 +2598,13 @@ int git_config_get_virtualfilesystem(void)
if (should_run_hook) {
/* virtual file system relies on the sparse checkout logic so force it on */
core_apply_sparse_checkout = 1;
virtual_filesystem_result = 1;
return 1;
}
core_virtualfilesystem = NULL;
}

virtual_filesystem_result = 0;
return 0;
}

Expand Down

0 comments on commit dd53e79

Please sign in to comment.