From cf4203648539d4974753f8fdfa1f11a0e72c9bb0 Mon Sep 17 00:00:00 2001 From: Yonghao Zou Date: Thu, 21 Aug 2025 15:22:18 +0800 Subject: [PATCH] Use patch instead of git apply In the case of downloading the source code directly instead of `git clone`, there is no `.git` folder. The `git apply` command will fail. This commit use `patch` to fix this case. --- truffle/mx.truffle/mx_truffle.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 442de76fc0a6..0bd08e6ba040 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -1961,10 +1961,12 @@ def build(self): mx.Extractor.create(self.subject.sources.get_path(False)).extract(self.out_dir) mx.log('Applying patches...') - git_apply = ['git', 'apply', '--whitespace=nowarn', '--unsafe-paths', '--directory', - os.path.join(os.path.realpath(self.out_dir), self.srcDir)] - for patch in self.subject.patches(self.delegate.toolchain): - mx.run(git_apply + [patch], cwd=self.subject.suite.vc_dir) + patch_dir = os.path.join(os.path.realpath(self.out_dir), self.srcDir) + for patch_file in self.subject.patches(self.delegate.toolchain): + mx.log(f"Applying patch: {patch_file}") + with open(patch_file, 'r') as pf: + patch_content = pf.read() + mx.run(['patch', '-d', patch_dir, '-p1'], cwd=self.subject.suite.vc_dir, stdin=patch_content) self.delegate.logBuild() self.delegate.build()