gitui: [Windows] "panic: Any" crash in repository with filenames exceeding MAX_PATH

Hello! Love this tool, thanks for your work πŸ˜„ I encountered and reproduced an issue with the Windows binary on repositories containing long filenames.

Bug description On Windows, when running gitui.exe from the command line in repositories with filenames exceeding MAX_PATH (260 characters), it fails with the following error:

panic: Any
trace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: BaseThreadInitThunk
  10: RtlUserThreadStart

Running from Git Bash yields an additional bit of information about the crash origin:

5β£―: <unknown>>n>load: Any, message: Some(failed to fetch status: Git(Error { code: -1, klass: 30, message: "invalid path \'\\\\?\\C:\\U
   6: <unknown>\Workspace\\Git\\toto\\very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faucibus-d
   7: <unknown>orbi-dolor-ligula-tempus-dir\\very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faupanic: Anynown>uctor-morbi-dolor-ligula-tempus\' (path too long)" })), location: Location { file: "asyncgit\\src\\status.rs", line: 122trace:<unknown>
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>dInitThunk
   6: <unknown>readStart
   7: <unknown>
   8: <unknown>
   9: BaseThreadInitThunk
  10: RtlUserThreadStart

To reproduce On Windows, from command line:

git init toto
cd toto
:: 136 characters long file name
echo . > very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faucibus-diam-ut-auctor-morbi-dolor-ligula-tempus
:: 140 characters long directory name
mkdir very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faucibus-diam-ut-auctor-morbi-dolor-ligula-tempus-dir
:: At this point, gitui works
gitui
:: Move file inside directory, which will exceed MAX_PATH length
mv very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faucibus-diam-ut-auctor-morbi-dolor-ligula-tempus very-long-path-lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-quisque-pharetra-faucibus-diam-ut-auctor-morbi-dolor-ligula-tempus-dir\
:: At this point, gitui crashes
gitui

Expected behavior gitui does not crash. Since Git allows working with long paths on Windows thanks to git config core.longpaths (usually set at the --system or --global level), this scenario is not an oddity.

Context

  • OS/Distro + Version: Windows 10
  • GitUI Version: 0.8
  • Rust version: unknown (bundled in .exe I guess?)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 24 (12 by maintainers)

Most upvoted comments

@MCord thanks for volunteering here, but I think @laarmen is right and the only thing we can do is hope/wait for libgit2 to sort this limitation. BUT at least this issue should be resolved to gracefully have gitui exit with a compelling message and maybe even link the libgit issue so people can show demand πŸ˜ƒ

edit: funny how many tools suffer this: cargo, nodegit (used by many like GitKraken), gitup and even tortoiseGit

Oh well, perhaps they fixed the toolchain since that time! I may look into that when I have some free time.

@nbusseneau thanks for testing πŸ€™

  • Having an intermediate folder: we already have long_filename in long_dirname, but I did try with a small bogus tmp container just in case: it does not work either.
  • Stage all triggers the same error.

I just had a quick look, and even if the gitui code were ready to handle long paths, in the end the backing libgit2 doesn’t seem to cope with them just yet, see this issue and this recent pull request.