globalOptions.setSearchPaths

Set the search paths for a given level of config data.

Note: Use the magic path "$PATH" to include the old value of the path. This is useful for prepending or appending paths.

Note: Passing a null or empty array of paths will reset the paths to their defaults (based on environment variables).

Note: configLevel must be one of GitConfigLevel.system, GitConfigLevel.xdg, or GitConfigLevel.global.

struct globalOptions
static
void
setSearchPaths

Examples

foreach (config; EnumMembers!GitConfigLevel)
{
    if (config != GitConfigLevel.system
        && config != GitConfigLevel.xdg
        && config != GitConfigLevel.global)
    {
        assertThrown!GitException(getSearchPaths(config));
        assertThrown!GitException(setSearchPaths(config, []));
        continue;
    }
    else
    {
        auto oldPaths = getSearchPaths(config);
        scope(exit) setSearchPaths(config, oldPaths);

        auto newPaths = ["/foo", "$PATH", "/foo/bar"];
        setSearchPaths(config, newPaths);

        auto chained = newPaths[0] ~ oldPaths ~ newPaths[2];
        assert(getSearchPaths(config) == chained);

        setSearchPaths(config, []);
        assert(getSearchPaths(config) == oldPaths);
    }
}

Meta