libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Add support for long file paths in CheckoutOptions

Open denis-kudelin opened this issue 1 year ago • 3 comments

Summary

Adds support for long file paths in CheckoutOptions by introducing the LongPaths property and updating CheckoutStrategy with the GIT_CHECKOUT_LONGPATHS flag.

Changes

  • New property LongPaths in CheckoutOptions.
  • Added GIT_CHECKOUT_LONGPATHS to CheckoutStrategy.

Motivation

Enhances compatibility with projects that have deeply nested directories or long file names, especially on Windows.

denis-kudelin avatar Aug 08 '24 14:08 denis-kudelin

@bording could you take a look at this PR and help get it merged?

DrewScoggins avatar Sep 04 '24 19:09 DrewScoggins

@bording We really need this bug fixed. Please prioritize it if possible

Ogglas avatar Oct 06 '24 20:10 Ogglas

@Ogglas, I was able to workaround this by setting the longpath option in the global git config. Presuming a global git config already being present on the machine at %USERPROFILE%.gitconfig, we create a temp repo (new Repository(Repository.Init("temprepo"))) and then set the longpath setting in that global config with temp_repo.Config.Set("core.longpaths", true, ConfigurationLevel.Global);. With that set, the clone should use the global setting as long as it is not set at a more local level.

LoopedBard3 avatar Oct 17 '24 17:10 LoopedBard3

As far as I can tell, this PR isn't actually doing anything. The support for long paths on Windows that was added to libgit2 in https://github.com/libgit2/libgit2/pull/5857 only supports the core.longpaths configuration setting.

Furthermore, the GIT_CHECKOUT_LONGPATHS setting that's been added to the CheckoutStrategy enum doesn't seem to exist at all in libgit2.

(1 << 24) is an entirely different option, GIT_CHECKOUT_DRY_RUN.

The good news is that LibGit2Sharp has been respecting the core.longpaths setting since at least 0.27.0, so you can already use long paths without needing any other changes.

bording avatar Nov 24 '24 04:11 bording