Description
Reproduction steps
On Windows 10 (or any windows OS that supports long file paths, with Enable Win32 Long Paths enabled)
Create a file path more than 260 characters long
Create a .net application using a version of .net framework of 4.6.2 or newer, and add an application manifest to enables support for long file paths.
Call the Commands.Stage on this repo, adding all files.
An invalid path exception will be thrown indicating the path is too long.
Running "git add ." from the command line works as long as the core.longpaths=true config option is set in git, but the .net application still fails with this exception.
The system gitconfig looks as follows:
[diff "astextplain"]
textconv = astextplain
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[http]
sslBackend = schannel
[core]
autocrlf = true
symlinks = false
longpaths = true
[pull]
rebase = false
Expected behavior
Commands.Stage should add all the files to the index, as long as the file paths are less than 4096 characters.
Actual behavior
An InvalidPath exception is thrown:
Error: LibGit2Sharp.LibGit2SharpException: invalid path '\\?\C:\REPLACE WITH REALLY LONG FOLDER PATH AND FILE NAME.xml' (path too long)
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 136
at LibGit2Sharp.Core.Proxy.git_diff_index_to_workdir(RepositoryHandle repo, IndexHandle index, GitDiffOptions options) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 809
at LibGit2Sharp.Diff.<>c__DisplayClass28_0.<WorkdirToIndex>b__0(ObjectId oh, ObjectId nh, GitDiffOptions o) in C:\projects\libgit2sharp\LibGit2Sharp\Diff.cs:line 506
at LibGit2Sharp.Diff.BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever, DiffModifiers diffOptions, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) in C:\projects\libgit2sharp\LibGit2Sharp\Diff.cs:line 561
at LibGit2Sharp.Diff.Compare[T](DiffModifiers diffOptions, IEnumerable`1 paths, ExplicitPathsOptions explicitPathsOptions, CompareOptions compareOptions) in C:\projects\libgit2sharp\LibGit2Sharp\Diff.cs:line 484
at LibGit2Sharp.Commands.Stage(IRepository repository, IEnumerable`1 paths, StageOptions stageOptions) in C:\projects\libgit2sharp\LibGit2Sharp\Commands\Stage.cs:line 77
at LibGit2Sharp.Commands.Stage(IRepository repository, String path) in C:\projects\libgit2sharp\LibGit2Sharp\Commands\Stage.cs:line 25
at AppMethodCall() in C:\....\GitRepository.cs:line 118
Version of LibGit2Sharp (release number or SHA1)
0.26.2.97
Operating system(s) tested; .NET runtime tested
Windows Server 2019 Datacenter Edition, .NET Framework 4.7.2