河南郑州app建设网站,wordpress skydrive,微信开发者平台官网登录,网络营销与策划实践报告之前的这篇文章 git 导出差异 diff 文件 写了导出 diff 、patch 文件。
拿到 patch 文件#xff0c;用 patch 命令可以快速的把修改内容合入#xff0c;合入后在 git 上是已修改的状态#xff0c;如需提交还要 add 、commit 。
patch 语法
patch --help 可以看到
Usage:…之前的这篇文章 git 导出差异 diff 文件 写了导出 diff 、patch 文件。
拿到 patch 文件用 patch 命令可以快速的把修改内容合入合入后在 git 上是已修改的状态如需提交还要 add 、commit 。
patch 语法
patch --help 可以看到
Usage: patch [OPTION]... [ORIGFILE [PATCHFILE]]Input options:-p NUM --stripNUM Strip NUM leading components from file names.-F LINES --fuzz LINES Set the fuzz factor to LINES for inexact matching.-l --ignore-whitespace Ignore white space changes between patch and input.-c --context Interpret the patch as a context difference.-e --ed Interpret the patch as an ed script.-n --normal Interpret the patch as a normal difference.-u --unified Interpret the patch as a unified difference.-N --forward Ignore patches that appear to be reversed or already applied.-R --reverse Assume patches were created with old and new files swapped.-i PATCHFILE --inputPATCHFILE Read patch from PATCHFILE instead of stdin.Output options:-o FILE --outputFILE Output patched files to FILE.-r FILE --reject-fileFILE Output rejects to FILE.-D NAME --ifdefNAME Make merged if-then-else output using NAME.-m --merge Merge using conflict markers instead of creating reject files.-E --remove-empty-files Remove output files that are empty after patching.-Z --set-utc Set times of patched files, assuming diff uses UTC (GMT).-T --set-time Likewise, assuming local time.--quoting-styleWORD output file names using quoting style WORD.Valid WORDs are: literal, shell, shell-always, c, escape.Default is taken from QUOTING_STYLE env variable, or shell if unset.Backup and version control options:-b --backup Back up the original contents of each file.--backup-if-mismatch Back up if the patch does not match exactly.--no-backup-if-mismatch Back up mismatches only if otherwise requested.-V STYLE --version-controlSTYLE Use STYLE version control.STYLE is either simple, numbered, or existing.-B PREFIX --prefixPREFIX Prepend PREFIX to backup file names.-Y PREFIX --basename-prefixPREFIX Prepend PREFIX to backup file basenames.-z SUFFIX --suffixSUFFIX Append SUFFIX to backup file names.-g NUM --getNUM Get files from RCS etc. if positive; ask if negative.Miscellaneous options:-t --batch Ask no questions; skip bad-Prereq patches; assume reversed.-f --force Like -t, but ignore bad-Prereq patches, and assume unreversed.-s --quiet --silent Work silently unless an error occurs.--verbose Output extra information about the work being done.--dry-run Do not actually change any files; just print what would happen.--posix Conform to the POSIX standard.-d DIR --directoryDIR Change the working directory to DIR first.--reject-formatFORMAT Create context or unified rejects.--binary Read and write data in binary mode.--read-onlyBEHAVIOR How to handle read-only input files: ignore that theyare read-only, warn (default), or fail.-v --version Output version info.--help Output this help.Report bugs to bug-patchgnu.org.应用到打补丁上常用 patch -p1 xxx.diff
示例
如 test_patch.diff 文件内容如下
diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index cb3348f7ab..a0c35bafa4 100755
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.javab/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java-2602,6 2602,7 public class PhoneWindowManager implements WindowManagerPolicy {Overridepublic long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event,int policyFlags) {Log.d(TAG, test_patch);final boolean keyguardOn keyguardOn();final int keyCode event.getKeyCode();final int repeatCount event.getRepeatCount();把 test_patch.diff 放在和 frameworks/ 同级别的目录下
同级别目录
使用 patch -p1 test_patch.diff 命令提示
aaacompilerbbb:~/ccc/ANDROID$ patch -p1 test_patch.diff
patching file frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java说明打补丁完成使用 git diff 看是OK的。
子目录1
进入 frameworks/ 目录下使用 patch -p1 test_patch.diff 命令提示
aaacompilerbbb:~/ccc/ANDROID$/frameworks$ patch -p1 ../test_patch.diff
cant 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/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
|index cb3348f7ab..a0c35bafa4 100755
|--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
| b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
--------------------------
File to patch:输入 base/services/core/java/com/android/server/policy/PhoneWindowManager.java 即可解决
aaacompilerbbb:~/ccc/ANDROID$/frameworks$ patch -p1 ../test_patch.diff
cant 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/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
|index cb3348f7ab..a0c35bafa4 100755
|--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
| b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
--------------------------
File to patch: base/services/core/java/com/android/server/policy/PhoneWindowManager.java
patching file base/services/core/java/com/android/server/policy/PhoneWindowManager.java子目录2
子目录1 中因为实际路径和 patch 文件路径有差异需要手动输一下路径。
有没有不用输入路径的方法有的用 patch -p2 ../test_patch.diff 。
aaacompilerbbb:~/ccc/ANDROID$/frameworks$ patch -p2 ../test_patch.diff
patching file base/services/core/java/com/android/server/policy/PhoneWindowManager.javaaaacompilerbbb:~/ccc/ANDROID$/frameworks/base$ patch -p3 ../../test_patch.diff
patching file services/core/java/com/android/server/policy/PhoneWindowManager.java