fork-dev / TrackerWin

Bug and issue tracker for Fork for Windows
450 stars 10 forks source link

DirectoryNotFoundException in Fork when exporting a git patch containing file system path in commit message #2246

Open mshingote opened 1 month ago

mshingote commented 1 month ago

Environment:

Fork version 1.97.0.0

Os:
Edition         Windows 10 Enterprise
Version         22H2
OS build        19045.4046
Experience  Windows Feature Experience Pack 1000.19053.1000.0

Processor   11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz   2.61 GHz
Installed RAM   64.0 GB (63.7 GB usable)
System type 64-bit operating system, x64-based processor

Description: An exception of type System.IO.DirectoryNotFoundException is thrown when attempting to create patch file using Fork app. The application fails to locate a specified directory path while trying to write a git patch file.

Steps to Reproduce:

  1. Launch the Git Fork application.
  2. Do git commit with below message e.g. \Folder1\Folder2\File.txt
  3. From worktree right click on commit -> Save as Patch -> Save -> Save

See Git Error Dialogue An unexpected error occured while performing the git request

[Internal]: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\my-files\Folder1\Folder2\File.txt.patch'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
   at Fork.Git.Commands.ExportPatchGitCommand.Execute(GitModule gitModule, Sha dst, Nullable`1 src, String filePath)

Possible Causes: The specified directory path does not exist and the application does not have logic to create missing directories.

Is this expected behavior? Otherwise for default patch file name you can replace \ with -

Side note: Sourcetree do create sub folders if specified.

DanPristupov commented 1 month ago

I think Fork should replace \ with -