将补丁应用于Git下的文件而不使用Git? [英] Apply patch to file that's under Git without using Git?
问题描述
我从Git中检出了最新的OpenSSL:
git clone git://git.openssl.org/openssl。 git
其中一位开发人员向我发送了AARCH64的补丁来测试:
$ cat RT4237.diff
diff --git a / crypto / ec / asm / ecp_nistz256-armv8.pl b / crypto / ec / asm /ecp_nistz256-armv8.pl
index 9d1bce1..ce6b69e 100644
--- a / crypto / ec / asm / ecp_nistz256-armv8.pl
+++ b / crypto / ec / asm /ecp_nistz256-armv8.pl
@@ -1289,6 +1289,9 @@ $ code。=<< ___;
stp $ acc0,$ acc1,[$ rp_real,#$ i]
stp $ acc2,$ acc3,[$ rp_real,#$ i + 16]
___
+ $ code。=<< ___ if($ i == 0);
+ adr $ bp_real,.Lone_mont-64
+ ___
}
$ code。=<< ___;
ldp $ acc0,$ acc1,[$ ap_real,#$ i] // in1
该补丁不适用于使用Git。我不会分享Git失败,所以人们不会分心解决Git问题。相反,我只是想使用一个实际工作的工具。
我试过使用将补丁文件应用到源代码树( patch -p3< RT4237.diff <
$ b
$ $ cd openssl
$ patch -p3< RT4237.diff
(从补丁中剥离尾随CR;使用--binary禁用)
在输入行5找不到要补丁的文件
也许你使用了错误的-p或 - -strip选项?
前面的文字是:
--------------------------
| diff - git a / crypto / ec / asm / ecp_nistz256-armv8.pl b / crypto / ec / asm / ecp_nistz256-armv8.pl
| index 9d1bce1..ce6b69e 100644
| --- a / crypto / ec / asm / ecp_nistz256-armv8.pl
| +++ b / crypto / ec / asm / ecp_nistz256-armv8.pl
---------------- ----------
如何使用补丁 不使用Git ?
hikey: openssl $ pwd
/ home / jwalton / openssl
hikey:openssl $ find。 -name RT4237.diff
./RT4237.diff
hikey:openssl $ find。 -name ecp_nistz256-armv8.pl
./crypto/ec/asm/ecp_nistz256-armv8.pl
基于 pwd
和补丁文件的内容,需要将补丁应用于 - p1
标志告诉补丁忽略路径名前面的a /部分,以便它找到要补丁的文件:
$ cd openssl
$ patch -p1< RT4237.diff
(从补丁中剥离尾随CR;使用--binary禁用。)
修补文件crypto / ec / asm / ecp_nistz256-armv8.pl
$
I checked out the latest OpenSSL from Git:
git clone git://git.openssl.org/openssl.git
One of the devs sent me a patch for AARCH64 to test:
$ cat RT4237.diff
diff --git a/crypto/ec/asm/ecp_nistz256-armv8.pl b/crypto/ec/asm/ecp_nistz256-armv8.pl
index 9d1bce1..ce6b69e 100644
--- a/crypto/ec/asm/ecp_nistz256-armv8.pl
+++ b/crypto/ec/asm/ecp_nistz256-armv8.pl
@@ -1289,6 +1289,9 @@ $code.=<<___;
stp $acc0,$acc1,[$rp_real,#$i]
stp $acc2,$acc3,[$rp_real,#$i+16]
___
+$code.=<<___ if ($i == 0);
+ adr $bp_real,.Lone_mont-64
+___
}
$code.=<<___;
ldp $acc0,$acc1,[$ap_real,#$i] // in1
The patch does not apply using Git. I'm not sharing the Git failure so folks don't get distracted on solving Git problems. Instead, I simply want to use a tool that actually works.
I've tried using Apply Patch File to a Source Code Tree (patch -p3 < RT4237.diff
) but its resulting in errors due to the Git preamble:
$ cd openssl
$ patch -p3 < RT4237.diff
(Stripping trailing CRs from patch; use --binary to disable.)
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/crypto/ec/asm/ecp_nistz256-armv8.pl b/crypto/ec/asm/ecp_nistz256-armv8.pl
|index 9d1bce1..ce6b69e 100644
|--- a/crypto/ec/asm/ecp_nistz256-armv8.pl
|+++ b/crypto/ec/asm/ecp_nistz256-armv8.pl
--------------------------
How can I apply the patch without using Git?
hikey:openssl$ pwd
/home/jwalton/openssl
hikey:openssl$ find . -name RT4237.diff
./RT4237.diff
hikey:openssl$ find . -name ecp_nistz256-armv8.pl
./crypto/ec/asm/ecp_nistz256-armv8.pl
Based on the pwd
and patch file's contents, the patch needed to be applied with the -p1
flag to tell patch to ignore the leading "a/" portion of the path name in order for it to find the file to patch:
$ cd openssl
$ patch -p1 < RT4237.diff
(Stripping trailing CRs from patch; use --binary to disable.)
patching file crypto/ec/asm/ecp_nistz256-armv8.pl
$
这篇关于将补丁应用于Git下的文件而不使用Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!