What is the format of a patch file?

前端 未结 4 899
南旧
南旧 2020-12-08 06:11

What does the following mean ?

diff -rBNu src.orig/java/org/apache/nutch/analysis/NutchAnalysisConstants.java src/java/org/apache/nutch/analysis/NutchAnalysi         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 06:27

    The -u option you used specifies the unified format. In that format the first two lines is a header: --- is the original file, +++ is the new file, and the timestamps.

    @@ block headers

    That is then followed by chunks (change hunks) that starts with the @@ -R,r +R,r @@ syntax.

    Those are two ranges, the one with the - is the range for the chunk in the original file, and the one with the + the range in the new file. The R designates the line number where the diff operation is started.

    The numbers after the comma are the number of affected lines in each file.

    • Every time you remove a line, the +r number will be smaller than -r.
    • Every time you add a line, the +r number will be bigger than -r
    • Changing a line will add 0 to the +r number. (same scope of lines)

    Chunks of code lines

    Within these chunks lines are identified as additions or deletions - means delete, + means addition. Lines that did not change in that chunk will have neither + or - front of it.

    In your example it means there are two chunks, or sections, that changed between the two files and the lines with + in it are the new ones added, nothing was deleted.

    You can find much more information about the syntax by doing a google search for unified diff.

提交回复
热议问题