AD

diff and patch 10 minutes Guide

Scenario 1: You are trying to compile a package from the code and found that someone had made a small modification on the code to compile on your system. Their way through the patch release their results, but you do not know how to use it. The answer is that you use a known patch (very appropriate) of the command-line tool to apply it to the original code.

Scenario 2: You download a source code package, spent about an hour to make some modifications it successfully on your system, compile. You want to share their results to other programmers, or to the package author. Now you need to create your own patch, you need the tool is diff.

This is a quick guide to diff and patch, by explaining their most common usage to help you solve the above problem. It tells you something enough you start to use immediately. After that, you can spare the time to learn to use diff and patch manpage The Ins and Outs. I always like to hear your questions and comments. Use contact form to get in touch with me.

With the patch command to apply patches

Application of a single file to patch into the directory where files and calls the patch command:

patch <foo.patch

These commands assume that patches are distributed in uniform format, this format to specify a patch applied to the document. If not, you can specify the file in the command line:

patch foo.txt <bar.patch

Apply the patch to the entire catalog (which may be more common) is also similar, but you must pay attention to set the p level. That is, the patch file, need to patch the file path on your computer, create a patch name with the computer may be different. p-level to tell patch command ignored pathname parts to identify the correct file. P-level is usually enough to 1, so you use:

patch-p1 <bar.patch

Before running this command, you should enter the source directory of the top directory. If the patch level 1 can not correctly identify any need to patch the file, check the patch file in the file name. If you see a file name:

/ Users / stephen / package / src / net / http.c

And you currently work in a contained net / http.c directory, use:

patch-p5 <bar.patch

In general, for most start deleting from the path of each path separator (slash characters) plus one, until the remaining part of the present in your working directory. End up with is the p-level.

To remove the patch, use-R parameters, such as:

patch-p5-R bar.patch

Create a patch using diff

Whether for a single file or the entire source directory, use the diff is very simple. Create a patch for a single file, use the following form:

diff-u original.c new.c> original.patch

Create a patch for the entire source tree, a copy of the source tree:

cp-R original new

In the directory new / in the necessary changes, and then create the patch with the following command:

diff-rupN original / new /> original.patch

This is the entry-diff and patch all the knowledge needed. For more information use:

man diff
man patch
标签: programmers, source code package, level 1, patches, command line tool, fi, foo, source directory, single file, uniform format, ins and outs, lt bar
分类: Development
时间: 2010-03-07

相关文章

  1. diff and patch ten minutes guide

    Scenario 1: You are trying to compile a package from the code and found that someone has made a small modifica ...
  2. diff and patch guide

    diff and patch are a tool in mathematical terms, diff is the difference between two sets of operations, patch ...
  3. 10 minutes to run every Windows app on your Ubuntu desktop,10分钟在你的UBUNTU中运行WINDOWS应用程序

    This simple guide will bring up the Windows start menu inside GNOME and allow you to run, use and install any ...
  4. FlyQuery-0.7 release, a free general information, development of a general inquiry, the list just 10 minutes

    A free general query FlyQuery, development of a general inquiry, the list just 10 minutes Download: http://hi. ...
  5. HDFS + MapReduce + Hive + HBase 10 minutes Getting Started (zhuan)

    HDFS + MapReduce + Hive + HBase 10 minutes quick start Yi Jian 2009-8-19 1. Introduction The purpose of this p ...
  6. FlyQuery-0.8 release, a free general inquiries, general inquiries, develop a list of just 10 minutes

    A free general query FlyQuery, develop a list of common queries 10 minutes Download: http://hi.baidu.com/flyqu ...
  7. 10 minutes to write your first program containing CRUD the Rails

    Text / Terrance This article for those interested in friend Ruby On Rails, step by step with you within 10 min ...
  8. Move your brain through, will be used: mysql database pv 10 minutes per visit to statistics?

    Move your brain through, will be used: How to access the database pv statistics per 10 minutes? mysql database ...
  9. Move your brain through, will be used: mysql database pv access to statistics per 10 minutes?

    Move your brain through, will be used: How to access the database pv statistics per 10 minutes? mysql database ...
  10. oracle 11g (10 minutes) solution to automatically disconnect from the database

    Recently, the debugger, the database is automatically disconnected frequently (every 10 minutes) of the anomal ...
  11. 10 Minutes Mail:临时邮箱服务,保障您的信息安全

    当你发现你的邮箱突然塞满了垃圾邮件的时候,也许你还不直到你的邮件资料是在哪个网站泄露的.如今的网站没有一家是安全的,yahoo.google这样的大公司都会泄露用户资料,普通网站就更不用说了,如果你担心受到垃圾邮件的干扰 ...
  12. 1 预热 : 理解 diff与patch

    先来了解2个基本概念: diff & patch 文档1:hello 应该杜绝文章中的错别子. 但是无论使用 *全拼,双拼 *还是五笔 是人就有可能犯错,软件更是如此. 犯了错,就要扣工资! 改正的成本可能会很高 ...
  13. Linux 命令 diff 与 patch

    单个文件打补丁 # 产生补丁 diff -uN from-file to-file > to-file.patch # 打补丁 patch -p0 < to-file.patch # 取消补丁 patch - ...
  14. 10 minutes to set up a powerful version control system SVN

    Requirements: LINUX established under the SVN server, automatically synchronized to the WEB directory, to achi ...
  15. web.py 10 minutes to create simple blog

    1, web.py Introduction web.py is a lightweight python web development framework, simple, efficient, low cost l ...
  16. FlyQuery-0.9 release, a free general inquiries, general inquiries, develop a list of just 10 minutes

    Download: http://hi.baidu.com/flyquery Online example: http://www.flyquery.com/ User Name: fq Password: fq Exa ...
  17. Review the code is pylint 7.67/10 minutes, I said a lot of pressure

    Ah various non-standard: Hundreds of tips. . . List of the most amateur of the following questions: R: 123: ge ...
  18. Review the code is pylint 7.67/10 minutes, I said that pressure

    Ah various non-standard: Hundreds of tips. . . List of the most amateur of the following questions: R: 123: ge ...
  19. ubuntu下diff patch打补丁

    首先把个人总结写出来,然后你们有空的话就继续往下看: a:最原始文件 b:修改过后的文件 diff -uN b a > c.patch 补丁出来了,在当前文件夹下,一定要看清楚文件的顺序 patch -p0 < ...