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

Invalid Path on Long File Paths for .net applications with long path support #1805

Open
MarkAtRamp51 opened this issue Jun 24, 2020 · 5 comments

Comments

@MarkAtRamp51
Copy link

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

@MarkAtRamp51
Copy link
Author

Actually I noticed that this isn't supported by libgit2 yet, but there is a pending pull request for it so it may come soon.

@japj
Copy link

japj commented Jul 24, 2020

This is probably also related/duplicate of the underlying problem in #1374
@MarkAtRamp51 what was the PR number? I can't seem to find a current PR related to long path support

@MarkAtRamp51
Copy link
Author

@japj It's this one libgit2/libgit2#5347

@phatcher
Copy link

phatcher commented Nov 1, 2021

This has been patched in lib2git as of release 1.2, and the LibGit2Sharp.NativeBinaries has been update to point at 1.3 so this should work now, so if the dependency is changed from 2.0.315-alpha.0.1 to 2.0.315-alpha.0.4 we should be ok.

@DenisKudelin
Copy link

Fix #2120

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

4 participants