0

I am getting error: git apply: failed to read: No such file or directory when applying a patch and I cannot get more details on the error.

This reproduces on Windows and Linux.

Steps to reproduce:

# Create patch
git clone https://github.com/dotnet/llvm-project
git -C llvm-project diff --patch --binary --output ../llvm.patch 4b825dc642cb6eb9a060e54bf8d69288fbee4904..30e9e6bc2e9f04e0a75daf4b8088ee91f66069da -- ':(glob)**/*' ':(exclude,glob)**/*.dll' ':(exclude,glob)**/*.Dll' ':(exclude,glob)**/*.exe' ':(exclude,glob)**/*.pdb' ':(exclude,glob)**/*.mdb' ':(exclude,glob)**/*.zip' ':(exclude,glob)**/*.nupkg'

# Try to apply the patch
mkdir foo
git -C foo init
git -C foo apply --cached --ignore-space-change ../llvm.patch

Which returns this (+ exit code 128):

error: git apply: failed to read: No such file or directory

I tried running procmon while this is happening and nothing there: enter image description here

I tried excluding more files from the patch and then I was able to create/apply the patch, like so:

git -C llvm-project diff --patch --binary --output ../llvm.patch 4b825dc642cb6eb9a060e54bf8d69288fbee4904..30e9e6bc2e9f04e0a75daf4b8088ee91f66069da -- ':(glob)**/*' ':(exclude,glob)**/*.dll' ':(exclude,glob)**/*.Dll' ':(exclude,glob)**/*.exe' ':(exclude,glob)**/*.pdb' ':(exclude,glob)**/*.mdb' ':(exclude,glob)**/*.zip' ':(exclude,glob)**/*.nupkg' ':(exclude,glob)bolt' ':(exclude,glob)clang/docs' ':(exclude,glob)clang/www' ':(exclude,glob)flang' ':(exclude,glob)libclc' ':(exclude,glob)lldb' ':(exclude,glob)llvm/docs' ':(exclude,glob)mlir' ':(exclude,glob)openmp' ':(exclude,glob)polly' ':(exclude,glob)pstl' ':(exclude,glob)third-party' ':(exclude,glob)**/tests/**'

But if I do the opposite and create a patch with only the previously excluded files, I'd expect that it breaks. But this works as well!

git -C llvm-project diff --patch --binary --output ../llvm.patch 4b825dc642cb6eb9a060e54bf8d69288fbee4904..30e9e6bc2e9f04e0a75daf4b8088ee91f66069da -- ':(glob)bolt' ':(glob)clang/docs' ':(glob)clang/www' ':(glob)flang' ':(glob)libclc' ':(glob)lldb' ':(glob)llvm/docs' ':(glob)mlir' ':(glob)openmp' ':(glob)polly' ':(glob)pstl' ':(glob)third-party' ':(glob)**/tests/**' ':(exclude,glob)**/*.dll' ':(exclude,glob)**/*.Dll' ':(exclude,glob)**/*.exe' ':(exclude,glob)**/*.pdb' ':(exclude,glob)**/*.mdb' ':(exclude,glob)**/*.zip' ':(exclude,glob)**/*.nupkg'

EDIT: I found out that if I occlude the lldb directory it works, synchronizing the lldb directory on its own works too. Together, it blows up.

Only when they are together, git fails. Size of the patch is 1GB but I've had 3GB patches apply successfully before.

Can someone help me diagnose this? I believe it's a bug in git.

Premek Vysoky
  • 81
  • 1
  • 6

1 Answers1

0

So I got a response from the git team and the reason is that patch file size is limited to 1GB: Is there any method to efficiently apply large git patches?

I don't know how to override this.

Premek Vysoky
  • 81
  • 1
  • 6