Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to test long paths... #5446

Closed
DynConcepts opened this issue Mar 8, 2020 · 2 comments
Closed

Ability to test long paths... #5446

DynConcepts opened this issue Mar 8, 2020 · 2 comments

Comments

@DynConcepts
Copy link

I have an immediate specific need for long path support on windows. Found

Support core.longpaths on Windows #5347

but it does not appear to have been merged yet.....

It there a build (even if unofficial) that I could use for test purposes???

@tapika
Copy link

tapika commented Sep 23, 2022

Can be tested like this:

using (var config = Configuration.BuildFrom(null))
{
    var longpaths = config.GetValueOrDefault<bool>("core.longpaths", ConfigurationLevel.Global);

    // can use also "git config --system core.longpaths true", but requires elevation.
    if (!longpaths)
        longpaths = config.GetValueOrDefault<bool>("core.longpaths", ConfigurationLevel.System);

    _useCoreLongPaths = !longpaths;
}

Also need to test that windows supports long paths:

[SupportedOSPlatform("windows")]
static bool Reconfigure()
{
    using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\FileSystem"))
    {
        object o = key.GetValue("LongPathsEnabled");
        if (!(o is int) || (int)o == 0)
        {
            Console.WriteLine("\n\nError: Please enable 'LongPathsEnabled' registry entry accoding to:\n" +
                "https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry\n");
            return false;
        }
    }

    return true;
}


...somewhere in Main...

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Reconfigure())
{
    return -3;
}

Maybe close this ticket ?

@ethomson
Copy link
Member

👍 Indeed we support long paths on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants