1This is diffutils.info-t, produced by makeinfo version 4.13 from 2diffutils.texi. 3 4This manual is for GNU Diffutils (version 3.3, 23 March 2013), and 5documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for 6showing the differences between files and the GNU `patch' command for 7using their output to update files. 8 9 Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2013 Free 10Software Foundation, Inc. 11 12 Permission is granted to copy, distribute and/or modify this 13 document under the terms of the GNU Free Documentation License, 14 Version 1.3 or any later version published by the Free Software 15 Foundation; with no Invariant Sections, no Front-Cover Texts, and 16 no Back-Cover Texts. A copy of the license is included in the 17 section entitled "GNU Free Documentation License." 18 19INFO-DIR-SECTION Individual utilities 20START-INFO-DIR-ENTRY 21* cmp: (diffutils)Invoking cmp. Compare 2 files byte by byte. 22* diff: (diffutils)Invoking diff. Compare 2 files line by line. 23* diff3: (diffutils)Invoking diff3. Compare 3 files line by line. 24* patch: (diffutils)Invoking patch. Apply a patch to a file. 25* sdiff: (diffutils)Invoking sdiff. Merge 2 files side-by-side. 26END-INFO-DIR-ENTRY 27 28INFO-DIR-SECTION Text creation and manipulation 29START-INFO-DIR-ENTRY 30* Diffutils: (diffutils). Comparing and merging files. 31END-INFO-DIR-ENTRY 32 33 34File: diffutils.info-t, Node: Top, Next: Overview, Up: (dir) 35 36Comparing and Merging Files 37*************************** 38 39This manual is for GNU Diffutils (version 3.3, 23 March 2013), and 40documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for 41showing the differences between files and the GNU `patch' command for 42using their output to update files. 43 44 Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2013 Free 45Software Foundation, Inc. 46 47 Permission is granted to copy, distribute and/or modify this 48 document under the terms of the GNU Free Documentation License, 49 Version 1.3 or any later version published by the Free Software 50 Foundation; with no Invariant Sections, no Front-Cover Texts, and 51 no Back-Cover Texts. A copy of the license is included in the 52 section entitled "GNU Free Documentation License." 53 54* Menu: 55 56* Overview:: Preliminary information. 57* Comparison:: What file comparison means. 58 59* Output Formats:: Formats for two-way difference reports. 60* Incomplete Lines:: Lines that lack trailing newlines. 61* Comparing Directories:: Comparing files and directories. 62* Adjusting Output:: Making `diff' output prettier. 63* diff Performance:: Making `diff' smarter or faster. 64 65* Comparing Three Files:: Formats for three-way difference reports. 66* diff3 Merging:: Merging from a common ancestor. 67 68* Interactive Merging:: Interactive merging with `sdiff'. 69 70* Merging with patch:: Using `patch' to change old files into new ones. 71* Making Patches:: Tips for making and using patch distributions. 72 73* Invoking cmp:: Compare two files byte by byte. 74* Invoking diff:: Compare two files line by line. 75* Invoking diff3:: Compare three files line by line. 76* Invoking patch:: Apply a diff file to an original. 77* Invoking sdiff:: Side-by-side merge of file differences. 78 79* Standards conformance:: Conformance to the POSIX standard. 80* Projects:: If you've found a bug or other shortcoming. 81 82* Copying This Manual:: How to make copies of this manual. 83* Translations:: Available translations of this manual. 84* Index:: Index. 85 86 87File: diffutils.info-t, Node: Overview, Next: Comparison, Prev: Top, Up: Top 88 89Overview 90******** 91 92Computer users often find occasion to ask how two files differ. Perhaps 93one file is a newer version of the other file. Or maybe the two files 94started out as identical copies but were changed by different people. 95 96 You can use the `diff' command to show differences between two 97files, or each corresponding file in two directories. `diff' outputs 98differences between files line by line in any of several formats, 99selectable by command line options. This set of differences is often 100called a "diff" or "patch". For files that are identical, `diff' 101normally produces no output; for binary (non-text) files, `diff' 102normally reports only that they are different. 103 104 You can use the `cmp' command to show the byte and line numbers 105where two files differ. `cmp' can also show all the bytes that differ 106between the two files, side by side. A way to compare two files 107character by character is the Emacs command `M-x compare-windows'. 108*Note Other Window: (emacs)Other Window, for more information on that 109command. 110 111 You can use the `diff3' command to show differences among three 112files. When two people have made independent changes to a common 113original, `diff3' can report the differences between the original and 114the two changed versions, and can produce a merged file that contains 115both persons' changes together with warnings about conflicts. 116 117 You can use the `sdiff' command to merge two files interactively. 118 119 You can use the set of differences produced by `diff' to distribute 120updates to text files (such as program source code) to other people. 121This method is especially useful when the differences are small compared 122to the complete files. Given `diff' output, you can use the `patch' 123program to update, or "patch", a copy of the file. If you think of 124`diff' as subtracting one file from another to produce their 125difference, you can think of `patch' as adding the difference to one 126file to reproduce the other. 127 128 This manual first concentrates on making diffs, and later shows how 129to use diffs to update files. 130 131 GNU `diff' was written by Paul Eggert, Mike Haertel, David Hayes, 132Richard Stallman, and Len Tower. Wayne Davison designed and 133implemented the unified output format. The basic algorithm is described 134by Eugene W. Myers in "An O(ND) Difference Algorithm and its 135Variations", `Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A 136File Comparison Program", Webb Miller and Eugene W. Myers, 137`Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040. 138The algorithm was independently discovered as described by E. Ukkonen in 139"Algorithms for Approximate String Matching", `Information and Control' 140Vol. 64, 1985, pp. 100-118. Unless the `--minimal' option is used, 141`diff' uses a heuristic by Paul Eggert that limits the cost to O(N^1.5 142log N) at the price of producing suboptimal output for large inputs 143with many differences. Related algorithms are surveyed by Alfred V. 144Aho in section 6.3 of "Algorithms for Finding Patterns in Strings", 145`Handbook of Theoretical Computer Science' (Jan Van Leeuwen, ed.), Vol. 146A, `Algorithms and Complexity', Elsevier/MIT Press, 1990, pp. 255-300. 147 148 GNU `diff3' was written by Randy Smith. GNU `sdiff' was written by 149Thomas Lord. GNU `cmp' was written by Torbjo"rn Granlund and David 150MacKenzie. 151 152 GNU `patch' was written mainly by Larry Wall and Paul Eggert; 153several GNU enhancements were contributed by Wayne Davison and David 154MacKenzie. Parts of this manual are adapted from a manual page written 155by Larry Wall, with his permission. 156 157 158File: diffutils.info-t, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top 159 1601 What Comparison Means 161*********************** 162 163There are several ways to think about the differences between two files. 164One way to think of the differences is as a series of lines that were 165deleted from, inserted in, or changed in one file to produce the other 166file. `diff' compares two files line by line, finds groups of lines 167that differ, and reports each group of differing lines. It can report 168the differing lines in several formats, which have different purposes. 169 170 GNU `diff' can show whether files are different without detailing 171the differences. It also provides ways to suppress certain kinds of 172differences that are not important to you. Most commonly, such 173differences are changes in the amount of white space between words or 174lines. `diff' also provides ways to suppress differences in alphabetic 175case or in lines that match a regular expression that you provide. 176These options can accumulate; for example, you can ignore changes in 177both white space and alphabetic case. 178 179 Another way to think of the differences between two files is as a 180sequence of pairs of bytes that can be either identical or different. 181`cmp' reports the differences between two files byte by byte, instead 182of line by line. As a result, it is often more useful than `diff' for 183comparing binary files. For text files, `cmp' is useful mainly when 184you want to know only whether two files are identical, or whether one 185file is a prefix of the other. 186 187 To illustrate the effect that considering changes byte by byte can 188have compared with considering them line by line, think of what happens 189if a single newline character is added to the beginning of a file. If 190that file is then compared with an otherwise identical file that lacks 191the newline at the beginning, `diff' will report that a blank line has 192been added to the file, while `cmp' will report that almost every byte 193of the two files differs. 194 195 `diff3' normally compares three input files line by line, finds 196groups of lines that differ, and reports each group of differing lines. 197Its output is designed to make it easy to inspect two different sets of 198changes to the same file. 199 200* Menu: 201 202* Hunks:: Groups of differing lines. 203* White Space:: Suppressing differences in white space. 204* Blank Lines:: Suppressing differences whose lines are all blank. 205* Specified Lines:: Suppressing differences whose lines all match a pattern. 206* Case Folding:: Suppressing differences in alphabetic case. 207* Brief:: Summarizing which files are different. 208* Binary:: Comparing binary files or forcing text comparisons. 209 210 211File: diffutils.info-t, Node: Hunks, Next: White Space, Up: Comparison 212 2131.1 Hunks 214========= 215 216When comparing two files, `diff' finds sequences of lines common to 217both files, interspersed with groups of differing lines called "hunks". 218Comparing two identical files yields one sequence of common lines and 219no hunks, because no lines differ. Comparing two entirely different 220files yields no common lines and one large hunk that contains all lines 221of both files. In general, there are many ways to match up lines 222between two given files. `diff' tries to minimize the total hunk size 223by finding large sequences of common lines interspersed with small 224hunks of differing lines. 225 226 For example, suppose the file `F' contains the three lines `a', `b', 227`c', and the file `G' contains the same three lines in reverse order 228`c', `b', `a'. If `diff' finds the line `c' as common, then the command 229`diff F G' produces this output: 230 231 1,2d0 232 < a 233 < b 234 3a2,3 235 > b 236 > a 237 238But if `diff' notices the common line `b' instead, it produces this 239output: 240 241 1c1 242 < a 243 --- 244 > c 245 3c3 246 < c 247 --- 248 > a 249 250It is also possible to find `a' as the common line. `diff' does not 251always find an optimal matching between the files; it takes shortcuts 252to run faster. But its output is usually close to the shortest 253possible. You can adjust this tradeoff with the `--minimal' (`-d') 254option (*note diff Performance::). 255 256 257File: diffutils.info-t, Node: White Space, Next: Blank Lines, Prev: Hunks, Up: Comparison 258 2591.2 Suppressing Differences in Blank and Tab Spacing 260==================================================== 261 262The `--ignore-tab-expansion' (`-E') option ignores the distinction 263between tabs and spaces on input. A tab is considered to be equivalent 264to the number of spaces to the next tab stop (*note Tabs::). 265 266 The `--ignore-trailing-space' (`-Z') option ignores white space at 267line end. 268 269 The `--ignore-space-change' (`-b') option is stronger than `-E' and 270`-Z' combined. It ignores white space at line end, and considers all 271other sequences of one or more white space characters within a line to 272be equivalent. With this option, `diff' considers the following two 273lines to be equivalent, where `$' denotes the line end: 274 275 Here lyeth muche rychnesse in lytell space. -- John Heywood$ 276 Here lyeth muche rychnesse in lytell space. -- John Heywood $ 277 278 The `--ignore-all-space' (`-w') option is stronger still. It 279ignores differences even if one line has white space where the other 280line has none. "White space" characters include tab, vertical tab, 281form feed, carriage return, and space; some locales may define 282additional characters to be white space. With this option, `diff' 283considers the following two lines to be equivalent, where `$' denotes 284the line end and `^M' denotes a carriage return: 285 286 Here lyeth muche rychnesse in lytell space.-- John Heywood$ 287 He relyeth much erychnes seinly tells pace. --John Heywood ^M$ 288 289 For many other programs newline is also a white space character, but 290`diff' is a line-oriented program and a newline character always ends a 291line. Hence the `-w' or `--ignore-all-space' option does not ignore 292newline-related changes; it ignores only other white space changes. 293 294 295File: diffutils.info-t, Node: Blank Lines, Next: Specified Lines, Prev: White Space, Up: Comparison 296 2971.3 Suppressing Differences Whose Lines Are All Blank 298===================================================== 299 300The `--ignore-blank-lines' (`-B') option ignores changes that consist 301entirely of blank lines. With this option, for example, a file 302containing 303 1. A point is that which has no part. 304 305 2. A line is breadthless length. 306 -- Euclid, The Elements, I 307 is considered identical to a file containing 308 1. A point is that which has no part. 309 2. A line is breadthless length. 310 311 312 -- Euclid, The Elements, I 313 314 Normally this option affects only lines that are completely empty, 315but if you also specify an option that ignores trailing spaces, lines 316are also affected if they look empty but contain white space. In other 317words, `-B' is equivalent to `-I '^$'' by default, but it is equivalent 318to `-I '^[[:space:]]*$'' if `-b', `-w' or `-Z' is also specified. 319 320 321File: diffutils.info-t, Node: Specified Lines, Next: Case Folding, Prev: Blank Lines, Up: Comparison 322 3231.4 Suppressing Differences Whose Lines All Match a Regular Expression 324====================================================================== 325 326To ignore insertions and deletions of lines that match a `grep'-style 327regular expression, use the `--ignore-matching-lines=REGEXP' (`-I 328REGEXP') option. You should escape regular expressions that contain 329shell metacharacters to prevent the shell from expanding them. For 330example, `diff -I '^[[:digit:]]'' ignores all changes to lines 331beginning with a digit. 332 333 However, `-I' only ignores the insertion or deletion of lines that 334contain the regular expression if every changed line in the hunk--every 335insertion and every deletion--matches the regular expression. In other 336words, for each nonignorable change, `diff' prints the complete set of 337changes in its vicinity, including the ignorable ones. 338 339 You can specify more than one regular expression for lines to ignore 340by using more than one `-I' option. `diff' tries to match each line 341against each regular expression. 342 343 344File: diffutils.info-t, Node: Case Folding, Next: Brief, Prev: Specified Lines, Up: Comparison 345 3461.5 Suppressing Case Differences 347================================ 348 349GNU `diff' can treat lower case letters as equivalent to their upper 350case counterparts, so that, for example, it considers `Funky Stuff', 351`funky STUFF', and `fUNKy stuFf' to all be the same. To request this, 352use the `-i' or `--ignore-case' option. 353 354 355File: diffutils.info-t, Node: Brief, Next: Binary, Prev: Case Folding, Up: Comparison 356 3571.6 Summarizing Which Files Differ 358================================== 359 360When you only want to find out whether files are different, and you 361don't care what the differences are, you can use the summary output 362format. In this format, instead of showing the differences between the 363files, `diff' simply reports whether files differ. The `--brief' 364(`-q') option selects this output format. 365 366 This format is especially useful when comparing the contents of two 367directories. It is also much faster than doing the normal line by line 368comparisons, because `diff' can stop analyzing the files as soon as it 369knows that there are any differences. 370 371 You can also get a brief indication of whether two files differ by 372using `cmp'. For files that are identical, `cmp' produces no output. 373When the files differ, by default, `cmp' outputs the byte and line 374number where the first difference occurs, or reports that one file is a 375prefix of the other. You can use the `-s', `--quiet', or `--silent' 376option to suppress that information, so that `cmp' produces no output 377and reports whether the files differ using only its exit status (*note 378Invoking cmp::). 379 380 Unlike `diff', `cmp' cannot compare directories; it can only compare 381two files. 382 383 384File: diffutils.info-t, Node: Binary, Prev: Brief, Up: Comparison 385 3861.7 Binary Files and Forcing Text Comparisons 387============================================= 388 389If `diff' thinks that either of the two files it is comparing is binary 390(a non-text file), it normally treats that pair of files much as if the 391summary output format had been selected (*note Brief::), and reports 392only that the binary files are different. This is because line by line 393comparisons are usually not meaningful for binary files. 394 395 `diff' determines whether a file is text or binary by checking the 396first few bytes in the file; the exact number of bytes is system 397dependent, but it is typically several thousand. If every byte in that 398part of the file is non-null, `diff' considers the file to be text; 399otherwise it considers the file to be binary. 400 401 Sometimes you might want to force `diff' to consider files to be 402text. For example, you might be comparing text files that contain null 403characters; `diff' would erroneously decide that those are non-text 404files. Or you might be comparing documents that are in a format used 405by a word processing system that uses null characters to indicate 406special formatting. You can force `diff' to consider all files to be 407text files, and compare them line by line, by using the `--text' (`-a') 408option. If the files you compare using this option do not in fact 409contain text, they will probably contain few newline characters, and 410the `diff' output will consist of hunks showing differences between 411long lines of whatever characters the files contain. 412 413 You can also force `diff' to report only whether files differ (but 414not how). Use the `--brief' (`-q') option for this. 415 416 Normally, differing binary files count as trouble because the 417resulting `diff' output does not capture all the differences. This 418trouble causes `diff' to exit with status 2. However, this trouble 419cannot occur with the `--text' (`-a') option, or with the `--brief' 420(`-q') option, as these options both cause `diff' to generate a form of 421output that represents differences as requested. 422 423 In operating systems that distinguish between text and binary files, 424`diff' normally reads and writes all data as text. Use the `--binary' 425option to force `diff' to read and write binary data instead. This 426option has no effect on a POSIX-compliant system like GNU or 427traditional Unix. However, many personal computer operating systems 428represent the end of a line with a carriage return followed by a 429newline. On such systems, `diff' normally ignores these carriage 430returns on input and generates them at the end of each output line, but 431with the `--binary' option `diff' treats each carriage return as just 432another input character, and does not generate a carriage return at the 433end of each output line. This can be useful when dealing with non-text 434files that are meant to be interchanged with POSIX-compliant systems. 435 436 The `--strip-trailing-cr' causes `diff' to treat input lines that 437end in carriage return followed by newline as if they end in plain 438newline. This can be useful when comparing text that is imperfectly 439imported from many personal computer operating systems. This option 440affects how lines are read, which in turn affects how they are compared 441and output. 442 443 If you want to compare two files byte by byte, you can use the `cmp' 444program with the `--verbose' (`-l') option to show the values of each 445differing byte in the two files. With GNU `cmp', you can also use the 446`-b' or `--print-bytes' option to show the ASCII representation of 447those bytes. *Note Invoking cmp::, for more information. 448 449 If `diff3' thinks that any of the files it is comparing is binary (a 450non-text file), it normally reports an error, because such comparisons 451are usually not useful. `diff3' uses the same test as `diff' to decide 452whether a file is binary. As with `diff', if the input files contain a 453few non-text bytes but otherwise are like text files, you can force 454`diff3' to consider all files to be text files and compare them line by 455line by using the `-a' or `--text' option. 456 457 458File: diffutils.info-t, Node: Output Formats, Next: Incomplete Lines, Prev: Comparison, Up: Top 459 4602 `diff' Output Formats 461*********************** 462 463`diff' has several mutually exclusive options for output format. The 464following sections describe each format, illustrating how `diff' 465reports the differences between two sample input files. 466 467* Menu: 468 469* Sample diff Input:: Sample `diff' input files for examples. 470* Context:: Showing differences with the surrounding text. 471* Side by Side:: Showing differences in two columns. 472* Normal:: Showing differences without surrounding text. 473* Scripts:: Generating scripts for other programs. 474* If-then-else:: Merging files with if-then-else. 475 476 477File: diffutils.info-t, Node: Sample diff Input, Next: Context, Up: Output Formats 478 4792.1 Two Sample Input Files 480========================== 481 482Here are two sample files that we will use in numerous examples to 483illustrate the output of `diff' and how various options can change it. 484 485 This is the file `lao': 486 487 The Way that can be told of is not the eternal Way; 488 The name that can be named is not the eternal name. 489 The Nameless is the origin of Heaven and Earth; 490 The Named is the mother of all things. 491 Therefore let there always be non-being, 492 so we may see their subtlety, 493 And let there always be being, 494 so we may see their outcome. 495 The two are the same, 496 But after they are produced, 497 they have different names. 498 499 This is the file `tzu': 500 501 The Nameless is the origin of Heaven and Earth; 502 The named is the mother of all things. 503 504 Therefore let there always be non-being, 505 so we may see their subtlety, 506 And let there always be being, 507 so we may see their outcome. 508 The two are the same, 509 But after they are produced, 510 they have different names. 511 They both may be called deep and profound. 512 Deeper and more profound, 513 The door of all subtleties! 514 515 In this example, the first hunk contains just the first two lines of 516`lao', the second hunk contains the fourth line of `lao' opposing the 517second and third lines of `tzu', and the last hunk contains just the 518last three lines of `tzu'. 519 520 521File: diffutils.info-t, Node: Context, Next: Side by Side, Prev: Sample diff Input, Up: Output Formats 522 5232.2 Showing Differences in Their Context 524======================================== 525 526Usually, when you are looking at the differences between files, you will 527also want to see the parts of the files near the lines that differ, to 528help you understand exactly what has changed. These nearby parts of the 529files are called the "context". 530 531 GNU `diff' provides two output formats that show context around the 532differing lines: "context format" and "unified format". It can 533optionally show in which function or section of the file the differing 534lines are found. 535 536 If you are distributing new versions of files to other people in the 537form of `diff' output, you should use one of the output formats that 538show context so that they can apply the diffs even if they have made 539small changes of their own to the files. `patch' can apply the diffs 540in this case by searching in the files for the lines of context around 541the differing lines; if those lines are actually a few lines away from 542where the diff says they are, `patch' can adjust the line numbers 543accordingly and still apply the diff correctly. *Note Imperfect::, for 544more information on using `patch' to apply imperfect diffs. 545 546* Menu: 547 548* Context Format:: An output format that shows surrounding lines. 549* Unified Format:: A more compact output format that shows context. 550* Sections:: Showing which sections of the files differences are in. 551* Alternate Names:: Showing alternate file names in context headers. 552 553 554File: diffutils.info-t, Node: Context Format, Next: Unified Format, Up: Context 555 5562.2.1 Context Format 557-------------------- 558 559The context output format shows several lines of context around the 560lines that differ. It is the standard format for distributing updates 561to source code. 562 563 To select this output format, use the `--context[=LINES]' (`-C 564LINES') or `-c' option. The argument LINES that some of these options 565take is the number of lines of context to show. If you do not specify 566LINES, it defaults to three. For proper operation, `patch' typically 567needs at least two lines of context. 568 569* Menu: 570 571* Example Context:: Sample output in context format. 572* Less Context:: Another sample with less context. 573* Detailed Context:: A detailed description of the context output format. 574 575 576File: diffutils.info-t, Node: Example Context, Next: Less Context, Up: Context Format 577 5782.2.1.1 An Example of Context Format 579.................................... 580 581Here is the output of `diff -c lao tzu' (*note Sample diff Input::, for 582the complete contents of the two files). Notice that up to three lines 583that are not different are shown around each line that is different; 584they are the context lines. Also notice that the first two hunks have 585run together, because their contents overlap. 586 587 *** lao 2002-02-21 23:30:39.942229878 -0800 588 --- tzu 2002-02-21 23:30:50.442260588 -0800 589 *************** 590 *** 1,7 **** 591 - The Way that can be told of is not the eternal Way; 592 - The name that can be named is not the eternal name. 593 The Nameless is the origin of Heaven and Earth; 594 ! The Named is the mother of all things. 595 Therefore let there always be non-being, 596 so we may see their subtlety, 597 And let there always be being, 598 --- 1,6 ---- 599 The Nameless is the origin of Heaven and Earth; 600 ! The named is the mother of all things. 601 ! 602 Therefore let there always be non-being, 603 so we may see their subtlety, 604 And let there always be being, 605 *************** 606 *** 9,11 **** 607 --- 8,13 ---- 608 The two are the same, 609 But after they are produced, 610 they have different names. 611 + They both may be called deep and profound. 612 + Deeper and more profound, 613 + The door of all subtleties! 614 615 616File: diffutils.info-t, Node: Less Context, Next: Detailed Context, Prev: Example Context, Up: Context Format 617 6182.2.1.2 An Example of Context Format with Less Context 619...................................................... 620 621Here is the output of `diff -C 1 lao tzu' (*note Sample diff Input::, 622for the complete contents of the two files). Notice that at most one 623context line is reported here. 624 625 *** lao 2002-02-21 23:30:39.942229878 -0800 626 --- tzu 2002-02-21 23:30:50.442260588 -0800 627 *************** 628 *** 1,5 **** 629 - The Way that can be told of is not the eternal Way; 630 - The name that can be named is not the eternal name. 631 The Nameless is the origin of Heaven and Earth; 632 ! The Named is the mother of all things. 633 Therefore let there always be non-being, 634 --- 1,4 ---- 635 The Nameless is the origin of Heaven and Earth; 636 ! The named is the mother of all things. 637 ! 638 Therefore let there always be non-being, 639 *************** 640 *** 11 **** 641 --- 10,13 ---- 642 they have different names. 643 + They both may be called deep and profound. 644 + Deeper and more profound, 645 + The door of all subtleties! 646 647 648File: diffutils.info-t, Node: Detailed Context, Prev: Less Context, Up: Context Format 649 6502.2.1.3 Detailed Description of Context Format 651.............................................. 652 653The context output format starts with a two-line header, which looks 654like this: 655 656 *** FROM-FILE FROM-FILE-MODIFICATION-TIME 657 --- TO-FILE TO-FILE-MODIFICATION TIME 658 659The time stamp normally looks like `2002-02-21 23:30:39.942229878 660-0800' to indicate the date, time with fractional seconds, and time 661zone in Internet RFC 2822 format 662(ftp://ftp.isi.edu/in-notes/rfc2822.txt). (The fractional seconds are 663omitted on hosts that do not support fractional time stamps.) However, 664a traditional time stamp like `Thu Feb 21 23:30:39 2002' is used if the 665`LC_TIME' locale category is either `C' or `POSIX'. 666 667 You can change the header's content with the `--label=LABEL' option; 668see *note Alternate Names::. 669 670 Next come one or more hunks of differences; each hunk shows one area 671where the files differ. Context format hunks look like this: 672 673 *************** 674 *** FROM-FILE-LINE-NUMBERS **** 675 FROM-FILE-LINE 676 FROM-FILE-LINE... 677 --- TO-FILE-LINE-NUMBERS ---- 678 TO-FILE-LINE 679 TO-FILE-LINE... 680 681 If a hunk contains two or more lines, its line numbers look like 682`START,END'. Otherwise only its end line number appears. An empty 683hunk is considered to end at the line that precedes the hunk. 684 685 The lines of context around the lines that differ start with two 686space characters. The lines that differ between the two files start 687with one of the following indicator characters, followed by a space 688character: 689 690`!' 691 A line that is part of a group of one or more lines that changed 692 between the two files. There is a corresponding group of lines 693 marked with `!' in the part of this hunk for the other file. 694 695`+' 696 An "inserted" line in the second file that corresponds to nothing 697 in the first file. 698 699`-' 700 A "deleted" line in the first file that corresponds to nothing in 701 the second file. 702 703 If all of the changes in a hunk are insertions, the lines of 704FROM-FILE are omitted. If all of the changes are deletions, the lines 705of TO-FILE are omitted. 706 707 708File: diffutils.info-t, Node: Unified Format, Next: Sections, Prev: Context Format, Up: Context 709 7102.2.2 Unified Format 711-------------------- 712 713The unified output format is a variation on the context format that is 714more compact because it omits redundant context lines. To select this 715output format, use the `--unified[=LINES]' (`-U LINES'), or `-u' option. 716The argument LINES is the number of lines of context to show. When it 717is not given, it defaults to three. 718 719 At present, only GNU `diff' can produce this format and only GNU 720`patch' can automatically apply diffs in this format. For proper 721operation, `patch' typically needs at least three lines of context. 722 723* Menu: 724 725* Example Unified:: Sample output in unified format. 726* Detailed Unified:: A detailed description of unified format. 727 728 729File: diffutils.info-t, Node: Example Unified, Next: Detailed Unified, Up: Unified Format 730 7312.2.2.1 An Example of Unified Format 732.................................... 733 734Here is the output of the command `diff -u lao tzu' (*note Sample diff 735Input::, for the complete contents of the two files): 736 737 --- lao 2002-02-21 23:30:39.942229878 -0800 738 +++ tzu 2002-02-21 23:30:50.442260588 -0800 739 @@ -1,7 +1,6 @@ 740 -The Way that can be told of is not the eternal Way; 741 -The name that can be named is not the eternal name. 742 The Nameless is the origin of Heaven and Earth; 743 -The Named is the mother of all things. 744 +The named is the mother of all things. 745 + 746 Therefore let there always be non-being, 747 so we may see their subtlety, 748 And let there always be being, 749 @@ -9,3 +8,6 @@ 750 The two are the same, 751 But after they are produced, 752 they have different names. 753 +They both may be called deep and profound. 754 +Deeper and more profound, 755 +The door of all subtleties! 756 757 758File: diffutils.info-t, Node: Detailed Unified, Prev: Example Unified, Up: Unified Format 759 7602.2.2.2 Detailed Description of Unified Format 761.............................................. 762 763The unified output format starts with a two-line header, which looks 764like this: 765 766 --- FROM-FILE FROM-FILE-MODIFICATION-TIME 767 +++ TO-FILE TO-FILE-MODIFICATION-TIME 768 769The time stamp looks like `2002-02-21 23:30:39.942229878 -0800' to 770indicate the date, time with fractional seconds, and time zone. The 771fractional seconds are omitted on hosts that do not support fractional 772time stamps. 773 774 You can change the header's content with the `--label=LABEL' option. 775*Note Alternate Names::. 776 777 Next come one or more hunks of differences; each hunk shows one area 778where the files differ. Unified format hunks look like this: 779 780 @@ FROM-FILE-LINE-NUMBERS TO-FILE-LINE-NUMBERS @@ 781 LINE-FROM-EITHER-FILE 782 LINE-FROM-EITHER-FILE... 783 784 If a hunk contains just one line, only its start line number appears. 785Otherwise its line numbers look like `START,COUNT'. An empty hunk is 786considered to start at the line that follows the hunk. 787 788 If a hunk and its context contain two or more lines, its line 789numbers look like `START,COUNT'. Otherwise only its end line number 790appears. An empty hunk is considered to end at the line that precedes 791the hunk. 792 793 The lines common to both files begin with a space character. The 794lines that actually differ between the two files have one of the 795following indicator characters in the left print column: 796 797`+' 798 A line was added here to the first file. 799 800`-' 801 A line was removed here from the first file. 802 803 804File: diffutils.info-t, Node: Sections, Next: Alternate Names, Prev: Unified Format, Up: Context 805 8062.2.3 Showing Which Sections Differences Are in 807----------------------------------------------- 808 809Sometimes you might want to know which part of the files each change 810falls in. If the files are source code, this could mean which function 811was changed. If the files are documents, it could mean which chapter 812or appendix was changed. GNU `diff' can show this by displaying the 813nearest section heading line that precedes the differing lines. Which 814lines are "section headings" is determined by a regular expression. 815 816* Menu: 817 818* Specified Headings:: Showing headings that match regular expressions. 819* C Function Headings:: Showing headings of C functions. 820 821 822File: diffutils.info-t, Node: Specified Headings, Next: C Function Headings, Up: Sections 823 8242.2.3.1 Showing Lines That Match Regular Expressions 825.................................................... 826 827To show in which sections differences occur for files that are not 828source code for C or similar languages, use the 829`--show-function-line=REGEXP' (`-F REGEXP') option. `diff' considers 830lines that match the `grep'-style regular expression REGEXP to be the 831beginning of a section of the file. Here are suggested regular 832expressions for some common languages: 833 834`^[[:alpha:]$_]' 835 C, C++, Prolog 836 837`^(' 838 Lisp 839 840`^@node' 841 Texinfo 842 843 This option does not automatically select an output format; in order 844to use it, you must select the context format (*note Context Format::) 845or unified format (*note Unified Format::). In other output formats it 846has no effect. 847 848 The `--show-function-line' (`-F') option finds the nearest unchanged 849line that precedes each hunk of differences and matches the given 850regular expression. Then it adds that line to the end of the line of 851asterisks in the context format, or to the `@@' line in unified format. 852If no matching line exists, this option leaves the output for that hunk 853unchanged. If that line is more than 40 characters long, it outputs 854only the first 40 characters. You can specify more than one regular 855expression for such lines; `diff' tries to match each line against each 856regular expression, starting with the last one given. This means that 857you can use `-p' and `-F' together, if you wish. 858 859 860File: diffutils.info-t, Node: C Function Headings, Prev: Specified Headings, Up: Sections 861 8622.2.3.2 Showing C Function Headings 863................................... 864 865To show in which functions differences occur for C and similar 866languages, you can use the `--show-c-function' (`-p') option. This 867option automatically defaults to the context output format (*note 868Context Format::), with the default number of lines of context. You 869can override that number with `-C LINES' elsewhere in the command line. 870You can override both the format and the number with `-U LINES' 871elsewhere in the command line. 872 873 The `--show-c-function' (`-p') option is equivalent to `-F 874'^[[:alpha:]$_]'' if the unified format is specified, otherwise `-c -F 875'^[[:alpha:]$_]'' (*note Specified Headings::). GNU `diff' provides 876this option for the sake of convenience. 877 878 879File: diffutils.info-t, Node: Alternate Names, Prev: Sections, Up: Context 880 8812.2.4 Showing Alternate File Names 882---------------------------------- 883 884If you are comparing two files that have meaningless or uninformative 885names, you might want `diff' to show alternate names in the header of 886the context and unified output formats. To do this, use the 887`--label=LABEL' option. The first time you give this option, its 888argument replaces the name and date of the first file in the header; 889the second time, its argument replaces the name and date of the second 890file. If you give this option more than twice, `diff' reports an 891error. The `--label' option does not affect the file names in the `pr' 892header when the `-l' or `--paginate' option is used (*note 893Pagination::). 894 895 Here are the first two lines of the output from `diff -C 2 896--label=original --label=modified lao tzu': 897 898 *** original 899 --- modified 900 901 902File: diffutils.info-t, Node: Side by Side, Next: Normal, Prev: Context, Up: Output Formats 903 9042.3 Showing Differences Side by Side 905==================================== 906 907`diff' can produce a side by side difference listing of two files. The 908files are listed in two columns with a gutter between them. The gutter 909contains one of the following markers: 910 911white space 912 The corresponding lines are in common. That is, either the lines 913 are identical, or the difference is ignored because of one of the 914 `--ignore' options (*note White Space::). 915 916`|' 917 The corresponding lines differ, and they are either both complete 918 or both incomplete. 919 920`<' 921 The files differ and only the first file contains the line. 922 923`>' 924 The files differ and only the second file contains the line. 925 926`(' 927 Only the first file contains the line, but the difference is 928 ignored. 929 930`)' 931 Only the second file contains the line, but the difference is 932 ignored. 933 934`\' 935 The corresponding lines differ, and only the first line is 936 incomplete. 937 938`/' 939 The corresponding lines differ, and only the second line is 940 incomplete. 941 942 Normally, an output line is incomplete if and only if the lines that 943it contains are incomplete. *Note Incomplete Lines::. However, when an 944output line represents two differing lines, one might be incomplete 945while the other is not. In this case, the output line is complete, but 946its the gutter is marked `\' if the first line is incomplete, `/' if 947the second line is. 948 949 Side by side format is sometimes easiest to read, but it has 950limitations. It generates much wider output than usual, and truncates 951lines that are too long to fit. Also, it relies on lining up output 952more heavily than usual, so its output looks particularly bad if you 953use varying width fonts, nonstandard tab stops, or nonprinting 954characters. 955 956 You can use the `sdiff' command to interactively merge side by side 957differences. *Note Interactive Merging::, for more information on 958merging files. 959 960* Menu: 961 962* Side by Side Format:: Controlling side by side output format. 963* Example Side by Side:: Sample side by side output. 964 965 966File: diffutils.info-t, Node: Side by Side Format, Next: Example Side by Side, Up: Side by Side 967 9682.3.1 Controlling Side by Side Format 969------------------------------------- 970 971The `--side-by-side' (`-y') option selects side by side format. 972Because side by side output lines contain two input lines, the output 973is wider than usual: normally 130 print columns, which can fit onto a 974traditional printer line. You can set the width of the output with the 975`--width=COLUMNS' (`-W COLUMNS') option. The output is split into two 976halves of equal width, separated by a small gutter to mark differences; 977the right half is aligned to a tab stop so that tabs line up. Input 978lines that are too long to fit in half of an output line are truncated 979for output. 980 981 The `--left-column' option prints only the left column of two common 982lines. The `--suppress-common-lines' option suppresses common lines 983entirely. 984 985 986File: diffutils.info-t, Node: Example Side by Side, Prev: Side by Side Format, Up: Side by Side 987 9882.3.2 An Example of Side by Side Format 989--------------------------------------- 990 991Here is the output of the command `diff -y -W 72 lao tzu' (*note Sample 992diff Input::, for the complete contents of the two files). 993 994 The Way that can be told of is n < 995 The name that can be named is no < 996 The Nameless is the origin of He The Nameless is the origin of He 997 The Named is the mother of all t | The named is the mother of all t 998 > 999 Therefore let there always be no Therefore let there always be no 1000 so we may see their subtlety, so we may see their subtlety, 1001 And let there always be being, And let there always be being, 1002 so we may see their outcome. so we may see their outcome. 1003 The two are the same, The two are the same, 1004 But after they are produced, But after they are produced, 1005 they have different names. they have different names. 1006 > They both may be called deep and 1007 > Deeper and more profound, 1008 > The door of all subtleties! 1009 1010 1011File: diffutils.info-t, Node: Normal, Next: Scripts, Prev: Side by Side, Up: Output Formats 1012 10132.4 Showing Differences Without Context 1014======================================= 1015 1016The "normal" `diff' output format shows each hunk of differences 1017without any surrounding context. Sometimes such output is the clearest 1018way to see how lines have changed, without the clutter of nearby 1019unchanged lines (although you can get similar results with the context 1020or unified formats by using 0 lines of context). However, this format 1021is no longer widely used for sending out patches; for that purpose, the 1022context format (*note Context Format::) and the unified format (*note 1023Unified Format::) are superior. Normal format is the default for 1024compatibility with older versions of `diff' and the POSIX standard. 1025Use the `--normal' option to select this output format explicitly. 1026 1027* Menu: 1028 1029* Example Normal:: Sample output in the normal format. 1030* Detailed Normal:: A detailed description of normal output format. 1031 1032 1033File: diffutils.info-t, Node: Example Normal, Next: Detailed Normal, Up: Normal 1034 10352.4.1 An Example of Normal Format 1036--------------------------------- 1037 1038Here is the output of the command `diff lao tzu' (*note Sample diff 1039Input::, for the complete contents of the two files). Notice that it 1040shows only the lines that are different between the two files. 1041 1042 1,2d0 1043 < The Way that can be told of is not the eternal Way; 1044 < The name that can be named is not the eternal name. 1045 4c2,3 1046 < The Named is the mother of all things. 1047 --- 1048 > The named is the mother of all things. 1049 > 1050 11a11,13 1051 > They both may be called deep and profound. 1052 > Deeper and more profound, 1053 > The door of all subtleties! 1054 1055 1056File: diffutils.info-t, Node: Detailed Normal, Prev: Example Normal, Up: Normal 1057 10582.4.2 Detailed Description of Normal Format 1059------------------------------------------- 1060 1061The normal output format consists of one or more hunks of differences; 1062each hunk shows one area where the files differ. Normal format hunks 1063look like this: 1064 1065 CHANGE-COMMAND 1066 < FROM-FILE-LINE 1067 < FROM-FILE-LINE... 1068 --- 1069 > TO-FILE-LINE 1070 > TO-FILE-LINE... 1071 1072 There are three types of change commands. Each consists of a line 1073number or comma-separated range of lines in the first file, a single 1074character indicating the kind of change to make, and a line number or 1075comma-separated range of lines in the second file. All line numbers are 1076the original line numbers in each file. The types of change commands 1077are: 1078 1079`LaR' 1080 Add the lines in range R of the second file after line L of the 1081 first file. For example, `8a12,15' means append lines 12-15 of 1082 file 2 after line 8 of file 1; or, if changing file 2 into file 1, 1083 delete lines 12-15 of file 2. 1084 1085`FcT' 1086 Replace the lines in range F of the first file with lines in range 1087 T of the second file. This is like a combined add and delete, but 1088 more compact. For example, `5,7c8,10' means change lines 5-7 of 1089 file 1 to read as lines 8-10 of file 2; or, if changing file 2 into 1090 file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1. 1091 1092`RdL' 1093 Delete the lines in range R from the first file; line L is where 1094 they would have appeared in the second file had they not been 1095 deleted. For example, `5,7d3' means delete lines 5-7 of file 1; 1096 or, if changing file 2 into file 1, append lines 5-7 of file 1 1097 after line 3 of file 2. 1098 1099 1100File: diffutils.info-t, Node: Scripts, Next: If-then-else, Prev: Normal, Up: Output Formats 1101 11022.5 Making Edit Scripts 1103======================= 1104 1105Several output modes produce command scripts for editing FROM-FILE to 1106produce TO-FILE. 1107 1108* Menu: 1109 1110* ed Scripts:: Using `diff' to produce commands for `ed'. 1111* Forward ed:: Making forward `ed' scripts. 1112* RCS:: A special `diff' output format used by RCS. 1113 1114 1115File: diffutils.info-t, Node: ed Scripts, Next: Forward ed, Up: Scripts 1116 11172.5.1 `ed' Scripts 1118------------------ 1119 1120`diff' can produce commands that direct the `ed' text editor to change 1121the first file into the second file. Long ago, this was the only 1122output mode that was suitable for editing one file into another 1123automatically; today, with `patch', it is almost obsolete. Use the 1124`--ed' (`-e') option to select this output format. 1125 1126 Like the normal format (*note Normal::), this output format does not 1127show any context; unlike the normal format, it does not include the 1128information necessary to apply the diff in reverse (to produce the first 1129file if all you have is the second file and the diff). 1130 1131 If the file `d' contains the output of `diff -e old new', then the 1132command `(cat d && echo w) | ed - old' edits `old' to make it a copy of 1133`new'. More generally, if `d1', `d2', ..., `dN' contain the outputs of 1134`diff -e old new1', `diff -e new1 new2', ..., `diff -e newN-1 newN', 1135respectively, then the command `(cat d1 d2 ... dN && echo w) | ed - 1136old' edits `old' to make it a copy of `newN'. 1137 1138* Menu: 1139 1140* Example ed:: A sample `ed' script. 1141* Detailed ed:: A detailed description of `ed' format. 1142 1143 1144File: diffutils.info-t, Node: Example ed, Next: Detailed ed, Up: ed Scripts 1145 11462.5.1.1 Example `ed' Script 1147........................... 1148 1149Here is the output of `diff -e lao tzu' (*note Sample diff Input::, for 1150the complete contents of the two files): 1151 1152 11a 1153 They both may be called deep and profound. 1154 Deeper and more profound, 1155 The door of all subtleties! 1156 . 1157 4c 1158 The named is the mother of all things. 1159 1160 . 1161 1,2d 1162 1163 1164File: diffutils.info-t, Node: Detailed ed, Prev: Example ed, Up: ed Scripts 1165 11662.5.1.2 Detailed Description of `ed' Format 1167........................................... 1168 1169The `ed' output format consists of one or more hunks of differences. 1170The changes closest to the ends of the files come first so that 1171commands that change the number of lines do not affect how `ed' 1172interprets line numbers in succeeding commands. `ed' format hunks look 1173like this: 1174 1175 CHANGE-COMMAND 1176 TO-FILE-LINE 1177 TO-FILE-LINE... 1178 . 1179 1180 Because `ed' uses a single period on a line to indicate the end of 1181input, GNU `diff' protects lines of changes that contain a single 1182period on a line by writing two periods instead, then writing a 1183subsequent `ed' command to change the two periods into one. The `ed' 1184format cannot represent an incomplete line, so if the second file ends 1185in a changed incomplete line, `diff' reports an error and then pretends 1186that a newline was appended. 1187 1188 There are three types of change commands. Each consists of a line 1189number or comma-separated range of lines in the first file and a single 1190character indicating the kind of change to make. All line numbers are 1191the original line numbers in the file. The types of change commands 1192are: 1193 1194`La' 1195 Add text from the second file after line L in the first file. For 1196 example, `8a' means to add the following lines after line 8 of file 1197 1. 1198 1199`Rc' 1200 Replace the lines in range R in the first file with the following 1201 lines. Like a combined add and delete, but more compact. For 1202 example, `5,7c' means change lines 5-7 of file 1 to read as the 1203 text file 2. 1204 1205`Rd' 1206 Delete the lines in range R from the first file. For example, 1207 `5,7d' means delete lines 5-7 of file 1. 1208 1209 1210File: diffutils.info-t, Node: Forward ed, Next: RCS, Prev: ed Scripts, Up: Scripts 1211 12122.5.2 Forward `ed' Scripts 1213-------------------------- 1214 1215`diff' can produce output that is like an `ed' script, but with hunks 1216in forward (front to back) order. The format of the commands is also 1217changed slightly: command characters precede the lines they modify, 1218spaces separate line numbers in ranges, and no attempt is made to 1219disambiguate hunk lines consisting of a single period. Like `ed' 1220format, forward `ed' format cannot represent incomplete lines. 1221 1222 Forward `ed' format is not very useful, because neither `ed' nor 1223`patch' can apply diffs in this format. It exists mainly for 1224compatibility with older versions of `diff'. Use the `-f' or 1225`--forward-ed' option to select it. 1226 1227 1228File: diffutils.info-t, Node: RCS, Prev: Forward ed, Up: Scripts 1229 12302.5.3 RCS Scripts 1231----------------- 1232 1233The RCS output format is designed specifically for use by the Revision 1234Control System, which is a set of free programs used for organizing 1235different versions and systems of files. Use the `--rcs' (`-n') option 1236to select this output format. It is like the forward `ed' format 1237(*note Forward ed::), but it can represent arbitrary changes to the 1238contents of a file because it avoids the forward `ed' format's problems 1239with lines consisting of a single period and with incomplete lines. 1240Instead of ending text sections with a line consisting of a single 1241period, each command specifies the number of lines it affects; a 1242combination of the `a' and `d' commands are used instead of `c'. Also, 1243if the second file ends in a changed incomplete line, then the output 1244also ends in an incomplete line. 1245 1246 Here is the output of `diff -n lao tzu' (*note Sample diff Input::, 1247for the complete contents of the two files): 1248 1249 d1 2 1250 d4 1 1251 a4 2 1252 The named is the mother of all things. 1253 1254 a11 3 1255 They both may be called deep and profound. 1256 Deeper and more profound, 1257 The door of all subtleties! 1258 1259 1260File: diffutils.info-t, Node: If-then-else, Prev: Scripts, Up: Output Formats 1261 12622.6 Merging Files with If-then-else 1263=================================== 1264 1265You can use `diff' to merge two files of C source code. The output of 1266`diff' in this format contains all the lines of both files. Lines 1267common to both files are output just once; the differing parts are 1268separated by the C preprocessor directives `#ifdef NAME' or `#ifndef 1269NAME', `#else', and `#endif'. When compiling the output, you select 1270which version to use by either defining or leaving undefined the macro 1271NAME. 1272 1273 To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME' 1274option. The argument NAME is the C preprocessor identifier to use in 1275the `#ifdef' and `#ifndef' directives. 1276 1277 For example, if you change an instance of `wait (&s)' to `waitpid 1278(-1, &s, 0)' and then merge the old and new files with the 1279`--ifdef=HAVE_WAITPID' option, then the affected part of your code 1280might look like this: 1281 1282 do { 1283 #ifndef HAVE_WAITPID 1284 if ((w = wait (&s)) < 0 && errno != EINTR) 1285 #else /* HAVE_WAITPID */ 1286 if ((w = waitpid (-1, &s, 0)) < 0 && errno != EINTR) 1287 #endif /* HAVE_WAITPID */ 1288 return w; 1289 } while (w != child); 1290 1291 You can specify formats for languages other than C by using line 1292group formats and line formats, as described in the next sections. 1293 1294* Menu: 1295 1296* Line Group Formats:: Formats for general if-then-else line groups. 1297* Line Formats:: Formats for each line in a line group. 1298* Example If-then-else:: Sample if-then-else format output. 1299* Detailed If-then-else:: A detailed description of if-then-else format. 1300 1301 1302File: diffutils.info-t, Node: Line Group Formats, Next: Line Formats, Up: If-then-else 1303 13042.6.1 Line Group Formats 1305------------------------ 1306 1307Line group formats let you specify formats suitable for many 1308applications that allow if-then-else input, including programming 1309languages and text formatting languages. A line group format specifies 1310the output format for a contiguous group of similar lines. 1311 1312 For example, the following command compares the TeX files `old' and 1313`new', and outputs a merged file in which old regions are surrounded by 1314`\begin{em}'-`\end{em}' lines, and new regions are surrounded by 1315`\begin{bf}'-`\end{bf}' lines. 1316 1317 diff \ 1318 --old-group-format='\begin{em} 1319 %<\end{em} 1320 ' \ 1321 --new-group-format='\begin{bf} 1322 %>\end{bf} 1323 ' \ 1324 old new 1325 1326 The following command is equivalent to the above example, but it is a 1327little more verbose, because it spells out the default line group 1328formats. 1329 1330 diff \ 1331 --old-group-format='\begin{em} 1332 %<\end{em} 1333 ' \ 1334 --new-group-format='\begin{bf} 1335 %>\end{bf} 1336 ' \ 1337 --unchanged-group-format='%=' \ 1338 --changed-group-format='\begin{em} 1339 %<\end{em} 1340 \begin{bf} 1341 %>\end{bf} 1342 ' \ 1343 old new 1344 1345 Here is a more advanced example, which outputs a diff listing with 1346headers containing line numbers in a "plain English" style. 1347 1348 diff \ 1349 --unchanged-group-format='' \ 1350 --old-group-format='-------- %dn line%(n=1?:s) deleted at %df: 1351 %<' \ 1352 --new-group-format='-------- %dN line%(N=1?:s) added after %de: 1353 %>' \ 1354 --changed-group-format='-------- %dn line%(n=1?:s) changed at %df: 1355 %<-------- to: 1356 %>' \ 1357 old new 1358 1359 To specify a line group format, use `diff' with one of the options 1360listed below. You can specify up to four line group formats, one for 1361each kind of line group. You should quote FORMAT, because it typically 1362contains shell metacharacters. 1363 1364`--old-group-format=FORMAT' 1365 These line groups are hunks containing only lines from the first 1366 file. The default old group format is the same as the changed 1367 group format if it is specified; otherwise it is a format that 1368 outputs the line group as-is. 1369 1370`--new-group-format=FORMAT' 1371 These line groups are hunks containing only lines from the second 1372 file. The default new group format is same as the changed group 1373 format if it is specified; otherwise it is a format that outputs 1374 the line group as-is. 1375 1376`--changed-group-format=FORMAT' 1377 These line groups are hunks containing lines from both files. The 1378 default changed group format is the concatenation of the old and 1379 new group formats. 1380 1381`--unchanged-group-format=FORMAT' 1382 These line groups contain lines common to both files. The default 1383 unchanged group format is a format that outputs the line group 1384 as-is. 1385 1386 In a line group format, ordinary characters represent themselves; 1387conversion specifications start with `%' and have one of the following 1388forms. 1389 1390`%<' 1391 stands for the lines from the first file, including the trailing 1392 newline. Each line is formatted according to the old line format 1393 (*note Line Formats::). 1394 1395`%>' 1396 stands for the lines from the second file, including the trailing 1397 newline. Each line is formatted according to the new line format. 1398 1399`%=' 1400 stands for the lines common to both files, including the trailing 1401 newline. Each line is formatted according to the unchanged line 1402 format. 1403 1404`%%' 1405 stands for `%'. 1406 1407`%c'C'' 1408 where C is a single character, stands for C. C may not be a 1409 backslash or an apostrophe. For example, `%c':'' stands for a 1410 colon, even inside the then-part of an if-then-else format, which 1411 a colon would normally terminate. 1412 1413`%c'\O'' 1414 where O is a string of 1, 2, or 3 octal digits, stands for the 1415 character with octal code O. For example, `%c'\0'' stands for a 1416 null character. 1417 1418`FN' 1419 where F is a `printf' conversion specification and N is one of the 1420 following letters, stands for N's value formatted with F. 1421 1422 `e' 1423 The line number of the line just before the group in the old 1424 file. 1425 1426 `f' 1427 The line number of the first line in the group in the old 1428 file; equals E + 1. 1429 1430 `l' 1431 The line number of the last line in the group in the old file. 1432 1433 `m' 1434 The line number of the line just after the group in the old 1435 file; equals L + 1. 1436 1437 `n' 1438 The number of lines in the group in the old file; equals L - 1439 F + 1. 1440 1441 `E, F, L, M, N' 1442 Likewise, for lines in the new file. 1443 1444 1445 The `printf' conversion specification can be `%d', `%o', `%x', or 1446 `%X', specifying decimal, octal, lower case hexadecimal, or upper 1447 case hexadecimal output respectively. After the `%' the following 1448 options can appear in sequence: a series of zero or more flags; an 1449 integer specifying the minimum field width; and a period followed 1450 by an optional integer specifying the minimum number of digits. 1451 The flags are `-' for left-justification, `'' for separating the 1452 digit into groups as specified by the `LC_NUMERIC' locale category, 1453 and `0' for padding with zeros instead of spaces. For example, 1454 `%5dN' prints the number of new lines in the group in a field of 1455 width 5 characters, using the `printf' format `"%5d"'. 1456 1457`(A=B?T:E)' 1458 If A equals B then T else E. A and B are each either a decimal 1459 constant or a single letter interpreted as above. This format 1460 spec is equivalent to T if A's value equals B's; otherwise it is 1461 equivalent to E. 1462 1463 For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no 1464 lines' if N (the number of lines in the group in the new file) is 1465 0, to `1 line' if N is 1, and to `%dN lines' otherwise. 1466 1467 1468File: diffutils.info-t, Node: Line Formats, Next: Example If-then-else, Prev: Line Group Formats, Up: If-then-else 1469 14702.6.2 Line Formats 1471------------------ 1472 1473Line formats control how each line taken from an input file is output 1474as part of a line group in if-then-else format. 1475 1476 For example, the following command outputs text with a one-character 1477change indicator to the left of the text. The first character of output 1478is `-' for deleted lines, `|' for added lines, and a space for 1479unchanged lines. The formats contain newline characters where newlines 1480are desired on output. 1481 1482 diff \ 1483 --old-line-format='-%l 1484 ' \ 1485 --new-line-format='|%l 1486 ' \ 1487 --unchanged-line-format=' %l 1488 ' \ 1489 old new 1490 1491 To specify a line format, use one of the following options. You 1492should quote FORMAT, since it often contains shell metacharacters. 1493 1494`--old-line-format=FORMAT' 1495 formats lines just from the first file. 1496 1497`--new-line-format=FORMAT' 1498 formats lines just from the second file. 1499 1500`--unchanged-line-format=FORMAT' 1501 formats lines common to both files. 1502 1503`--line-format=FORMAT' 1504 formats all lines; in effect, it sets all three above options 1505 simultaneously. 1506 1507 In a line format, ordinary characters represent themselves; 1508conversion specifications start with `%' and have one of the following 1509forms. 1510 1511`%l' 1512 stands for the contents of the line, not counting its trailing 1513 newline (if any). This format ignores whether the line is 1514 incomplete; *Note Incomplete Lines::. 1515 1516`%L' 1517 stands for the contents of the line, including its trailing newline 1518 (if any). If a line is incomplete, this format preserves its 1519 incompleteness. 1520 1521`%%' 1522 stands for `%'. 1523 1524`%c'C'' 1525 where C is a single character, stands for C. C may not be a 1526 backslash or an apostrophe. For example, `%c':'' stands for a 1527 colon. 1528 1529`%c'\O'' 1530 where O is a string of 1, 2, or 3 octal digits, stands for the 1531 character with octal code O. For example, `%c'\0'' stands for a 1532 null character. 1533 1534`Fn' 1535 where F is a `printf' conversion specification, stands for the 1536 line number formatted with F. For example, `%.5dn' prints the 1537 line number using the `printf' format `"%.5d"'. *Note Line Group 1538 Formats::, for more about printf conversion specifications. 1539 1540 1541 The default line format is `%l' followed by a newline character. 1542 1543 If the input contains tab characters and it is important that they 1544line up on output, you should ensure that `%l' or `%L' in a line format 1545is just after a tab stop (e.g. by preceding `%l' or `%L' with a tab 1546character), or you should use the `-t' or `--expand-tabs' option. 1547 1548 Taken together, the line and line group formats let you specify many 1549different formats. For example, the following command uses a format 1550similar to normal `diff' format. You can tailor this command to get 1551fine control over `diff' output. 1552 1553 diff \ 1554 --old-line-format='< %l 1555 ' \ 1556 --new-line-format='> %l 1557 ' \ 1558 --old-group-format='%df%(f=l?:,%dl)d%dE 1559 %<' \ 1560 --new-group-format='%dea%dF%(F=L?:,%dL) 1561 %>' \ 1562 --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL) 1563 %<--- 1564 %>' \ 1565 --unchanged-group-format='' \ 1566 old new 1567 1568 1569File: diffutils.info-t, Node: Example If-then-else, Next: Detailed If-then-else, Prev: Line Formats, Up: If-then-else 1570 15712.6.3 An Example of If-then-else Format 1572--------------------------------------- 1573 1574Here is the output of `diff -DTWO lao tzu' (*note Sample diff Input::, 1575for the complete contents of the two files): 1576 1577 #ifndef TWO 1578 The Way that can be told of is not the eternal Way; 1579 The name that can be named is not the eternal name. 1580 #endif /* ! TWO */ 1581 The Nameless is the origin of Heaven and Earth; 1582 #ifndef TWO 1583 The Named is the mother of all things. 1584 #else /* TWO */ 1585 The named is the mother of all things. 1586 1587 #endif /* TWO */ 1588 Therefore let there always be non-being, 1589 so we may see their subtlety, 1590 And let there always be being, 1591 so we may see their outcome. 1592 The two are the same, 1593 But after they are produced, 1594 they have different names. 1595 #ifdef TWO 1596 They both may be called deep and profound. 1597 Deeper and more profound, 1598 The door of all subtleties! 1599 #endif /* TWO */ 1600 1601 1602File: diffutils.info-t, Node: Detailed If-then-else, Prev: Example If-then-else, Up: If-then-else 1603 16042.6.4 Detailed Description of If-then-else Format 1605------------------------------------------------- 1606 1607For lines common to both files, `diff' uses the unchanged line group 1608format. For each hunk of differences in the merged output format, if 1609the hunk contains only lines from the first file, `diff' uses the old 1610line group format; if the hunk contains only lines from the second 1611file, `diff' uses the new group format; otherwise, `diff' uses the 1612changed group format. 1613 1614 The old, new, and unchanged line formats specify the output format of 1615lines from the first file, lines from the second file, and lines common 1616to both files, respectively. 1617 1618 The option `--ifdef=NAME' is equivalent to the following sequence of 1619options using shell syntax: 1620 1621 --old-group-format='#ifndef NAME 1622 %<#endif /* ! NAME */ 1623 ' \ 1624 --new-group-format='#ifdef NAME 1625 %>#endif /* NAME */ 1626 ' \ 1627 --unchanged-group-format='%=' \ 1628 --changed-group-format='#ifndef NAME 1629 %<#else /* NAME */ 1630 %>#endif /* NAME */ 1631 ' 1632 1633 You should carefully check the `diff' output for proper nesting. 1634For example, when using the `-D NAME' or `--ifdef=NAME' option, you 1635should check that if the differing lines contain any of the C 1636preprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or 1637`#endif', they are nested properly and match. If they don't, you must 1638make corrections manually. It is a good idea to carefully check the 1639resulting code anyway to make sure that it really does what you want it 1640to; depending on how the input files were produced, the output might 1641contain duplicate or otherwise incorrect code. 1642 1643 The `patch' `-D NAME' option behaves like the `diff' `-D NAME' 1644option, except it operates on a file and a diff to produce a merged 1645file. *Note patch Options::. 1646 1647 1648File: diffutils.info-t, Node: Incomplete Lines, Next: Comparing Directories, Prev: Output Formats, Up: Top 1649 16503 Incomplete Lines 1651****************** 1652 1653When an input file ends in a non-newline character, its last line is 1654called an "incomplete line" because its last character is not a 1655newline. All other lines are called "full lines" and end in a newline 1656character. Incomplete lines do not match full lines unless differences 1657in white space are ignored (*note White Space::). 1658 1659 An incomplete line is normally distinguished on output from a full 1660line by a following line that starts with `\'. However, the RCS format 1661(*note RCS::) outputs the incomplete line as-is, without any trailing 1662newline or following line. The side by side format normally represents 1663incomplete lines as-is, but in some cases uses a `\' or `/' gutter 1664marker. *Note Side by Side::. The if-then-else line format preserves 1665a line's incompleteness with `%L', and discards the newline with `%l'. 1666*Note Line Formats::. Finally, with the `ed' and forward `ed' output 1667formats (*note Output Formats::) `diff' cannot represent an incomplete 1668line, so it pretends there was a newline and reports an error. 1669 1670 For example, suppose `F' and `G' are one-byte files that contain 1671just `f' and `g', respectively. Then `diff F G' outputs 1672 1673 1c1 1674 < f 1675 \ No newline at end of file 1676 --- 1677 > g 1678 \ No newline at end of file 1679 1680(The exact message may differ in non-English locales.) `diff -n F G' 1681outputs the following without a trailing newline: 1682 1683 d1 1 1684 a1 1 1685 g 1686 1687`diff -e F G' reports two errors and outputs the following: 1688 1689 1c 1690 g 1691 . 1692 1693 1694File: diffutils.info-t, Node: Comparing Directories, Next: Adjusting Output, Prev: Incomplete Lines, Up: Top 1695 16964 Comparing Directories 1697*********************** 1698 1699You can use `diff' to compare some or all of the files in two directory 1700trees. When both file name arguments to `diff' are directories, it 1701compares each file that is contained in both directories, examining 1702file names in alphabetical order as specified by the `LC_COLLATE' 1703locale category. Normally `diff' is silent about pairs of files that 1704contain no differences, but if you use the `--report-identical-files' 1705(`-s') option, it reports pairs of identical files. Normally `diff' 1706reports subdirectories common to both directories without comparing 1707subdirectories' files, but if you use the `-r' or `--recursive' option, 1708it compares every corresponding pair of files in the directory trees, 1709as many levels deep as they go. 1710 1711 If only one file exists, `diff' normally does not show its contents; 1712it merely reports that one file exists but the other does not. You can 1713make `diff' act as though the missing file is empty, so that it outputs 1714the entire contents of the file that actually exists. (It is output as 1715either an insertion or a deletion, depending on whether the missing 1716file is in the first or the second position.) To do this, use the 1717`--new-file' (`-N') option. This option affects command-line arguments 1718as well as files found via directory traversal; for example, `diff -N a 1719b' treats `a' as empty if `a' does not exist but `b' does, and 1720similarly `diff -N - b' treats standard input as empty if it is closed 1721but `b' exists. 1722 1723 If the older directory contains large files that are not in the 1724newer directory, you can make the patch smaller by using the 1725`--unidirectional-new-file' option instead of `-N'. This option is 1726like `-N' except that it inserts the contents only of files that appear 1727in the second directory but not the first (that is, files that were 1728added). At the top of the patch, write instructions for the user 1729applying the patch to remove the files that were deleted before 1730applying the patch. *Note Making Patches::, for more discussion of 1731making patches for distribution. 1732 1733 To ignore some files while comparing directories, use the 1734`--exclude=PATTERN' (`-x PATTERN') option. This option ignores any 1735files or subdirectories whose base names match the shell pattern 1736PATTERN. Unlike in the shell, a period at the start of the base of a 1737file name matches a wildcard at the start of a pattern. You should 1738enclose PATTERN in quotes so that the shell does not expand it. For 1739example, the option `-x '*.[ao]'' ignores any file whose name ends with 1740`.a' or `.o'. 1741 1742 This option accumulates if you specify it more than once. For 1743example, using the options `-x 'RCS' -x '*,v'' ignores any file or 1744subdirectory whose base name is `RCS' or ends with `,v'. 1745 1746 If you need to give this option many times, you can instead put the 1747patterns in a file, one pattern per line, and use the 1748`--exclude-from=FILE' (`-X FILE') option. Trailing white space and 1749empty lines are ignored in the pattern file. 1750 1751 If you have been comparing two directories and stopped partway 1752through, later you might want to continue where you left off. You can 1753do this by using the `--starting-file=FILE' (`-S FILE') option. This 1754compares only the file FILE and all alphabetically later files in the 1755topmost directory level. 1756 1757 If two directories differ only in that file names are lower case in 1758one directory and upper case in the upper, `diff' normally reports many 1759differences because it compares file names in a case sensitive way. 1760With the `--ignore-file-name-case' option, `diff' ignores case 1761differences in file names, so that for example the contents of the file 1762`Tao' in one directory are compared to the contents of the file `TAO' 1763in the other. The `--no-ignore-file-name-case' option cancels the 1764effect of the `--ignore-file-name-case' option, reverting to the default 1765behavior. 1766 1767 If an `--exclude=PATTERN' (`-x PATTERN') option, or an 1768`--exclude-from=FILE' (`-X FILE') option, is specified while the 1769`--ignore-file-name-case' option is in effect, case is ignored when 1770excluding file names matching the specified patterns. 1771 1772 To avoid that `diff' follows symbolic links, use the 1773`--no-dereference'. When this option is in use, symbolic links will be 1774treated like a special kind of files, rather than comparing the target 1775of each symbolic link. 1776 1777 1778File: diffutils.info-t, Node: Adjusting Output, Next: diff Performance, Prev: Comparing Directories, Up: Top 1779 17805 Making `diff' Output Prettier 1781******************************* 1782 1783`diff' provides several ways to adjust the appearance of its output. 1784These adjustments can be applied to any output format. 1785 1786* Menu: 1787 1788* Tabs:: Preserving the alignment of tab stops. 1789* Trailing Blanks:: Suppressing blanks before empty output lines. 1790* Pagination:: Page numbering and time-stamping `diff' output. 1791 1792 1793File: diffutils.info-t, Node: Tabs, Next: Trailing Blanks, Up: Adjusting Output 1794 17955.1 Preserving Tab Stop Alignment 1796================================= 1797 1798The lines of text in some of the `diff' output formats are preceded by 1799one or two characters that indicate whether the text is inserted, 1800deleted, or changed. The addition of those characters can cause tabs 1801to move to the next tab stop, throwing off the alignment of columns in 1802the line. GNU `diff' provides two ways to make tab-aligned columns 1803line up correctly. 1804 1805 The first way is to have `diff' convert all tabs into the correct 1806number of spaces before outputting them; select this method with the 1807`--expand-tabs' (`-t') option. To use this form of output with 1808`patch', you must give `patch' the `-l' or `--ignore-white-space' 1809option (*note Changed White Space::, for more information). `diff' 1810normally assumes that tab stops are set every 8 print columns, but this 1811can be altered by the `--tabsize=COLUMNS' option. 1812 1813 The other method for making tabs line up correctly is to add a tab 1814character instead of a space after the indicator character at the 1815beginning of the line. This ensures that all following tab characters 1816are in the same position relative to tab stops that they were in the 1817original files, so that the output is aligned correctly. Its 1818disadvantage is that it can make long lines too long to fit on one line 1819of the screen or the paper. It also does not work with the unified 1820output format, which does not have a space character after the change 1821type indicator character. Select this method with the `-T' or 1822`--initial-tab' option. 1823 1824 1825File: diffutils.info-t, Node: Trailing Blanks, Next: Pagination, Prev: Tabs, Up: Adjusting Output 1826 18275.2 Omitting trailing blanks 1828============================ 1829 1830When outputting lines in normal or context format, or outputting an 1831unchanged line in unified format, `diff' normally outputs a blank just 1832before each line. If the line is empty, the output of `diff' therefore 1833contains trailing blanks even though the input does not contain them. 1834For example, when outputting an unchanged empty line in context format, 1835`diff' normally outputs a line with two leading spaces. 1836 1837 Some text editors and email agents routinely delete trailing blanks, 1838so it can be a problem to deal with diff output files that contain 1839them. You can avoid this problem with the `--suppress-blank-empty' 1840option. It causes `diff' to omit trailing blanks at the end of output 1841lines in normal, context, and unified format, unless the trailing 1842blanks were already present in the input. This changes the output 1843format slightly, so that output lines are guaranteed to never end in a 1844blank unless an input line ends in a blank. This format is less likely 1845to be munged by text editors or by transmission via email. It is 1846accepted by GNU `patch' as well. 1847 1848 1849File: diffutils.info-t, Node: Pagination, Prev: Trailing Blanks, Up: Adjusting Output 1850 18515.3 Paginating `diff' Output 1852============================ 1853 1854It can be convenient to have long output page-numbered and time-stamped. 1855The `--paginate' (`-l') option does this by sending the `diff' output 1856through the `pr' program. Here is what the page header might look like 1857for `diff -lc lao tzu': 1858 1859 2002-02-22 14:20 diff -lc lao tzu Page 1 1860 1861 1862File: diffutils.info-t, Node: diff Performance, Next: Comparing Three Files, Prev: Adjusting Output, Up: Top 1863 18646 `diff' Performance Tradeoffs 1865****************************** 1866 1867GNU `diff' runs quite efficiently; however, in some circumstances you 1868can cause it to run faster or produce a more compact set of changes. 1869 1870 One way to improve `diff' performance is to use hard or symbolic 1871links to files instead of copies. This improves performance because 1872`diff' normally does not need to read two hard or symbolic links to the 1873same file, since their contents must be identical. For example, 1874suppose you copy a large directory hierarchy, make a few changes to the 1875copy, and then often use `diff -r' to compare the original to the copy. 1876If the original files are read-only, you can greatly improve 1877performance by creating the copy using hard or symbolic links (e.g., 1878with GNU `cp -lR' or `cp -sR'). Before editing a file in the copy for 1879the first time, you should break the link and replace it with a regular 1880copy. 1881 1882 You can also affect the performance of GNU `diff' by giving it 1883options that change the way it compares files. Performance has more 1884than one dimension. These options improve one aspect of performance at 1885the cost of another, or they improve performance in some cases while 1886hurting it in others. 1887 1888 The way that GNU `diff' determines which lines have changed always 1889comes up with a near-minimal set of differences. Usually it is good 1890enough for practical purposes. If the `diff' output is large, you 1891might want `diff' to use a modified algorithm that sometimes produces a 1892smaller set of differences. The `--minimal' (`-d') option does this; 1893however, it can also cause `diff' to run more slowly than usual, so it 1894is not the default behavior. 1895 1896 When the files you are comparing are large and have small groups of 1897changes scattered throughout them, you can use the 1898`--speed-large-files' option to make a different modification to the 1899algorithm that `diff' uses. If the input files have a constant small 1900density of changes, this option speeds up the comparisons without 1901changing the output. If not, `diff' might produce a larger set of 1902differences; however, the output will still be correct. 1903 1904 Normally `diff' discards the prefix and suffix that is common to 1905both files before it attempts to find a minimal set of differences. 1906This makes `diff' run faster, but occasionally it may produce 1907non-minimal output. The `--horizon-lines=LINES' option prevents `diff' 1908from discarding the last LINES lines of the prefix and the first LINES 1909lines of the suffix. This gives `diff' further opportunities to find a 1910minimal output. 1911 1912 Suppose a run of changed lines includes a sequence of lines at one 1913end and there is an identical sequence of lines just outside the other 1914end. The `diff' command is free to choose which identical sequence is 1915included in the hunk. In this case, `diff' normally shifts the hunk's 1916boundaries when this merges adjacent hunks, or shifts a hunk's lines 1917towards the end of the file. Merging hunks can make the output look 1918nicer in some cases. 1919 1920 1921File: diffutils.info-t, Node: Comparing Three Files, Next: diff3 Merging, Prev: diff Performance, Up: Top 1922 19237 Comparing Three Files 1924*********************** 1925 1926Use the program `diff3' to compare three files and show any differences 1927among them. (`diff3' can also merge files; see *note diff3 Merging::). 1928 1929 The "normal" `diff3' output format shows each hunk of differences 1930without surrounding context. Hunks are labeled depending on whether 1931they are two-way or three-way, and lines are annotated by their 1932location in the input files. 1933 1934 *Note Invoking diff3::, for more information on how to run `diff3'. 1935 1936* Menu: 1937 1938* Sample diff3 Input:: Sample `diff3' input for examples. 1939* Example diff3 Normal:: Sample output in the normal format. 1940* Detailed diff3 Normal:: A detailed description of normal output format. 1941* diff3 Hunks:: The format of normal output format. 1942 1943 1944File: diffutils.info-t, Node: Sample diff3 Input, Next: Example diff3 Normal, Up: Comparing Three Files 1945 19467.1 A Third Sample Input File 1947============================= 1948 1949Here is a third sample file that will be used in examples to illustrate 1950the output of `diff3' and how various options can change it. The first 1951two files are the same that we used for `diff' (*note Sample diff 1952Input::). This is the third sample file, called `tao': 1953 1954 The Way that can be told of is not the eternal Way; 1955 The name that can be named is not the eternal name. 1956 The Nameless is the origin of Heaven and Earth; 1957 The named is the mother of all things. 1958 1959 Therefore let there always be non-being, 1960 so we may see their subtlety, 1961 And let there always be being, 1962 so we may see their result. 1963 The two are the same, 1964 But after they are produced, 1965 they have different names. 1966 1967 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 1968 1969 1970File: diffutils.info-t, Node: Example diff3 Normal, Next: Detailed diff3 Normal, Prev: Sample diff3 Input, Up: Comparing Three Files 1971 19727.2 An Example of `diff3' Normal Format 1973======================================= 1974 1975Here is the output of the command `diff3 lao tzu tao' (*note Sample 1976diff3 Input::, for the complete contents of the files). Notice that it 1977shows only the lines that are different among the three files. 1978 1979 ====2 1980 1:1,2c 1981 3:1,2c 1982 The Way that can be told of is not the eternal Way; 1983 The name that can be named is not the eternal name. 1984 2:0a 1985 ====1 1986 1:4c 1987 The Named is the mother of all things. 1988 2:2,3c 1989 3:4,5c 1990 The named is the mother of all things. 1991 1992 ====3 1993 1:8c 1994 2:7c 1995 so we may see their outcome. 1996 3:9c 1997 so we may see their result. 1998 ==== 1999 1:11a 2000 2:11,13c 2001 They both may be called deep and profound. 2002 Deeper and more profound, 2003 The door of all subtleties! 2004 3:13,14c 2005 2006 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2007 2008 2009File: diffutils.info-t, Node: Detailed diff3 Normal, Next: diff3 Hunks, Prev: Example diff3 Normal, Up: Comparing Three Files 2010 20117.3 Detailed Description of `diff3' Normal Format 2012================================================= 2013 2014Each hunk begins with a line marked `===='. Three-way hunks have plain 2015`====' lines, and two-way hunks have `1', `2', or `3' appended to 2016specify which of the three input files differ in that hunk. The hunks 2017contain copies of two or three sets of input lines each preceded by one 2018or two commands identifying where the lines came from. 2019 2020 Normally, two spaces precede each copy of an input line to 2021distinguish it from the commands. But with the `--initial-tab' (`-T') 2022option, `diff3' uses a tab instead of two spaces; this lines up tabs 2023correctly. *Note Tabs::, for more information. 2024 2025 Commands take the following forms: 2026 2027`FILE:La' 2028 This hunk appears after line L of file FILE, and contains no lines 2029 in that file. To edit this file to yield the other files, one 2030 must append hunk lines taken from the other files. For example, 2031 `1:11a' means that the hunk follows line 11 in the first file and 2032 contains no lines from that file. 2033 2034`FILE:Rc' 2035 This hunk contains the lines in the range R of file FILE. The 2036 range R is a comma-separated pair of line numbers, or just one 2037 number if there is only one line. To edit this file to yield the 2038 other files, one must change the specified lines to be the lines 2039 taken from the other files. For example, `2:11,13c' means that 2040 the hunk contains lines 11 through 13 from the second file. 2041 2042 If the last line in a set of input lines is incomplete (*note 2043Incomplete Lines::), it is distinguished on output from a full line by 2044a following line that starts with `\'. 2045 2046 2047File: diffutils.info-t, Node: diff3 Hunks, Prev: Detailed diff3 Normal, Up: Comparing Three Files 2048 20497.4 `diff3' Hunks 2050================= 2051 2052Groups of lines that differ in two or three of the input files are 2053called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::). If 2054all three input files differ in a `diff3' hunk, the hunk is called a 2055"three-way hunk"; if just two input files differ, it is a "two-way 2056hunk". 2057 2058 As with `diff', several solutions are possible. When comparing the 2059files `A', `B', and `C', `diff3' normally finds `diff3' hunks by 2060merging the two-way hunks output by the two commands `diff A B' and 2061`diff A C'. This does not necessarily minimize the size of the output, 2062but exceptions should be rare. 2063 2064 For example, suppose `F' contains the three lines `a', `b', `f', `G' 2065contains the lines `g', `b', `g', and `H' contains the lines `a', `b', 2066`h'. `diff3 F G H' might output the following: 2067 2068 ====2 2069 1:1c 2070 3:1c 2071 a 2072 2:1c 2073 g 2074 ==== 2075 1:3c 2076 f 2077 2:3c 2078 g 2079 3:3c 2080 h 2081 2082because it found a two-way hunk containing `a' in the first and third 2083files and `g' in the second file, then the single line `b' common to 2084all three files, then a three-way hunk containing the last line of each 2085file. 2086 2087 2088File: diffutils.info-t, Node: diff3 Merging, Next: Interactive Merging, Prev: Comparing Three Files, Up: Top 2089 20908 Merging From a Common Ancestor 2091******************************** 2092 2093When two people have made changes to copies of the same file, `diff3' 2094can produce a merged output that contains both sets of changes together 2095with warnings about conflicts. 2096 2097 One might imagine programs with names like `diff4' and `diff5' to 2098compare more than three files simultaneously, but in practice the need 2099rarely arises. You can use `diff3' to merge three or more sets of 2100changes to a file by merging two change sets at a time. 2101 2102 `diff3' can incorporate changes from two modified versions into a 2103common preceding version. This lets you merge the sets of changes 2104represented by the two newer files. Specify the common ancestor version 2105as the second argument and the two newer versions as the first and third 2106arguments, like this: 2107 2108 diff3 MINE OLDER YOURS 2109 2110You can remember the order of the arguments by noting that they are in 2111alphabetical order. 2112 2113 You can think of this as subtracting OLDER from YOURS and adding the 2114result to MINE, or as merging into MINE the changes that would turn 2115OLDER into YOURS. This merging is well-defined as long as MINE and 2116OLDER match in the neighborhood of each such change. This fails to be 2117true when all three input files differ or when only OLDER differs; we 2118call this a "conflict". When all three input files differ, we call the 2119conflict an "overlap". 2120 2121 `diff3' gives you several ways to handle overlaps and conflicts. 2122You can omit overlaps or conflicts, or select only overlaps, or mark 2123conflicts with special `<<<<<<<' and `>>>>>>>' lines. 2124 2125 `diff3' can output the merge results as an `ed' script that that can 2126be applied to the first file to yield the merged output. However, it 2127is usually better to have `diff3' generate the merged output directly; 2128this bypasses some problems with `ed'. 2129 2130* Menu: 2131 2132* Which Changes:: Selecting changes to incorporate. 2133* Marking Conflicts:: Marking conflicts. 2134* Bypassing ed:: Generating merged output directly. 2135* Merging Incomplete Lines:: How `diff3' merges incomplete lines. 2136* Saving the Changed File:: Emulating System V behavior. 2137 2138 2139File: diffutils.info-t, Node: Which Changes, Next: Marking Conflicts, Up: diff3 Merging 2140 21418.1 Selecting Which Changes to Incorporate 2142========================================== 2143 2144You can select all unmerged changes from OLDER to YOURS for merging 2145into MINE with the `--ed' (`-e') option. You can select only the 2146nonoverlapping unmerged changes with `--easy-only' (`-3'), and you can 2147select only the overlapping changes with `--overlap-only' (`-x'). 2148 2149 The `-e', `-3' and `-x' options select only "unmerged changes", i.e. 2150changes where MINE and YOURS differ; they ignore changes from OLDER to 2151YOURS where MINE and YOURS are identical, because they assume that such 2152changes have already been merged. If this assumption is not a safe 2153one, you can use the `--show-all' (`-A') option (*note Marking 2154Conflicts::). 2155 2156 Here is the output of the command `diff3' with each of these three 2157options (*note Sample diff3 Input::, for the complete contents of the 2158files). Notice that `-e' outputs the union of the disjoint sets of 2159changes output by `-3' and `-x'. 2160 2161 Output of `diff3 -e lao tzu tao': 2162 11a 2163 2164 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2165 . 2166 8c 2167 so we may see their result. 2168 . 2169 2170 Output of `diff3 -3 lao tzu tao': 2171 8c 2172 so we may see their result. 2173 . 2174 2175 Output of `diff3 -x lao tzu tao': 2176 11a 2177 2178 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2179 . 2180 2181 2182File: diffutils.info-t, Node: Marking Conflicts, Next: Bypassing ed, Prev: Which Changes, Up: diff3 Merging 2183 21848.2 Marking Conflicts 2185===================== 2186 2187`diff3' can mark conflicts in the merged output by bracketing them with 2188special marker lines. A conflict that comes from two files A and B is 2189marked as follows: 2190 2191 <<<<<<< A 2192 lines from A 2193 ======= 2194 lines from B 2195 >>>>>>> B 2196 2197 A conflict that comes from three files A, B and C is marked as 2198follows: 2199 2200 <<<<<<< A 2201 lines from A 2202 ||||||| B 2203 lines from B 2204 ======= 2205 lines from C 2206 >>>>>>> C 2207 2208 The `--show-all' (`-A') option acts like the `-e' option, except 2209that it brackets conflicts, and it outputs all changes from OLDER to 2210YOURS, not just the unmerged changes. Thus, given the sample input 2211files (*note Sample diff3 Input::), `diff3 -A lao tzu tao' puts 2212brackets around the conflict where only `tzu' differs: 2213 2214 <<<<<<< tzu 2215 ======= 2216 The Way that can be told of is not the eternal Way; 2217 The name that can be named is not the eternal name. 2218 >>>>>>> tao 2219 2220 And it outputs the three-way conflict as follows: 2221 2222 <<<<<<< lao 2223 ||||||| tzu 2224 They both may be called deep and profound. 2225 Deeper and more profound, 2226 The door of all subtleties! 2227 ======= 2228 2229 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2230 >>>>>>> tao 2231 2232 The `--show-overlap' (`-E') option outputs less information than the 2233`--show-all' (`-A') option, because it outputs only unmerged changes, 2234and it never outputs the contents of the second file. Thus the `-E' 2235option acts like the `-e' option, except that it brackets the first and 2236third files from three-way overlapping changes. Similarly, `-X' acts 2237like `-x', except it brackets all its (necessarily overlapping) 2238changes. For example, for the three-way overlapping change above, the 2239`-E' and `-X' options output the following: 2240 2241 <<<<<<< lao 2242 ======= 2243 2244 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2245 >>>>>>> tao 2246 2247 If you are comparing files that have meaningless or uninformative 2248names, you can use the `--label=LABEL' option to show alternate names 2249in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets. This option can be 2250given up to three times, once for each input file. Thus `diff3 -A 2251--label X --label Y --label Z A B C' acts like `diff3 -A A B C', except 2252that the output looks like it came from files named `X', `Y' and `Z' 2253rather than from files named `A', `B' and `C'. 2254 2255 2256File: diffutils.info-t, Node: Bypassing ed, Next: Merging Incomplete Lines, Prev: Marking Conflicts, Up: diff3 Merging 2257 22588.3 Generating the Merged Output Directly 2259========================================= 2260 2261With the `--merge' (`-m') option, `diff3' outputs the merged file 2262directly. This is more efficient than using `ed' to generate it, and 2263works even with non-text files that `ed' would reject. If you specify 2264`-m' without an `ed' script option, `-A' is assumed. 2265 2266 For example, the command `diff3 -m lao tzu tao' (*note Sample diff3 2267Input:: for a copy of the input files) would output the following: 2268 2269 <<<<<<< tzu 2270 ======= 2271 The Way that can be told of is not the eternal Way; 2272 The name that can be named is not the eternal name. 2273 >>>>>>> tao 2274 The Nameless is the origin of Heaven and Earth; 2275 The Named is the mother of all things. 2276 Therefore let there always be non-being, 2277 so we may see their subtlety, 2278 And let there always be being, 2279 so we may see their result. 2280 The two are the same, 2281 But after they are produced, 2282 they have different names. 2283 <<<<<<< lao 2284 ||||||| tzu 2285 They both may be called deep and profound. 2286 Deeper and more profound, 2287 The door of all subtleties! 2288 ======= 2289 2290 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 2291 >>>>>>> tao 2292 2293 2294File: diffutils.info-t, Node: Merging Incomplete Lines, Next: Saving the Changed File, Prev: Bypassing ed, Up: diff3 Merging 2295 22968.4 How `diff3' Merges Incomplete Lines 2297======================================= 2298 2299With `-m', incomplete lines (*note Incomplete Lines::) are simply 2300copied to the output as they are found; if the merged output ends in an 2301conflict and one of the input files ends in an incomplete line, 2302succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere 2303other than the start of a line because they are appended to the 2304incomplete line. 2305 2306 Without `-m', if an `ed' script option is specified and an 2307incomplete line is found, `diff3' generates a warning and acts as if a 2308newline had been present. 2309 2310 2311File: diffutils.info-t, Node: Saving the Changed File, Prev: Merging Incomplete Lines, Up: diff3 Merging 2312 23138.5 Saving the Changed File 2314=========================== 2315 2316Traditional Unix `diff3' generates an `ed' script without the trailing 2317`w' and `q' commands that save the changes. System V `diff3' generates 2318these extra commands. GNU `diff3' normally behaves like traditional 2319Unix `diff3', but with the `-i' option it behaves like System V `diff3' 2320and appends the `w' and `q' commands. 2321 2322 The `-i' option requires one of the `ed' script options `-AeExX3', 2323and is incompatible with the merged output option `-m'. 2324 2325 2326File: diffutils.info-t, Node: Interactive Merging, Next: Merging with patch, Prev: diff3 Merging, Up: Top 2327 23289 Interactive Merging with `sdiff' 2329********************************** 2330 2331With `sdiff', you can merge two files interactively based on a 2332side-by-side `-y' format comparison (*note Side by Side::). Use 2333`--output=FILE' (`-o FILE') to specify where to put the merged text. 2334*Note Invoking sdiff::, for more details on the options to `sdiff'. 2335 2336 Another way to merge files interactively is to use the Emacs Lisp 2337package `emerge'. *Note emerge: (emacs)emerge, for more information. 2338 2339* Menu: 2340 2341* sdiff Option Summary:: Summary of `sdiff' options. 2342* Merge Commands:: Merging two files interactively. 2343 2344 2345File: diffutils.info-t, Node: sdiff Option Summary, Next: Merge Commands, Up: Interactive Merging 2346 23479.1 Specifying `diff' Options to `sdiff' 2348======================================== 2349 2350The following `sdiff' options have the same meaning as for `diff'. 2351*Note diff Options::, for the use of these options. 2352 2353 -a -b -d -i -t -v 2354 -B -E -I REGEXP -Z 2355 2356 --expand-tabs 2357 --ignore-blank-lines --ignore-case 2358 --ignore-matching-lines=REGEXP --ignore-space-change 2359 --ignore-tab-expansion --ignore-trailing-space 2360 --left-column --minimal --speed-large-files 2361 --strip-trailing-cr --suppress-common-lines 2362 --tabsize=COLUMNS --text --version --width=COLUMNS 2363 2364 For historical reasons, `sdiff' has alternate names for some 2365options. The `-l' option is equivalent to the `--left-column' option, 2366and similarly `-s' is equivalent to `--suppress-common-lines'. The 2367meaning of the `sdiff' `-w' and `-W' options is interchanged from that 2368of `diff': with `sdiff', `-w COLUMNS' is equivalent to 2369`--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'. 2370`sdiff' without the `-o' option is equivalent to `diff' with the 2371`--side-by-side' (`-y') option (*note Side by Side::). 2372 2373 2374File: diffutils.info-t, Node: Merge Commands, Prev: sdiff Option Summary, Up: Interactive Merging 2375 23769.2 Merge Commands 2377================== 2378 2379Groups of common lines, with a blank gutter, are copied from the first 2380file to the output. After each group of differing lines, `sdiff' 2381prompts with `%' and pauses, waiting for one of the following commands. 2382Follow each command with <RET>. 2383 2384`e' 2385 Discard both versions. Invoke a text editor on an empty temporary 2386 file, then copy the resulting file to the output. 2387 2388`eb' 2389 Concatenate the two versions, edit the result in a temporary file, 2390 then copy the edited result to the output. 2391 2392`ed' 2393 Like `eb', except precede each version with a header that shows 2394 what file and lines the version came from. 2395 2396`el' 2397`e1' 2398 Edit a copy of the left version, then copy the result to the 2399 output. 2400 2401`er' 2402`e2' 2403 Edit a copy of the right version, then copy the result to the 2404 output. 2405 2406`l' 2407`1' 2408 Copy the left version to the output. 2409 2410`q' 2411 Quit. 2412 2413`r' 2414`2' 2415 Copy the right version to the output. 2416 2417`s' 2418 Silently copy common lines. 2419 2420`v' 2421 Verbosely copy common lines. This is the default. 2422 2423 The text editor invoked is specified by the `EDITOR' environment 2424variable if it is set. The default is system-dependent. 2425 2426 2427File: diffutils.info-t, Node: Merging with patch, Next: Making Patches, Prev: Interactive Merging, Up: Top 2428 242910 Merging with `patch' 2430*********************** 2431 2432`patch' takes comparison output produced by `diff' and applies the 2433differences to a copy of the original file, producing a patched 2434version. With `patch', you can distribute just the changes to a set of 2435files instead of distributing the entire file set; your correspondents 2436can apply `patch' to update their copy of the files with your changes. 2437`patch' automatically determines the diff format, skips any leading or 2438trailing headers, and uses the headers to determine which file to 2439patch. This lets your correspondents feed a mail message containing a 2440difference listing directly to `patch'. 2441 2442 `patch' detects and warns about common problems like forward 2443patches. It saves any patches that it could not apply. It can also 2444maintain a `patchlevel.h' file to ensure that your correspondents apply 2445diffs in the proper order. 2446 2447 `patch' accepts a series of diffs in its standard input, usually 2448separated by headers that specify which file to patch. It applies 2449`diff' hunks (*note Hunks::) one by one. If a hunk does not exactly 2450match the original file, `patch' uses heuristics to try to patch the 2451file as well as it can. If no approximate match can be found, `patch' 2452rejects the hunk and skips to the next hunk. `patch' normally replaces 2453each file F with its new version, putting reject hunks (if any) into 2454`F.rej'. 2455 2456 *Note Invoking patch::, for detailed information on the options to 2457`patch'. 2458 2459* Menu: 2460 2461* patch Input:: Selecting the type of `patch' input. 2462* Revision Control:: Getting files from RCS, SCCS, etc. 2463* Imperfect:: Dealing with imperfect patches. 2464* Creating and Removing:: Creating and removing files with a patch. 2465* Patching Time Stamps:: Updating time stamps on patched files. 2466* Multiple Patches:: Handling multiple patches in a file. 2467* patch Directories:: Changing directory and stripping directories. 2468* Backups:: Whether backup files are made. 2469* Backup Names:: Backup file names. 2470* Reject Names:: Reject file names. 2471* patch Messages:: Messages and questions `patch' can produce. 2472* patch and POSIX:: Conformance to the POSIX standard. 2473* patch and Tradition:: GNU versus traditional `patch'. 2474 2475 2476File: diffutils.info-t, Node: patch Input, Next: Revision Control, Up: Merging with patch 2477 247810.1 Selecting the `patch' Input Format 2479======================================= 2480 2481`patch' normally determines which `diff' format the patch file uses by 2482examining its contents. For patch files that contain particularly 2483confusing leading text, you might need to use one of the following 2484options to force `patch' to interpret the patch file as a certain 2485format of diff. The output formats listed here are the only ones that 2486`patch' can understand. 2487 2488`-c' 2489`--context' 2490 context diff. 2491 2492`-e' 2493`--ed' 2494 `ed' script. 2495 2496`-n' 2497`--normal' 2498 normal diff. 2499 2500`-u' 2501`--unified' 2502 unified diff. 2503 2504 2505File: diffutils.info-t, Node: Revision Control, Next: Imperfect, Prev: patch Input, Up: Merging with patch 2506 250710.2 Revision Control 2508===================== 2509 2510If a nonexistent input file is under a revision control system 2511supported by `patch', `patch' normally asks the user whether to get (or 2512check out) the file from the revision control system. Patch currently 2513supports RCS, ClearCase and SCCS. Under RCS and SCCS, `patch' also 2514asks when the input file is read-only and matches the default version 2515in the revision control system. 2516 2517 The `--get=NUM' (`-g NUM') option affects access to files under 2518supported revision control systems. If NUM is positive, `patch' gets 2519the file without asking the user; if zero, `patch' neither asks the 2520user nor gets the file; and if negative, `patch' asks the user before 2521getting the file. The default value of NUM is given by the value of the 2522`PATCH_GET' environment variable if it is set; if not, the default 2523value is zero if `patch' is conforming to POSIX, negative otherwise. 2524*Note patch and POSIX::. 2525 2526 The choice of revision control system is unaffected by the 2527`VERSION_CONTROL' environment variable (*note Backup Names::). 2528 2529 2530File: diffutils.info-t, Node: Imperfect, Next: Creating and Removing, Prev: Revision Control, Up: Merging with patch 2531 253210.3 Applying Imperfect Patches 2533=============================== 2534 2535`patch' tries to skip any leading text in the patch file, apply the 2536diff, and then skip any trailing text. Thus you can feed a mail 2537message directly to `patch', and it should work. If the entire diff is 2538indented by a constant amount of white space, `patch' automatically 2539ignores the indentation. If a context diff contains trailing carriage 2540return on each line, `patch' automatically ignores the carriage return. 2541If a context diff has been encapsulated by prepending `- ' to lines 2542beginning with `-' as per Internet RFC 934 2543(ftp://ftp.isi.edu/in-notes/rfc934.txt), `patch' automatically 2544unencapsulates the input. 2545 2546 However, certain other types of imperfect input require user 2547intervention or testing. 2548 2549* Menu: 2550 2551* Changed White Space:: When tabs and spaces don't match exactly. 2552* Reversed Patches:: Applying reversed patches correctly. 2553* Inexact:: Helping `patch' find close matches. 2554* Dry Runs:: Predicting what `patch' will do. 2555 2556 2557File: diffutils.info-t, Node: Changed White Space, Next: Reversed Patches, Up: Imperfect 2558 255910.3.1 Applying Patches with Changed White Space 2560------------------------------------------------ 2561 2562Sometimes mailers, editors, or other programs change spaces into tabs, 2563or vice versa. If this happens to a patch file or an input file, the 2564files might look the same, but `patch' will not be able to match them 2565properly. If this problem occurs, use the `-l' or 2566`--ignore-white-space' option, which makes `patch' compare blank 2567characters (i.e. spaces and tabs) loosely so that any nonempty sequence 2568of blanks in the patch file matches any nonempty sequence of blanks in 2569the input files. Non-blank characters must still match exactly. Each 2570line of the context must still match a line in the input file. 2571 2572 2573File: diffutils.info-t, Node: Reversed Patches, Next: Inexact, Prev: Changed White Space, Up: Imperfect 2574 257510.3.2 Applying Reversed Patches 2576-------------------------------- 2577 2578Sometimes people run `diff' with the new file first instead of second. 2579This creates a diff that is "reversed". To apply such patches, give 2580`patch' the `--reverse' (`-R') option. `patch' then attempts to swap 2581each hunk around before applying it. Rejects come out in the swapped 2582format. 2583 2584 Often `patch' can guess that the patch is reversed. If the first 2585hunk of a patch fails, `patch' reverses the hunk to see if it can apply 2586it that way. If it can, `patch' asks you if you want to have the `-R' 2587option set; if it can't, `patch' continues to apply the patch normally. 2588This method cannot detect a reversed patch if it is a normal diff and 2589the first command is an append (which should have been a delete) since 2590appends always succeed, because a null context matches anywhere. But 2591most patches add or change lines rather than delete them, so most 2592reversed normal diffs begin with a delete, which fails, and `patch' 2593notices. 2594 2595 If you apply a patch that you have already applied, `patch' thinks 2596it is a reversed patch and offers to un-apply the patch. This could be 2597construed as a feature. If you did this inadvertently and you don't 2598want to un-apply the patch, just answer `n' to this offer and to the 2599subsequent "apply anyway" question--or type `C-c' to kill the `patch' 2600process. 2601 2602 2603File: diffutils.info-t, Node: Inexact, Next: Dry Runs, Prev: Reversed Patches, Up: Imperfect 2604 260510.3.3 Helping `patch' Find Inexact Matches 2606------------------------------------------- 2607 2608For context diffs, and to a lesser extent normal diffs, `patch' can 2609detect when the line numbers mentioned in the patch are incorrect, and 2610it attempts to find the correct place to apply each hunk of the patch. 2611As a first guess, it takes the line number mentioned in the hunk, plus 2612or minus any offset used in applying the previous hunk. If that is not 2613the correct place, `patch' scans both forward and backward for a set of 2614lines matching the context given in the hunk. 2615 2616 First `patch' looks for a place where all lines of the context 2617match. If it cannot find such a place, and it is reading a context or 2618unified diff, and the maximum fuzz factor is set to 1 or more, then 2619`patch' makes another scan, ignoring the first and last line of 2620context. If that fails, and the maximum fuzz factor is set to 2 or 2621more, it makes another scan, ignoring the first two and last two lines 2622of context are ignored. It continues similarly if the maximum fuzz 2623factor is larger. 2624 2625 The `--fuzz=LINES' (`-F LINES') option sets the maximum fuzz factor 2626to LINES. This option only applies to context and unified diffs; it 2627ignores up to LINES lines while looking for the place to install a 2628hunk. Note that a larger fuzz factor increases the odds of making a 2629faulty patch. The default fuzz factor is 2; there is no point to 2630setting it to more than the number of lines of context in the diff, 2631ordinarily 3. 2632 2633 If `patch' cannot find a place to install a hunk of the patch, it 2634writes the hunk out to a reject file (*note Reject Names::, for 2635information on how reject files are named). It writes out rejected 2636hunks in context format no matter what form the input patch is in. If 2637the input is a normal or `ed' diff, many of the contexts are simply 2638null. The line numbers on the hunks in the reject file may be 2639different from those in the patch file: they show the approximate 2640location where `patch' thinks the failed hunks belong in the new file 2641rather than in the old one. 2642 2643 If the `--verbose' option is given, then as it completes each hunk 2644`patch' tells you whether the hunk succeeded or failed, and if it 2645failed, on which line (in the new file) `patch' thinks the hunk should 2646go. If this is different from the line number specified in the diff, 2647it tells you the offset. A single large offset _may_ indicate that 2648`patch' installed a hunk in the wrong place. `patch' also tells you if 2649it used a fuzz factor to make the match, in which case you should also 2650be slightly suspicious. 2651 2652 `patch' cannot tell if the line numbers are off in an `ed' script, 2653and can only detect wrong line numbers in a normal diff when it finds a 2654change or delete command. It may have the same problem with a context 2655diff using a fuzz factor equal to or greater than the number of lines 2656of context shown in the diff (typically 3). In these cases, you should 2657probably look at a context diff between your original and patched input 2658files to see if the changes make sense. Compiling without errors is a 2659pretty good indication that the patch worked, but not a guarantee. 2660 2661 A patch against an empty file applies to a nonexistent file, and vice 2662versa. *Note Creating and Removing::. 2663 2664 `patch' usually produces the correct results, even when it must make 2665many guesses. However, the results are guaranteed only when the patch 2666is applied to an exact copy of the file that the patch was generated 2667from. 2668 2669 2670File: diffutils.info-t, Node: Dry Runs, Prev: Inexact, Up: Imperfect 2671 267210.3.4 Predicting what `patch' will do 2673-------------------------------------- 2674 2675It may not be obvious in advance what `patch' will do with a 2676complicated or poorly formatted patch. If you are concerned that the 2677input might cause `patch' to modify the wrong files, you can use the 2678`--dry-run' option, which causes `patch' to print the results of 2679applying patches without actually changing any files. You can then 2680inspect the diagnostics generated by the dry run to see whether `patch' 2681will modify the files that you expect. If the patch does not do what 2682you want, you can modify the patch (or the other options to `patch') 2683and try another dry run. Once you are satisfied with the proposed 2684patch you can apply it by invoking `patch' as before, but this time 2685without the `--dry-run' option. 2686 2687 2688File: diffutils.info-t, Node: Creating and Removing, Next: Patching Time Stamps, Prev: Imperfect, Up: Merging with patch 2689 269010.4 Creating and Removing Files 2691================================ 2692 2693Sometimes when comparing two directories, a file may exist in one 2694directory but not the other. If you give `diff' the `--new-file' 2695(`-N') option, or if you supply an old or new file that is named 2696`/dev/null' or is empty and is dated the Epoch (1970-01-01 00:00:00 2697UTC), `diff' outputs a patch that adds or deletes the contents of this 2698file. When given such a patch, `patch' normally creates a new file or 2699removes the old file. However, when conforming to POSIX (*note patch 2700and POSIX::), `patch' does not remove the old file, but leaves it empty. 2701The `--remove-empty-files' (`-E') option causes `patch' to remove 2702output files that are empty after applying a patch, even if the patch 2703does not appear to be one that removed the file. 2704 2705 If the patch appears to create a file that already exists, `patch' 2706asks for confirmation before applying the patch. 2707 2708 2709File: diffutils.info-t, Node: Patching Time Stamps, Next: Multiple Patches, Prev: Creating and Removing, Up: Merging with patch 2710 271110.5 Updating Time Stamps on Patched Files 2712========================================== 2713 2714When `patch' updates a file, it normally sets the file's last-modified 2715time stamp to the current time of day. If you are using `patch' to 2716track a software distribution, this can cause `make' to incorrectly 2717conclude that a patched file is out of date. For example, if 2718`syntax.c' depends on `syntax.y', and `patch' updates `syntax.c' and 2719then `syntax.y', then `syntax.c' will normally appear to be out of date 2720with respect to `syntax.y' even though its contents are actually up to 2721date. 2722 2723 The `--set-utc' (`-Z') option causes `patch' to set a patched file's 2724modification and access times to the time stamps given in context diff 2725headers. If the context diff headers do not specify a time zone, they 2726are assumed to use Coordinated Universal Time (UTC, often known as GMT). 2727 2728 The `--set-time' (`-T') option acts like `-Z' or `--set-utc', except 2729that it assumes that the context diff headers' time stamps use local 2730time instead of UTC. This option is not recommended, because patches 2731using local time cannot easily be used by people in other time zones, 2732and because local time stamps are ambiguous when local clocks move 2733backwards during daylight-saving time adjustments. If the context diff 2734headers specify a time zone, this option is equivalent to `--set-utc' 2735(`-Z'). 2736 2737 `patch' normally refrains from setting a file's time stamps if the 2738file's original last-modified time stamp does not match the time given 2739in the diff header, of if the file's contents do not exactly match the 2740patch. However, if the `--force' (`-f') option is given, the file's 2741time stamps are set regardless. 2742 2743 Due to the limitations of the current `diff' format, `patch' cannot 2744update the times of files whose contents have not changed. Also, if 2745you set file time stamps to values other than the current time of day, 2746you should also remove (e.g., with `make clean') all files that depend 2747on the patched files, so that later invocations of `make' do not get 2748confused by the patched files' times. 2749 2750 2751File: diffutils.info-t, Node: Multiple Patches, Next: patch Directories, Prev: Patching Time Stamps, Up: Merging with patch 2752 275310.6 Multiple Patches in a File 2754=============================== 2755 2756If the patch file contains more than one patch, and if you do not 2757specify an input file on the command line, `patch' tries to apply each 2758patch as if they came from separate patch files. This means that it 2759determines the name of the file to patch for each patch, and that it 2760examines the leading text before each patch for file names and 2761prerequisite revision level (*note Making Patches::, for more on that 2762topic). 2763 2764 `patch' uses the following rules to intuit a file name from the 2765leading text before a patch. First, `patch' takes an ordered list of 2766candidate file names as follows: 2767 2768 * If the header is that of a context diff, `patch' takes the old and 2769 new file names in the header. A name is ignored if it does not 2770 have enough slashes to satisfy the `-pNUM' or `--strip=NUM' 2771 option. The name `/dev/null' is also ignored. 2772 2773 * If there is an `Index:' line in the leading garbage and if either 2774 the old and new names are both absent or if `patch' is conforming 2775 to POSIX, `patch' takes the name in the `Index:' line. 2776 2777 * For the purpose of the following rules, the candidate file names 2778 are considered to be in the order (old, new, index), regardless of 2779 the order that they appear in the header. 2780 2781Then `patch' selects a file name from the candidate list as follows: 2782 2783 * If some of the named files exist, `patch' selects the first name 2784 if conforming to POSIX, and the best name otherwise. 2785 2786 * If `patch' is not ignoring RCS, ClearCase, and SCCS (*note 2787 Revision Control::), and no named files exist but an RCS, 2788 ClearCase, or SCCS master is found, `patch' selects the first 2789 named file with an RCS, ClearCase, or SCCS master. 2790 2791 * If no named files exist, no RCS, ClearCase, or SCCS master was 2792 found, some names are given, `patch' is not conforming to POSIX, 2793 and the patch appears to create a file, `patch' selects the best 2794 name requiring the creation of the fewest directories. 2795 2796 * If no file name results from the above heuristics, you are asked 2797 for the name of the file to patch, and `patch' selects that name. 2798 2799 To determine the "best" of a nonempty list of file names, `patch' 2800first takes all the names with the fewest path name components; of 2801those, it then takes all the names with the shortest basename; of 2802those, it then takes all the shortest names; finally, it takes the 2803first remaining name. 2804 2805 *Note patch and POSIX::, to see whether `patch' is conforming to 2806POSIX. 2807 2808 2809File: diffutils.info-t, Node: patch Directories, Next: Backups, Prev: Multiple Patches, Up: Merging with patch 2810 281110.7 Applying Patches in Other Directories 2812========================================== 2813 2814The `--directory=DIRECTORY' (`-d DIRECTORY') option to `patch' makes 2815directory DIRECTORY the current directory for interpreting both file 2816names in the patch file, and file names given as arguments to other 2817options (such as `-B' and `-o'). For example, while in a mail reading 2818program, you can patch a file in the `/usr/src/emacs' directory 2819directly from a message containing the patch like this: 2820 2821 | patch -d /usr/src/emacs 2822 2823 Sometimes the file names given in a patch contain leading 2824directories, but you keep your files in a directory different from the 2825one given in the patch. In those cases, you can use the 2826`--strip=NUMBER' (`-pNUMBER') option to set the file name strip count 2827to NUMBER. The strip count tells `patch' how many slashes, along with 2828the directory names between them, to strip from the front of file 2829names. A sequence of one or more adjacent slashes is counted as a 2830single slash. By default, `patch' strips off all leading directories, 2831leaving just the base file names. 2832 2833 For example, suppose the file name in the patch file is 2834`/gnu/src/emacs/etc/NEWS'. Using `-p0' gives the entire file name 2835unmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading slash), 2836`-p4' gives `etc/NEWS', and not specifying `-p' at all gives `NEWS'. 2837 2838 `patch' looks for each file (after any slashes have been stripped) 2839in the current directory, or if you used the `-d DIRECTORY' option, in 2840that directory. 2841 2842 2843File: diffutils.info-t, Node: Backups, Next: Backup Names, Prev: patch Directories, Up: Merging with patch 2844 284510.8 Backup Files 2846================= 2847 2848Normally, `patch' creates a backup file if the patch does not exactly 2849match the original input file, because in that case the original data 2850might not be recovered if you undo the patch with `patch -R' (*note 2851Reversed Patches::). However, when conforming to POSIX, `patch' does 2852not create backup files by default. *Note patch and POSIX::. 2853 2854 The `--backup' (`-b') option causes `patch' to make a backup file 2855regardless of whether the patch matches the original input. The 2856`--backup-if-mismatch' option causes `patch' to create backup files for 2857mismatches files; this is the default when not conforming to POSIX. The 2858`--no-backup-if-mismatch' option causes `patch' to not create backup 2859files, even for mismatched patches; this is the default when conforming 2860to POSIX. 2861 2862 When backing up a file that does not exist, an empty, unreadable 2863backup file is created as a placeholder to represent the nonexistent 2864file. 2865 2866 2867File: diffutils.info-t, Node: Backup Names, Next: Reject Names, Prev: Backups, Up: Merging with patch 2868 286910.9 Backup File Names 2870====================== 2871 2872Normally, `patch' renames an original input file into a backup file by 2873appending to its name the extension `.orig', or `~' if using `.orig' 2874would make the backup file name too long.(1) The `-z BACKUP-SUFFIX' or 2875`--suffix=BACKUP-SUFFIX' option causes `patch' to use BACKUP-SUFFIX as 2876the backup extension instead. 2877 2878 Alternately, you can specify the extension for backup files with the 2879`SIMPLE_BACKUP_SUFFIX' environment variable, which the options override. 2880 2881 `patch' can also create numbered backup files the way GNU Emacs 2882does. With this method, instead of having a single backup of each 2883file, `patch' makes a new backup file name each time it patches a file. 2884For example, the backups of a file named `sink' would be called, 2885successively, `sink.~1~', `sink.~2~', `sink.~3~', etc. 2886 2887 The `-V BACKUP-STYLE' or `--version-control=BACKUP-STYLE' option 2888takes as an argument a method for creating backup file names. You can 2889alternately control the type of backups that `patch' makes with the 2890`PATCH_VERSION_CONTROL' environment variable, which the `-V' option 2891overrides. If `PATCH_VERSION_CONTROL' is not set, the 2892`VERSION_CONTROL' environment variable is used instead. Please note 2893that these options and variables control backup file names; they do not 2894affect the choice of revision control system (*note Revision Control::). 2895 2896 The values of these environment variables and the argument to the 2897`-V' option are like the GNU Emacs `version-control' variable (*note 2898Backup Names: (emacs)Backup Names, for more information on backup 2899versions in Emacs). They also recognize synonyms that are more 2900descriptive. The valid values are listed below; unique abbreviations 2901are acceptable. 2902 2903`t' 2904`numbered' 2905 Always make numbered backups. 2906 2907`nil' 2908`existing' 2909 Make numbered backups of files that already have them, simple 2910 backups of the others. This is the default. 2911 2912`never' 2913`simple' 2914 Always make simple backups. 2915 2916 You can also tell `patch' to prepend a prefix, such as a directory 2917name, to produce backup file names. The `--prefix=PREFIX' (`-B 2918PREFIX') option makes backup files by prepending PREFIX to them. The 2919`--basename-prefix=PREFIX' (`-Y PREFIX') prepends PREFIX to the last 2920file name component of backup file names instead; for example, `-Y ~' 2921causes the backup name for `dir/file.c' to be `dir/~file.c'. If you 2922use either of these prefix options, the suffix-based options are 2923ignored. 2924 2925 If you specify the output file with the `-o' option, that file is 2926the one that is backed up, not the input file. 2927 2928 Options that affect the names of backup files do not affect whether 2929backups are made. For example, if you specify the 2930`--no-backup-if-mismatch' option, none of the options described in this 2931section have any affect, because no backups are made. 2932 2933 ---------- Footnotes ---------- 2934 2935 (1) A coding error in GNU `patch' version 2.5.4 causes it to always 2936use `~', but this should be fixed in the next release. 2937 2938 2939File: diffutils.info-t, Node: Reject Names, Next: patch Messages, Prev: Backup Names, Up: Merging with patch 2940 294110.10 Reject File Names 2942======================= 2943 2944The names for reject files (files containing patches that `patch' could 2945not find a place to apply) are normally the name of the output file 2946with `.rej' appended (or `#' if using `.rej' would make the backup file 2947name too long). 2948 2949 Alternatively, you can tell `patch' to place all of the rejected 2950patches in a single file. The `-r REJECT-FILE' or 2951`--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file 2952name. 2953 2954 2955File: diffutils.info-t, Node: patch Messages, Next: patch and POSIX, Prev: Reject Names, Up: Merging with patch 2956 295710.11 Messages and Questions from `patch' 2958========================================= 2959 2960`patch' can produce a variety of messages, especially if it has trouble 2961decoding its input. In a few situations where it's not sure how to 2962proceed, `patch' normally prompts you for more information from the 2963keyboard. There are options to produce more or fewer messages, to have 2964it not ask for keyboard input, and to affect the way that file names 2965are quoted in messages. 2966 2967* Menu: 2968 2969* More or Fewer Messages:: Controlling the verbosity of `patch'. 2970* patch and Keyboard Input:: Inhibiting keyboard input. 2971* patch Quoting Style:: Quoting file names in diagnostics. 2972 2973 `patch' exits with status 0 if all hunks are applied successfully, 1 2974if some hunks cannot be applied, and 2 if there is more serious trouble. 2975When applying a set of patches in a loop, you should check the exit 2976status, so you don't apply a later patch to a partially patched file. 2977 2978 2979File: diffutils.info-t, Node: More or Fewer Messages, Next: patch and Keyboard Input, Up: patch Messages 2980 298110.11.1 Controlling the Verbosity of `patch' 2982-------------------------------------------- 2983 2984You can cause `patch' to produce more messages by using the `--verbose' 2985option. For example, when you give this option, the message `Hmm...' 2986indicates that `patch' is reading text in the patch file, attempting to 2987determine whether there is a patch in that text, and if so, what kind 2988of patch it is. 2989 2990 You can inhibit all terminal output from `patch', unless an error 2991occurs, by using the `-s', `--quiet', or `--silent' option. 2992 2993 2994File: diffutils.info-t, Node: patch and Keyboard Input, Next: patch Quoting Style, Prev: More or Fewer Messages, Up: patch Messages 2995 299610.11.2 Inhibiting Keyboard Input 2997--------------------------------- 2998 2999There are two ways you can prevent `patch' from asking you any 3000questions. The `--force' (`-f') option assumes that you know what you 3001are doing. It causes `patch' to do the following: 3002 3003 * Skip patches that do not contain file names in their headers. 3004 3005 * Patch files even though they have the wrong version for the 3006 `Prereq:' line in the patch; 3007 3008 * Assume that patches are not reversed even if they look like they 3009 are. 3010 3011The `--batch' (`-t') option is similar to `-f', in that it suppresses 3012questions, but it makes somewhat different assumptions: 3013 3014 * Skip patches that do not contain file names in their headers (the 3015 same as `-f'). 3016 3017 * Skip patches for which the file has the wrong version for the 3018 `Prereq:' line in the patch; 3019 3020 * Assume that patches are reversed if they look like they are. 3021 3022 3023File: diffutils.info-t, Node: patch Quoting Style, Prev: patch and Keyboard Input, Up: patch Messages 3024 302510.11.3 `patch' Quoting Style 3026----------------------------- 3027 3028When `patch' outputs a file name in a diagnostic message, it can format 3029the name in any of several ways. This can be useful to output file 3030names unambiguously, even if they contain punctuation or special 3031characters like newlines. The `--quoting-style=WORD' option controls 3032how names are output. The WORD should be one of the following: 3033 3034`literal' 3035 Output names as-is. 3036 3037`shell' 3038 Quote names for the shell if they contain shell metacharacters or 3039 would cause ambiguous output. 3040 3041`shell-always' 3042 Quote names for the shell, even if they would normally not require 3043 quoting. 3044 3045`c' 3046 Quote names as for a C language string. 3047 3048`escape' 3049 Quote as with `c' except omit the surrounding double-quote 3050 characters. 3051 3052 You can specify the default value of the `--quoting-style' option 3053with the environment variable `QUOTING_STYLE'. If that environment 3054variable is not set, the default value is `shell', but this default may 3055change in a future version of `patch'. 3056 3057 3058File: diffutils.info-t, Node: patch and POSIX, Next: patch and Tradition, Prev: patch Messages, Up: Merging with patch 3059 306010.12 `patch' and the POSIX Standard 3061==================================== 3062 3063If you specify the `--posix' option, or set the `POSIXLY_CORRECT' 3064environment variable, `patch' conforms more strictly to the POSIX 3065standard, as follows: 3066 3067 * Take the first existing file from the list (old, new, index) when 3068 intuiting file names from diff headers. *Note Multiple Patches::. 3069 3070 * Do not remove files that are removed by a diff. *Note Creating 3071 and Removing::. 3072 3073 * Do not ask whether to get files from RCS, ClearCase, or SCCS. 3074 *Note Revision Control::. 3075 3076 * Require that all options precede the files in the command line. 3077 3078 * Do not backup files, even when there is a mismatch. *Note 3079 Backups::. 3080 3081 3082 3083File: diffutils.info-t, Node: patch and Tradition, Prev: patch and POSIX, Up: Merging with patch 3084 308510.13 GNU `patch' and Traditional `patch' 3086========================================= 3087 3088The current version of GNU `patch' normally follows the POSIX standard. 3089*Note patch and POSIX::, for the few exceptions to this general rule. 3090 3091 Unfortunately, POSIX redefined the behavior of `patch' in several 3092important ways. You should be aware of the following differences if 3093you must interoperate with traditional `patch', or with GNU `patch' 3094version 2.1 and earlier. 3095 3096 * In traditional `patch', the `-p' option's operand was optional, 3097 and a bare `-p' was equivalent to `-p0'. The `-p' option now 3098 requires an operand, and `-p 0' is now equivalent to `-p0'. For 3099 maximum compatibility, use options like `-p0' and `-p1'. 3100 3101 Also, traditional `patch' simply counted slashes when stripping 3102 path prefixes; `patch' now counts pathname components. That is, a 3103 sequence of one or more adjacent slashes now counts as a single 3104 slash. For maximum portability, avoid sending patches containing 3105 `//' in file names. 3106 3107 * In traditional `patch', backups were enabled by default. This 3108 behavior is now enabled with the `--backup' (`-b') option. 3109 3110 Conversely, in POSIX `patch', backups are never made, even when 3111 there is a mismatch. In GNU `patch', this behavior is enabled 3112 with the `--no-backup-if-mismatch' option, or by conforming to 3113 POSIX. 3114 3115 The `-b SUFFIX' option of traditional `patch' is equivalent to the 3116 `-b -z SUFFIX' options of GNU `patch'. 3117 3118 * Traditional `patch' used a complicated (and incompletely 3119 documented) method to intuit the name of the file to be patched 3120 from the patch header. This method did not conform to POSIX, and 3121 had a few gotchas. Now `patch' uses a different, equally 3122 complicated (but better documented) method that is optionally 3123 POSIX-conforming; we hope it has fewer gotchas. The two methods 3124 are compatible if the file names in the context diff header and the 3125 `Index:' line are all identical after prefix-stripping. Your 3126 patch is normally compatible if each header's file names all 3127 contain the same number of slashes. 3128 3129 * When traditional `patch' asked the user a question, it sent the 3130 question to standard error and looked for an answer from the first 3131 file in the following list that was a terminal: standard error, 3132 standard output, `/dev/tty', and standard input. Now `patch' 3133 sends questions to standard output and gets answers from 3134 `/dev/tty'. Defaults for some answers have been changed so that 3135 `patch' never goes into an infinite loop when using default 3136 answers. 3137 3138 * Traditional `patch' exited with a status value that counted the 3139 number of bad hunks, or with status 1 if there was real trouble. 3140 Now `patch' exits with status 1 if some hunks failed, or with 2 if 3141 there was real trouble. 3142 3143 * Limit yourself to the following options when sending instructions 3144 meant to be executed by anyone running GNU `patch', traditional 3145 `patch', or a `patch' that conforms to POSIX. Spaces are 3146 significant in the following list, and operands are required. 3147 3148 `-c' 3149 `-d DIR' 3150 `-D DEFINE' 3151 `-e' 3152 `-l' 3153 `-n' 3154 `-N' 3155 `-o OUTFILE' 3156 `-pNUM' 3157 `-R' 3158 `-r REJECTFILE' 3159 3160 3161 3162File: diffutils.info-t, Node: Making Patches, Next: Invoking cmp, Prev: Merging with patch, Up: Top 3163 316411 Tips for Making and Using Patches 3165************************************ 3166 3167Use some common sense when making and using patches. For example, when 3168sending bug fixes to a program's maintainer, send several small 3169patches, one per independent subject, instead of one large, 3170harder-to-digest patch that covers all the subjects. 3171 3172 Here are some other things you should keep in mind if you are going 3173to distribute patches for updating a software package. 3174 3175* Menu: 3176 3177* Tips for Patch Producers:: Advice for making patches. 3178* Tips for Patch Consumers:: Advice for using patches. 3179* Avoiding Common Mistakes:: Avoiding common mistakes when using `patch'. 3180* Generating Smaller Patches:: How to generate smaller patches. 3181 3182 3183File: diffutils.info-t, Node: Tips for Patch Producers, Next: Tips for Patch Consumers, Up: Making Patches 3184 318511.1 Tips for Patch Producers 3186============================= 3187 3188To create a patch that changes an older version of a package into a 3189newer version, first make a copy of the older and newer versions in 3190adjacent subdirectories. It is common to do that by unpacking `tar' 3191archives of the two versions. 3192 3193 To generate the patch, use the command `diff -Naur OLD NEW' where 3194OLD and NEW identify the old and new directories. The names OLD and 3195NEW should not contain any slashes. The `-N' option lets the patch 3196create and remove files; `-a' lets the patch update non-text files; `-u' 3197generates useful time stamps and enough context; and `-r' lets the 3198patch update subdirectories. Here is an example command, using Bourne 3199shell syntax: 3200 3201 diff -Naur gcc-3.0.3 gcc-3.0.4 3202 3203 Tell your recipients how to apply the patches. This should include 3204which working directory to use, and which `patch' options to use; the 3205option `-p1' is recommended. Test your procedure by pretending to be a 3206recipient and applying your patches to a copy of the original files. 3207 3208 *Note Avoiding Common Mistakes::, for how to avoid common mistakes 3209when generating a patch. 3210 3211 3212File: diffutils.info-t, Node: Tips for Patch Consumers, Next: Avoiding Common Mistakes, Prev: Tips for Patch Producers, Up: Making Patches 3213 321411.2 Tips for Patch Consumers 3215============================= 3216 3217A patch producer should tell recipients how to apply the patches, so 3218the first rule of thumb for a patch consumer is to follow the 3219instructions supplied with the patch. 3220 3221 GNU `diff' can analyze files with arbitrarily long lines and files 3222that end in incomplete lines. However, older versions of `patch' 3223cannot patch such files. If you are having trouble applying such 3224patches, try upgrading to a recent version of GNU `patch'. 3225 3226 3227File: diffutils.info-t, Node: Avoiding Common Mistakes, Next: Generating Smaller Patches, Prev: Tips for Patch Consumers, Up: Making Patches 3228 322911.3 Avoiding Common Mistakes 3230============================= 3231 3232When producing a patch for multiple files, apply `diff' to directories 3233whose names do not have slashes. This reduces confusion when the patch 3234consumer specifies the `-pNUMBER' option, since this option can have 3235surprising results when the old and new file names have different 3236numbers of slashes. For example, do not send a patch with a header 3237that looks like this: 3238 3239 diff -Naur v2.0.29/prog/README prog/README 3240 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800 3241 +++ prog/README 2002-03-17 20:49:32.442260588 -0800 3242 3243because the two file names have different numbers of slashes, and 3244different versions of `patch' interpret the file names differently. To 3245avoid confusion, send output that looks like this instead: 3246 3247 diff -Naur v2.0.29/prog/README v2.0.30/prog/README 3248 --- v2.0.29/prog/README 2002-03-10 23:30:39.942229878 -0800 3249 +++ v2.0.30/prog/README 2002-03-17 20:49:32.442260588 -0800 3250 3251 Make sure you have specified the file names correctly, either in a 3252context diff header or with an `Index:' line. Take care to not send out 3253reversed patches, since these make people wonder whether they have 3254already applied the patch. 3255 3256 Avoid sending patches that compare backup file names like 3257`README.orig' or `README~', since this might confuse `patch' into 3258patching a backup file instead of the real file. Instead, send patches 3259that compare the same base file names in different directories, e.g. 3260`old/README' and `new/README'. 3261 3262 To save people from partially applying a patch before other patches 3263that should have gone before it, you can make the first patch in the 3264patch file update a file with a name like `patchlevel.h' or 3265`version.c', which contains a patch level or version number. If the 3266input file contains the wrong version number, `patch' will complain 3267immediately. 3268 3269 An even clearer way to prevent this problem is to put a `Prereq:' 3270line before the patch. If the leading text in the patch file contains a 3271line that starts with `Prereq:', `patch' takes the next word from that 3272line (normally a version number) and checks whether the next input file 3273contains that word, preceded and followed by either white space or a 3274newline. If not, `patch' prompts you for confirmation before 3275proceeding. This makes it difficult to accidentally apply patches in 3276the wrong order. 3277 3278 3279File: diffutils.info-t, Node: Generating Smaller Patches, Prev: Avoiding Common Mistakes, Up: Making Patches 3280 328111.4 Generating Smaller Patches 3282=============================== 3283 3284The simplest way to generate a patch is to use `diff -Naur' (*note Tips 3285for Patch Producers::), but you might be able to reduce the size of the 3286patch by renaming or removing some files before making the patch. If 3287the older version of the package contains any files that the newer 3288version does not, or if any files have been renamed between the two 3289versions, make a list of `rm' and `mv' commands for the user to execute 3290in the old version directory before applying the patch. Then run those 3291commands yourself in the scratch directory. 3292 3293 If there are any files that you don't need to include in the patch 3294because they can easily be rebuilt from other files (for example, 3295`TAGS' and output from `yacc' and `makeinfo'), exclude them from the 3296patch by giving `diff' the `-x PATTERN' option (*note Comparing 3297Directories::). If you want your patch to modify a derived file 3298because your recipients lack tools to build it, make sure that the 3299patch for the derived file follows any patches for files that it 3300depends on, so that the recipients' time stamps will not confuse `make'. 3301 3302 Now you can create the patch using `diff -Naur'. Make sure to 3303specify the scratch directory first and the newer directory second. 3304 3305 Add to the top of the patch a note telling the user any `rm' and 3306`mv' commands to run before applying the patch. Then you can remove 3307the scratch directory. 3308 3309 You can also shrink the patch size by using fewer lines of context, 3310but bear in mind that `patch' typically needs at least two lines for 3311proper operation when patches do not exactly match the input files. 3312 3313 3314File: diffutils.info-t, Node: Invoking cmp, Next: Invoking diff, Prev: Making Patches, Up: Top 3315 331612 Invoking `cmp' 3317***************** 3318 3319The `cmp' command compares two files, and if they differ, tells the 3320first byte and line number where they differ or reports that one file 3321is a prefix of the other. Bytes and lines are numbered starting with 33221. The arguments of `cmp' are as follows: 3323 3324 cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]] 3325 3326 The file name `-' is always the standard input. `cmp' also uses the 3327standard input if one file name is omitted. The FROM-SKIP and TO-SKIP 3328operands specify how many bytes to ignore at the start of each file; 3329they are equivalent to the `--ignore-initial=FROM-SKIP:TO-SKIP' option. 3330 3331 By default, `cmp' outputs nothing if the two files have the same 3332contents. If one file is a prefix of the other, `cmp' prints to 3333standard error a message of the following form: 3334 3335 cmp: EOF on SHORTER-FILE 3336 3337 Otherwise, `cmp' prints to standard output a message of the 3338following form: 3339 3340 FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER 3341 3342 The message formats can differ outside the POSIX locale. Also, 3343POSIX allows the EOF message to be followed by a blank and some 3344additional information. 3345 3346 An exit status of 0 means no differences were found, 1 means some 3347differences were found, and 2 means trouble. 3348 3349* Menu: 3350 3351* cmp Options:: Summary of options to `cmp'. 3352 3353 3354File: diffutils.info-t, Node: cmp Options, Up: Invoking cmp 3355 335612.1 Options to `cmp' 3357===================== 3358 3359Below is a summary of all of the options that GNU `cmp' accepts. Most 3360options have two equivalent names, one of which is a single letter 3361preceded by `-', and the other of which is a long name preceded by 3362`--'. Multiple single letter options (unless they take an argument) 3363can be combined into a single command line word: `-bl' is equivalent to 3364`-b -l'. 3365 3366`-b' 3367`--print-bytes' 3368 Print the differing bytes. Display control bytes as a `^' 3369 followed by a letter of the alphabet and precede bytes that have 3370 the high bit set with `M-' (which stands for "meta"). 3371 3372`--help' 3373 Output a summary of usage and then exit. 3374 3375`-i SKIP' 3376`--ignore-initial=SKIP' 3377 Ignore any differences in the first SKIP bytes of the input files. 3378 Treat files with fewer than SKIP bytes as if they are empty. If 3379 SKIP is of the form `FROM-SKIP:TO-SKIP', skip the first FROM-SKIP 3380 bytes of the first input file and the first TO-SKIP bytes of the 3381 second. 3382 3383`-l' 3384`--verbose' 3385 Output the (decimal) byte numbers and (octal) values of all 3386 differing bytes, instead of the default standard output. Each 3387 output line contains a differing byte's number relative to the 3388 start of the input, followed by the differing byte values. Byte 3389 numbers start at 1. Also, output the EOF message if one file is 3390 shorter than the other. 3391 3392`-n COUNT' 3393`--bytes=COUNT' 3394 Compare at most COUNT input bytes. 3395 3396`-s' 3397`--quiet' 3398`--silent' 3399 Do not print anything; only return an exit status indicating 3400 whether the files differ. 3401 3402`-v' 3403`--version' 3404 Output version information and then exit. 3405 3406 In the above table, operands that are byte counts are normally 3407decimal, but may be preceded by `0' for octal and `0x' for hexadecimal. 3408 3409 A byte count can be followed by a suffix to specify a multiple of 3410that count; in this case an omitted integer is understood to be 1. A 3411bare size letter, or one followed by `iB', specifies a multiple using 3412powers of 1024. A size letter followed by `B' specifies powers of 1000 3413instead. For example, `-n 4M' and `-n 4MiB' are equivalent to `-n 34144194304', whereas `-n 4MB' is equivalent to `-n 4000000'. This 3415notation is upward compatible with the SI prefixes 3416(http://www.bipm.fr/enus/3_SI/si-prefixes.html) for decimal multiples 3417and with the IEC 60027-2 prefixes for binary multiples 3418(http://physics.nist.gov/cuu/Units/binary.html). 3419 3420 The following suffixes are defined. Large sizes like `1Y' may be 3421rejected by your computer due to limitations of its arithmetic. 3422 3423`kB' 3424 kilobyte: 10^3 = 1000. 3425 3426`k' 3427`K' 3428`KiB' 3429 kibibyte: 2^10 = 1024. `K' is special: the SI prefix is `k' and 3430 the IEC 60027-2 prefix is `Ki', but tradition and POSIX use `k' to 3431 mean `KiB'. 3432 3433`MB' 3434 megabyte: 10^6 = 1,000,000. 3435 3436`M' 3437`MiB' 3438 mebibyte: 2^20 = 1,048,576. 3439 3440`GB' 3441 gigabyte: 10^9 = 1,000,000,000. 3442 3443`G' 3444`GiB' 3445 gibibyte: 2^30 = 1,073,741,824. 3446 3447`TB' 3448 terabyte: 10^12 = 1,000,000,000,000. 3449 3450`T' 3451`TiB' 3452 tebibyte: 2^40 = 1,099,511,627,776. 3453 3454`PB' 3455 petabyte: 10^15 = 1,000,000,000,000,000. 3456 3457`P' 3458`PiB' 3459 pebibyte: 2^50 = 1,125,899,906,842,624. 3460 3461`EB' 3462 exabyte: 10^18 = 1,000,000,000,000,000,000. 3463 3464`E' 3465`EiB' 3466 exbibyte: 2^60 = 1,152,921,504,606,846,976. 3467 3468`ZB' 3469 zettabyte: 10^21 = 1,000,000,000,000,000,000,000 3470 3471`Z' 3472`ZiB' 3473 2^70 = 1,180,591,620,717,411,303,424. (`Zi' is a GNU extension to 3474 IEC 60027-2.) 3475 3476`YB' 3477 yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000. 3478 3479`Y' 3480`YiB' 3481 2^80 = 1,208,925,819,614,629,174,706,176. (`Yi' is a GNU 3482 extension to IEC 60027-2.) 3483 3484 3485File: diffutils.info-t, Node: Invoking diff, Next: Invoking diff3, Prev: Invoking cmp, Up: Top 3486 348713 Invoking `diff' 3488****************** 3489 3490The format for running the `diff' command is: 3491 3492 diff OPTIONS... FILES... 3493 3494 In the simplest case, two file names FROM-FILE and TO-FILE are 3495given, and `diff' compares the contents of FROM-FILE and TO-FILE. A 3496file name of `-' stands for text read from the standard input. As a 3497special case, `diff - -' compares a copy of standard input to itself. 3498 3499 If one file is a directory and the other is not, `diff' compares the 3500file in the directory whose name is that of the non-directory. The 3501non-directory file must not be `-'. 3502 3503 If two file names are given and both are directories, `diff' 3504compares corresponding files in both directories, in alphabetical 3505order; this comparison is not recursive unless the `--recursive' (`-r') 3506option is given. `diff' never compares the actual contents of a 3507directory as if it were a file. The file that is fully specified may 3508not be standard input, because standard input is nameless and the 3509notion of "file with the same name" does not apply. 3510 3511 If the `--from-file=FILE' option is given, the number of file names 3512is arbitrary, and FILE is compared to each named file. Similarly, if 3513the `--to-file=FILE' option is given, each named file is compared to 3514FILE. 3515 3516 `diff' options begin with `-', so normally file names may not begin 3517with `-'. However, `--' as an argument by itself treats the remaining 3518arguments as file names even if they begin with `-'. 3519 3520 An exit status of 0 means no differences were found, 1 means some 3521differences were found, and 2 means trouble. Normally, differing 3522binary files count as trouble, but this can be altered by using the 3523`--text' (`-a') option, or the `-q' or `--brief' option. 3524 3525* Menu: 3526 3527* diff Options:: Summary of options to `diff'. 3528 3529 3530File: diffutils.info-t, Node: diff Options, Up: Invoking diff 3531 353213.1 Options to `diff' 3533====================== 3534 3535Below is a summary of all of the options that GNU `diff' accepts. Most 3536options have two equivalent names, one of which is a single letter 3537preceded by `-', and the other of which is a long name preceded by 3538`--'. Multiple single letter options (unless they take an argument) 3539can be combined into a single command line word: `-ac' is equivalent to 3540`-a -c'. Long named options can be abbreviated to any unique prefix of 3541their name. Brackets ([ and ]) indicate that an option takes an 3542optional argument. 3543 3544`-a' 3545`--text' 3546 Treat all files as text and compare them line-by-line, even if they 3547 do not seem to be text. *Note Binary::. 3548 3549`-b' 3550`--ignore-space-change' 3551 Ignore changes in amount of white space. *Note White Space::. 3552 3553`-B' 3554`--ignore-blank-lines' 3555 Ignore changes that just insert or delete blank lines. *Note 3556 Blank Lines::. 3557 3558`--binary' 3559 Read and write data in binary mode. *Note Binary::. 3560 3561`-c' 3562 Use the context output format, showing three lines of context. 3563 *Note Context Format::. 3564 3565`-C LINES' 3566`--context[=LINES]' 3567 Use the context output format, showing LINES (an integer) lines of 3568 context, or three if LINES is not given. *Note Context Format::. 3569 For proper operation, `patch' typically needs at least two lines of 3570 context. 3571 3572 For compatibility `diff' also supports an obsolete option syntax 3573 `-LINES' that has effect when combined with `-c', `-p', or `-u'. 3574 New scripts should use `-U LINES' (`-C LINES') instead. 3575 3576`--changed-group-format=FORMAT' 3577 Use FORMAT to output a line group containing differing lines from 3578 both files in if-then-else format. *Note Line Group Formats::. 3579 3580`-d' 3581`--minimal' 3582 Change the algorithm perhaps find a smaller set of changes. This 3583 makes `diff' slower (sometimes much slower). *Note diff 3584 Performance::. 3585 3586`-D NAME' 3587`--ifdef=NAME' 3588 Make merged `#ifdef' format output, conditional on the preprocessor 3589 macro NAME. *Note If-then-else::. 3590 3591`-e' 3592`--ed' 3593 Make output that is a valid `ed' script. *Note ed Scripts::. 3594 3595`-E' 3596`--ignore-tab-expansion' 3597 Ignore changes due to tab expansion. *Note White Space::. 3598 3599`-f' 3600`--forward-ed' 3601 Make output that looks vaguely like an `ed' script but has changes 3602 in the order they appear in the file. *Note Forward ed::. 3603 3604`-F REGEXP' 3605`--show-function-line=REGEXP' 3606 In context and unified format, for each hunk of differences, show 3607 some of the last preceding line that matches REGEXP. *Note 3608 Specified Headings::. 3609 3610`--from-file=FILE' 3611 Compare FILE to each operand; FILE may be a directory. 3612 3613`--help' 3614 Output a summary of usage and then exit. 3615 3616`--horizon-lines=LINES' 3617 Do not discard the last LINES lines of the common prefix and the 3618 first LINES lines of the common suffix. *Note diff Performance::. 3619 3620`-i' 3621`--ignore-case' 3622 Ignore changes in case; consider upper- and lower-case letters 3623 equivalent. *Note Case Folding::. 3624 3625`-I REGEXP' 3626`--ignore-matching-lines=REGEXP' 3627 Ignore changes that just insert or delete lines that match REGEXP. 3628 *Note Specified Lines::. 3629 3630`--ignore-file-name-case' 3631 Ignore case when comparing file names. For example, recursive 3632 comparison of `d' to `e' might compare the contents of `d/Init' 3633 and `e/inIt'. At the top level, `diff d inIt' might compare the 3634 contents of `d/Init' and `inIt'. *Note Comparing Directories::. 3635 3636`-l' 3637`--paginate' 3638 Pass the output through `pr' to paginate it. *Note Pagination::. 3639 3640`-L LABEL' 3641`--label=LABEL' 3642 Use LABEL instead of the file name in the context format (*note 3643 Context Format::) and unified format (*note Unified Format::) 3644 headers. *Note RCS::. 3645 3646`--left-column' 3647 Print only the left column of two common lines in side by side 3648 format. *Note Side by Side Format::. 3649 3650`--line-format=FORMAT' 3651 Use FORMAT to output all input lines in if-then-else format. 3652 *Note Line Formats::. 3653 3654`-n' 3655`--rcs' 3656 Output RCS-format diffs; like `-f' except that each command 3657 specifies the number of lines affected. *Note RCS::. 3658 3659`-N' 3660`--new-file' 3661 If one file is missing, treat it as present but empty. *Note 3662 Comparing Directories::. 3663 3664`--new-group-format=FORMAT' 3665 Use FORMAT to output a group of lines taken from just the second 3666 file in if-then-else format. *Note Line Group Formats::. 3667 3668`--new-line-format=FORMAT' 3669 Use FORMAT to output a line taken from just the second file in 3670 if-then-else format. *Note Line Formats::. 3671 3672`--no-dereference' 3673 Act on symbolic links themselves instead of what they point to. 3674 3675`--old-group-format=FORMAT' 3676 Use FORMAT to output a group of lines taken from just the first 3677 file in if-then-else format. *Note Line Group Formats::. 3678 3679`--old-line-format=FORMAT' 3680 Use FORMAT to output a line taken from just the first file in 3681 if-then-else format. *Note Line Formats::. 3682 3683`-p' 3684`--show-c-function' 3685 Show which C function each change is in. *Note C Function 3686 Headings::. 3687 3688`-q' 3689`--brief' 3690 Report only whether the files differ, not the details of the 3691 differences. *Note Brief::. 3692 3693`-r' 3694`--recursive' 3695 When comparing directories, recursively compare any subdirectories 3696 found. *Note Comparing Directories::. 3697 3698`-s' 3699`--report-identical-files' 3700 Report when two files are the same. *Note Comparing Directories::. 3701 3702`-S FILE' 3703`--starting-file=FILE' 3704 When comparing directories, start with the file FILE. This is 3705 used for resuming an aborted comparison. *Note Comparing 3706 Directories::. 3707 3708`--speed-large-files' 3709 Use heuristics to speed handling of large files that have numerous 3710 scattered small changes. *Note diff Performance::. 3711 3712`--strip-trailing-cr' 3713 Strip any trailing carriage return at the end of an input line. 3714 *Note Binary::. 3715 3716`--suppress-common-lines' 3717 Do not print common lines in side by side format. *Note Side by 3718 Side Format::. 3719 3720`-t' 3721`--expand-tabs' 3722 Expand tabs to spaces in the output, to preserve the alignment of 3723 tabs in the input files. *Note Tabs::. 3724 3725`-T' 3726`--initial-tab' 3727 Output a tab rather than a space before the text of a line in 3728 normal or context format. This causes the alignment of tabs in 3729 the line to look normal. *Note Tabs::. 3730 3731`--tabsize=COLUMNS' 3732 Assume that tab stops are set every COLUMNS (default 8) print 3733 columns. *Note Tabs::. 3734 3735`--suppress-blank-empty' 3736 Suppress any blanks before newlines when printing the 3737 representation of an empty line, when outputting normal, context, 3738 or unified format. *Note Trailing Blanks::. 3739 3740`--to-file=FILE' 3741 Compare each operand to FILE; FILE may be a directory. 3742 3743`-u' 3744 Use the unified output format, showing three lines of context. 3745 *Note Unified Format::. 3746 3747`--unchanged-group-format=FORMAT' 3748 Use FORMAT to output a group of common lines taken from both files 3749 in if-then-else format. *Note Line Group Formats::. 3750 3751`--unchanged-line-format=FORMAT' 3752 Use FORMAT to output a line common to both files in if-then-else 3753 format. *Note Line Formats::. 3754 3755`--unidirectional-new-file' 3756 If a first file is missing, treat it as present but empty. *Note 3757 Comparing Directories::. 3758 3759`-U LINES' 3760`--unified[=LINES]' 3761 Use the unified output format, showing LINES (an integer) lines of 3762 context, or three if LINES is not given. *Note Unified Format::. 3763 For proper operation, `patch' typically needs at least two lines of 3764 context. 3765 3766 On older systems, `diff' supports an obsolete option `-LINES' that 3767 has effect when combined with `-u'. POSIX 1003.1-2001 (*note 3768 Standards conformance::) does not allow this; use `-U LINES' 3769 instead. 3770 3771`-v' 3772`--version' 3773 Output version information and then exit. 3774 3775`-w' 3776`--ignore-all-space' 3777 Ignore white space when comparing lines. *Note White Space::. 3778 3779`-W COLUMNS' 3780`--width=COLUMNS' 3781 Output at most COLUMNS (default 130) print columns per line in 3782 side by side format. *Note Side by Side Format::. 3783 3784`-x PATTERN' 3785`--exclude=PATTERN' 3786 When comparing directories, ignore files and subdirectories whose 3787 basenames match PATTERN. *Note Comparing Directories::. 3788 3789`-X FILE' 3790`--exclude-from=FILE' 3791 When comparing directories, ignore files and subdirectories whose 3792 basenames match any pattern contained in FILE. *Note Comparing 3793 Directories::. 3794 3795`-y' 3796`--side-by-side' 3797 Use the side by side output format. *Note Side by Side Format::. 3798 3799`-Z' 3800`--ignore-trailing-space' 3801 Ignore white space at line end. *Note White Space::. 3802 3803 3804File: diffutils.info-t, Node: Invoking diff3, Next: Invoking patch, Prev: Invoking diff, Up: Top 3805 380614 Invoking `diff3' 3807******************* 3808 3809The `diff3' command compares three files and outputs descriptions of 3810their differences. Its arguments are as follows: 3811 3812 diff3 OPTIONS... MINE OLDER YOURS 3813 3814 The files to compare are MINE, OLDER, and YOURS. At most one of 3815these three file names may be `-', which tells `diff3' to read the 3816standard input for that file. 3817 3818 An exit status of 0 means `diff3' was successful, 1 means some 3819conflicts were found, and 2 means trouble. 3820 3821* Menu: 3822 3823* diff3 Options:: Summary of options to `diff3'. 3824 3825 3826File: diffutils.info-t, Node: diff3 Options, Up: Invoking diff3 3827 382814.1 Options to `diff3' 3829======================= 3830 3831Below is a summary of all of the options that GNU `diff3' accepts. 3832Multiple single letter options (unless they take an argument) can be 3833combined into a single command line argument. 3834 3835`-a' 3836`--text' 3837 Treat all files as text and compare them line-by-line, even if they 3838 do not appear to be text. *Note Binary::. 3839 3840`-A' 3841`--show-all' 3842 Incorporate all unmerged changes from OLDER to YOURS into MINE, 3843 surrounding conflicts with bracket lines. *Note Marking 3844 Conflicts::. 3845 3846`--diff-program=PROGRAM' 3847 Use the compatible comparison program PROGRAM to compare files 3848 instead of `diff'. 3849 3850`-e' 3851`--ed' 3852 Generate an `ed' script that incorporates all the changes from 3853 OLDER to YOURS into MINE. *Note Which Changes::. 3854 3855`-E' 3856`--show-overlap' 3857 Like `-e', except bracket lines from overlapping changes' first 3858 and third files. *Note Marking Conflicts::. With `-E', an 3859 overlapping change looks like this: 3860 3861 <<<<<<< MINE 3862 lines from MINE 3863 ======= 3864 lines from YOURS 3865 >>>>>>> YOURS 3866 3867`--help' 3868 Output a summary of usage and then exit. 3869 3870`-i' 3871 Generate `w' and `q' commands at the end of the `ed' script for 3872 System V compatibility. This option must be combined with one of 3873 the `-AeExX3' options, and may not be combined with `-m'. *Note 3874 Saving the Changed File::. 3875 3876`--label=LABEL' 3877 Use the label LABEL for the brackets output by the `-A', `-E' and 3878 `-X' options. This option may be given up to three times, one for 3879 each input file. The default labels are the names of the input 3880 files. Thus `diff3 --label X --label Y --label Z -m A B C' acts 3881 like `diff3 -m A B C', except that the output looks like it came 3882 from files named `X', `Y' and `Z' rather than from files named 3883 `A', `B' and `C'. *Note Marking Conflicts::. 3884 3885`-m' 3886`--merge' 3887 Apply the edit script to the first file and send the result to 3888 standard output. Unlike piping the output from `diff3' to `ed', 3889 this works even for binary files and incomplete lines. `-A' is 3890 assumed if no edit script option is specified. *Note Bypassing 3891 ed::. 3892 3893`--strip-trailing-cr' 3894 Strip any trailing carriage return at the end of an input line. 3895 *Note Binary::. 3896 3897`-T' 3898`--initial-tab' 3899 Output a tab rather than two spaces before the text of a line in 3900 normal format. This causes the alignment of tabs in the line to 3901 look normal. *Note Tabs::. 3902 3903`-v' 3904`--version' 3905 Output version information and then exit. 3906 3907`-x' 3908`--overlap-only' 3909 Like `-e', except output only the overlapping changes. *Note 3910 Which Changes::. 3911 3912`-X' 3913 Like `-E', except output only the overlapping changes. In other 3914 words, like `-x', except bracket changes as in `-E'. *Note 3915 Marking Conflicts::. 3916 3917`-3' 3918`--easy-only' 3919 Like `-e', except output only the nonoverlapping changes. *Note 3920 Which Changes::. 3921 3922 3923File: diffutils.info-t, Node: Invoking patch, Next: Invoking sdiff, Prev: Invoking diff3, Up: Top 3924 392515 Invoking `patch' 3926******************* 3927 3928Normally `patch' is invoked like this: 3929 3930 patch <PATCHFILE 3931 3932 The full format for invoking `patch' is: 3933 3934 patch OPTIONS... [ORIGFILE [PATCHFILE]] 3935 3936 You can also specify where to read the patch from with the `-i 3937PATCHFILE' or `--input=PATCHFILE' option. If you do not specify 3938PATCHFILE, or if PATCHFILE is `-', `patch' reads the patch (that is, 3939the `diff' output) from the standard input. 3940 3941 If you do not specify an input file on the command line, `patch' 3942tries to intuit from the "leading text" (any text in the patch that 3943comes before the `diff' output) which file to edit. *Note Multiple 3944Patches::. 3945 3946 By default, `patch' replaces the original input file with the 3947patched version, possibly after renaming the original file into a 3948backup file (*note Backup Names::, for a description of how `patch' 3949names backup files). You can also specify where to put the output with 3950the `-o FILE' or `--output=FILE' option; however, do not use this option 3951if FILE is one of the input files. 3952 3953* Menu: 3954 3955* patch Options:: Summary table of options to `patch'. 3956 3957 3958File: diffutils.info-t, Node: patch Options, Up: Invoking patch 3959 396015.1 Options to `patch' 3961======================= 3962 3963Here is a summary of all of the options that GNU `patch' accepts. 3964*Note patch and Tradition::, for which of these options are safe to use 3965in older versions of `patch'. 3966 3967 Multiple single-letter options that do not take an argument can be 3968combined into a single command line argument with only one dash. 3969 3970`-b' 3971`--backup' 3972 Back up the original contents of each file, even if backups would 3973 normally not be made. *Note Backups::. 3974 3975`-B PREFIX' 3976`--prefix=PREFIX' 3977 Prepend PREFIX to backup file names. *Note Backup Names::. 3978 3979`--backup-if-mismatch' 3980 Back up the original contents of each file if the patch does not 3981 exactly match the file. This is the default behavior when not 3982 conforming to POSIX. *Note Backups::. 3983 3984`--binary' 3985 Read and write all files in binary mode, except for standard output 3986 and `/dev/tty'. This option has no effect on POSIX-conforming 3987 systems like GNU/Linux. On systems where this option makes a 3988 difference, the patch should be generated by `diff -a --binary'. 3989 *Note Binary::. 3990 3991`-c' 3992`--context' 3993 Interpret the patch file as a context diff. *Note patch Input::. 3994 3995`-d DIRECTORY' 3996`--directory=DIRECTORY' 3997 Make directory DIRECTORY the current directory for interpreting 3998 both file names in the patch file, and file names given as 3999 arguments to other options. *Note patch Directories::. 4000 4001`-D NAME' 4002`--ifdef=NAME' 4003 Make merged if-then-else output using NAME. *Note If-then-else::. 4004 4005`--dry-run' 4006 Print the results of applying the patches without actually changing 4007 any files. *Note Dry Runs::. 4008 4009`-e' 4010`--ed' 4011 Interpret the patch file as an `ed' script. *Note patch Input::. 4012 4013`-E' 4014`--remove-empty-files' 4015 Remove output files that are empty after the patches have been 4016 applied. *Note Creating and Removing::. 4017 4018`-f' 4019`--force' 4020 Assume that the user knows exactly what he or she is doing, and do 4021 not ask any questions. *Note patch Messages::. 4022 4023`-F LINES' 4024`--fuzz=LINES' 4025 Set the maximum fuzz factor to LINES. *Note Inexact::. 4026 4027`-g NUM' 4028`--get=NUM' 4029 If NUM is positive, get input files from a revision control system 4030 as necessary; if zero, do not get the files; if negative, ask the 4031 user whether to get the files. *Note Revision Control::. 4032 4033`--help' 4034 Output a summary of usage and then exit. 4035 4036`-i PATCHFILE' 4037`--input=PATCHFILE' 4038 Read the patch from PATCHFILE rather than from standard input. 4039 *Note patch Options::. 4040 4041`-l' 4042`--ignore-white-space' 4043 Let any sequence of blanks (spaces or tabs) in the patch file match 4044 any sequence of blanks in the input file. *Note Changed White 4045 Space::. 4046 4047`-n' 4048`--normal' 4049 Interpret the patch file as a normal diff. *Note patch Input::. 4050 4051`-N' 4052`--forward' 4053 Ignore patches that `patch' thinks are reversed or already applied. 4054 See also `-R'. *Note Reversed Patches::. 4055 4056`--no-backup-if-mismatch' 4057 Do not back up the original contents of files. This is the default 4058 behavior when conforming to POSIX. *Note Backups::. 4059 4060`-o FILE' 4061`--output=FILE' 4062 Use FILE as the output file name. *Note patch Options::. 4063 4064`-pNUMBER' 4065`--strip=NUMBER' 4066 Set the file name strip count to NUMBER. *Note patch 4067 Directories::. 4068 4069`--posix' 4070 Conform to POSIX, as if the `POSIXLY_CORRECT' environment variable 4071 had been set. *Note patch and POSIX::. 4072 4073`--quoting-style=WORD' 4074 Use style WORD to quote names in diagnostics, as if the 4075 `QUOTING_STYLE' environment variable had been set to WORD. *Note 4076 patch Quoting Style::. 4077 4078`-r REJECT-FILE' 4079`--reject-file=REJECT-FILE' 4080 Use REJECT-FILE as the reject file name. *Note Reject Names::. 4081 4082`-R' 4083`--reverse' 4084 Assume that this patch was created with the old and new files 4085 swapped. *Note Reversed Patches::. 4086 4087`-s' 4088`--quiet' 4089`--silent' 4090 Work silently unless an error occurs. *Note patch Messages::. 4091 4092`-t' 4093`--batch' 4094 Do not ask any questions. *Note patch Messages::. 4095 4096`-T' 4097`--set-time' 4098 Set the modification and access times of patched files from time 4099 stamps given in context diff headers, assuming that the context 4100 diff headers use local time. *Note Patching Time Stamps::. 4101 4102`-u' 4103`--unified' 4104 Interpret the patch file as a unified diff. *Note patch Input::. 4105 4106`-v' 4107`--version' 4108 Output version information and then exit. 4109 4110`-V BACKUP-STYLE' 4111`--version=control=BACKUP-STYLE' 4112 Select the naming convention for backup file names. *Note Backup 4113 Names::. 4114 4115`--verbose' 4116 Print more diagnostics than usual. *Note patch Messages::. 4117 4118`-x NUMBER' 4119`--debug=NUMBER' 4120 Set internal debugging flags. Of interest only to `patch' 4121 patchers. 4122 4123`-Y PREFIX' 4124`--basename-prefix=PREFIX' 4125 Prepend PREFIX to base names of backup files. *Note Backup 4126 Names::. 4127 4128`-z SUFFIX' 4129`--suffix=SUFFIX' 4130 Use SUFFIX as the backup extension instead of `.orig' or `~'. 4131 *Note Backup Names::. 4132 4133`-Z' 4134`--set-utc' 4135 Set the modification and access times of patched files from time 4136 stamps given in context diff headers, assuming that the context 4137 diff headers use UTC. *Note Patching Time Stamps::. 4138 4139 4140 4141File: diffutils.info-t, Node: Invoking sdiff, Next: Standards conformance, Prev: Invoking patch, Up: Top 4142 414316 Invoking `sdiff' 4144******************* 4145 4146The `sdiff' command merges two files and interactively outputs the 4147results. Its arguments are as follows: 4148 4149 sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE 4150 4151 This merges FROM-FILE with TO-FILE, with output to OUTFILE. If 4152FROM-FILE is a directory and TO-FILE is not, `sdiff' compares the file 4153in FROM-FILE whose file name is that of TO-FILE, and vice versa. 4154FROM-FILE and TO-FILE may not both be directories. 4155 4156 `sdiff' options begin with `-', so normally FROM-FILE and TO-FILE 4157may not begin with `-'. However, `--' as an argument by itself treats 4158the remaining arguments as file names even if they begin with `-'. You 4159may not use `-' as an input file. 4160 4161 `sdiff' without `--output' (`-o') produces a side-by-side 4162difference. This usage is obsolete; use the `--side-by-side' (`-y') 4163option of `diff' instead. 4164 4165 An exit status of 0 means no differences were found, 1 means some 4166differences were found, and 2 means trouble. 4167 4168* Menu: 4169 4170* sdiff Options:: Summary of options to `diff'. 4171 4172 4173File: diffutils.info-t, Node: sdiff Options, Up: Invoking sdiff 4174 417516.1 Options to `sdiff' 4176======================= 4177 4178Below is a summary of all of the options that GNU `sdiff' accepts. 4179Each option has two equivalent names, one of which is a single letter 4180preceded by `-', and the other of which is a long name preceded by 4181`--'. Multiple single letter options (unless they take an argument) 4182can be combined into a single command line argument. Long named 4183options can be abbreviated to any unique prefix of their name. 4184 4185`-a' 4186`--text' 4187 Treat all files as text and compare them line-by-line, even if they 4188 do not appear to be text. *Note Binary::. 4189 4190`-b' 4191`--ignore-space-change' 4192 Ignore changes in amount of white space. *Note White Space::. 4193 4194`-B' 4195`--ignore-blank-lines' 4196 Ignore changes that just insert or delete blank lines. *Note 4197 Blank Lines::. 4198 4199`-d' 4200`--minimal' 4201 Change the algorithm to perhaps find a smaller set of changes. 4202 This makes `sdiff' slower (sometimes much slower). *Note diff 4203 Performance::. 4204 4205`--diff-program=PROGRAM' 4206 Use the compatible comparison program PROGRAM to compare files 4207 instead of `diff'. 4208 4209`-E' 4210`--ignore-tab-expansion' 4211 Ignore changes due to tab expansion. *Note White Space::. 4212 4213`--help' 4214 Output a summary of usage and then exit. 4215 4216`-i' 4217`--ignore-case' 4218 Ignore changes in case; consider upper- and lower-case to be the 4219 same. *Note Case Folding::. 4220 4221`-I REGEXP' 4222`--ignore-matching-lines=REGEXP' 4223 Ignore changes that just insert or delete lines that match REGEXP. 4224 *Note Specified Lines::. 4225 4226`-l' 4227`--left-column' 4228 Print only the left column of two common lines. *Note Side by 4229 Side Format::. 4230 4231`-o FILE' 4232`--output=FILE' 4233 Put merged output into FILE. This option is required for merging. 4234 4235`-s' 4236`--suppress-common-lines' 4237 Do not print common lines. *Note Side by Side Format::. 4238 4239`--speed-large-files' 4240 Use heuristics to speed handling of large files that have numerous 4241 scattered small changes. *Note diff Performance::. 4242 4243`--strip-trailing-cr' 4244 Strip any trailing carriage return at the end of an input line. 4245 *Note Binary::. 4246 4247`-t' 4248`--expand-tabs' 4249 Expand tabs to spaces in the output, to preserve the alignment of 4250 tabs in the input files. *Note Tabs::. 4251 4252`--tabsize=COLUMNS' 4253 Assume that tab stops are set every COLUMNS (default 8) print 4254 columns. *Note Tabs::. 4255 4256`-v' 4257`--version' 4258 Output version information and then exit. 4259 4260`-w COLUMNS' 4261`--width=COLUMNS' 4262 Output at most COLUMNS (default 130) print columns per line. 4263 *Note Side by Side Format::. Note that for historical reasons, 4264 this option is `-W' in `diff', `-w' in `sdiff'. 4265 4266`-W' 4267`--ignore-all-space' 4268 Ignore white space when comparing lines. *Note White Space::. 4269 Note that for historical reasons, this option is `-w' in `diff', 4270 `-W' in `sdiff'. 4271 4272`-Z' 4273`--ignore-trailing-space' 4274 Ignore white space at line end. *Note White Space::. 4275 4276 4277File: diffutils.info-t, Node: Standards conformance, Next: Projects, Prev: Invoking sdiff, Up: Top 4278 427917 Standards conformance 4280************************ 4281 4282In a few cases, the GNU utilities' default behavior is incompatible 4283with the POSIX standard. To suppress these incompatibilities, define 4284the `POSIXLY_CORRECT' environment variable. Unless you are checking 4285for POSIX conformance, you probably do not need to define 4286`POSIXLY_CORRECT'. 4287 4288 Normally options and operands can appear in any order, and programs 4289act as if all the options appear before any operands. For example, 4290`diff lao tzu -C 2' acts like `diff -C 2 lao tzu', since `2' is an 4291option-argument of `-C'. However, if the `POSIXLY_CORRECT' environment 4292variable is set, options must appear before operands, unless otherwise 4293specified for a particular command. 4294 4295 Newer versions of POSIX are occasionally incompatible with older 4296versions. For example, older versions of POSIX allowed the command 4297`diff -c -10' to have the same meaning as `diff -C 10', but POSIX 42981003.1-2001 `diff' no longer allows digit-string options like `-10'. 4299 4300 The GNU utilities normally conform to the version of POSIX that is 4301standard for your system. To cause them to conform to a different 4302version of POSIX, define the `_POSIX2_VERSION' environment variable to 4303a value of the form YYYYMM specifying the year and month the standard 4304was adopted. Two values are currently supported for `_POSIX2_VERSION': 4305`199209' stands for POSIX 1003.2-1992, and `200112' stands for POSIX 43061003.1-2001. For example, if you are running older software that 4307assumes an older version of POSIX and uses `diff -c -10', you can work 4308around the compatibility problems by setting `_POSIX2_VERSION=199209' 4309in your environment. 4310 4311 4312File: diffutils.info-t, Node: Projects, Next: Copying This Manual, Prev: Standards conformance, Up: Top 4313 431418 Future Projects 4315****************** 4316 4317Here are some ideas for improving GNU `diff' and `patch'. The GNU 4318project has identified some improvements as potential programming 4319projects for volunteers. You can also help by reporting any bugs that 4320you find. 4321 4322 If you are a programmer and would like to contribute something to the 4323GNU project, please consider volunteering for one of these projects. 4324If you are seriously contemplating work, please write to <gvc@gnu.org> 4325to coordinate with other volunteers. 4326 4327* Menu: 4328 4329* Shortcomings:: Suggested projects for improvements. 4330* Bugs:: Reporting bugs. 4331 4332 4333File: diffutils.info-t, Node: Shortcomings, Next: Bugs, Up: Projects 4334 433518.1 Suggested Projects for Improving GNU `diff' and `patch' 4336============================================================ 4337 4338One should be able to use GNU `diff' to generate a patch from any pair 4339of directory trees, and given the patch and a copy of one such tree, 4340use `patch' to generate a faithful copy of the other. Unfortunately, 4341some changes to directory trees cannot be expressed using current patch 4342formats; also, `patch' does not handle some of the existing formats. 4343These shortcomings motivate the following suggested projects. 4344 4345* Menu: 4346 4347* Internationalization:: Handling multibyte and varying-width characters. 4348* Changing Structure:: Handling changes to the directory structure. 4349* Special Files:: Handling symbolic links, device special files, etc. 4350* Unusual File Names:: Handling file names that contain unusual characters. 4351* Time Stamp Order:: Outputting diffs in time stamp order. 4352* Ignoring Changes:: Ignoring certain changes while showing others. 4353* Speedups:: Improving performance. 4354 4355 4356File: diffutils.info-t, Node: Internationalization, Next: Changing Structure, Up: Shortcomings 4357 435818.1.1 Handling Multibyte and Varying-Width Characters 4359------------------------------------------------------ 4360 4361`diff', `diff3' and `sdiff' treat each line of input as a string of 4362unibyte characters. This can mishandle multibyte characters in some 4363cases. For example, when asked to ignore spaces, `diff' does not 4364properly ignore a multibyte space character. 4365 4366 Also, `diff' currently assumes that each byte is one column wide, 4367and this assumption is incorrect in some locales, e.g., locales that 4368use UTF-8 encoding. This causes problems with the `-y' or 4369`--side-by-side' option of `diff'. 4370 4371 These problems need to be fixed without unduly affecting the 4372performance of the utilities in unibyte environments. 4373 4374 The IBM GNU/Linux Technology Center Internationalization Team has 4375proposed patches to support internationalized `diff' 4376(http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz). 4377Unfortunately, these patches are incomplete and are to an older version 4378of `diff', so more work needs to be done in this area. 4379 4380 4381File: diffutils.info-t, Node: Changing Structure, Next: Special Files, Prev: Internationalization, Up: Shortcomings 4382 438318.1.2 Handling Changes to the Directory Structure 4384-------------------------------------------------- 4385 4386`diff' and `patch' do not handle some changes to directory structure. 4387For example, suppose one directory tree contains a directory named `D' 4388with some subsidiary files, and another contains a file with the same 4389name `D'. `diff -r' does not output enough information for `patch' to 4390transform the directory subtree into the file. 4391 4392 There should be a way to specify that a file has been removed without 4393having to include its entire contents in the patch file. There should 4394also be a way to tell `patch' that a file was renamed, even if there is 4395no way for `diff' to generate such information. There should be a way 4396to tell `patch' that a file's time stamp has changed, even if its 4397contents have not changed. 4398 4399 These problems can be fixed by extending the `diff' output format to 4400represent changes in directory structure, and extending `patch' to 4401understand these extensions. 4402 4403 4404File: diffutils.info-t, Node: Special Files, Next: Unusual File Names, Prev: Changing Structure, Up: Shortcomings 4405 440618.1.3 Files that are Neither Directories Nor Regular Files 4407----------------------------------------------------------- 4408 4409Some files are neither directories nor regular files: they are unusual 4410files like symbolic links, device special files, named pipes, and 4411sockets. Currently, `diff' treats symbolic links as if they were the 4412pointed-to files, except that a recursive `diff' reports an error if it 4413detects infinite loops of symbolic links (e.g., symbolic links to 4414`..'). `diff' treats other special files like regular files if they 4415are specified at the top level, but simply reports their presence when 4416comparing directories. This means that `patch' cannot represent 4417changes to such files. For example, if you change which file a 4418symbolic link points to, `diff' outputs the difference between the two 4419files, instead of the change to the symbolic link. 4420 4421 `diff' should optionally report changes to special files specially, 4422and `patch' should be extended to understand these extensions. 4423 4424 4425File: diffutils.info-t, Node: Unusual File Names, Next: Time Stamp Order, Prev: Special Files, Up: Shortcomings 4426 442718.1.4 File Names that Contain Unusual Characters 4428------------------------------------------------- 4429 4430When a file name contains an unusual character like a newline or white 4431space, `diff -r' generates a patch that `patch' cannot parse. The 4432problem is with format of `diff' output, not just with `patch', because 4433with odd enough file names one can cause `diff' to generate a patch 4434that is syntactically correct but patches the wrong files. The format 4435of `diff' output should be extended to handle all possible file names. 4436 4437 4438File: diffutils.info-t, Node: Time Stamp Order, Next: Ignoring Changes, Prev: Unusual File Names, Up: Shortcomings 4439 444018.1.5 Outputting Diffs in Time Stamp Order 4441------------------------------------------- 4442 4443Applying `patch' to a multiple-file diff can result in files whose time 4444stamps are out of order. GNU `patch' has options to restore the time 4445stamps of the updated files (*note Patching Time Stamps::), but 4446sometimes it is useful to generate a patch that works even if the 4447recipient does not have GNU patch, or does not use these options. One 4448way to do this would be to implement a `diff' option to output diffs in 4449time stamp order. 4450 4451 4452File: diffutils.info-t, Node: Ignoring Changes, Next: Speedups, Prev: Time Stamp Order, Up: Shortcomings 4453 445418.1.6 Ignoring Certain Changes 4455------------------------------- 4456 4457It would be nice to have a feature for specifying two strings, one in 4458FROM-FILE and one in TO-FILE, which should be considered to match. 4459Thus, if the two strings are `foo' and `bar', then if two lines differ 4460only in that `foo' in file 1 corresponds to `bar' in file 2, the lines 4461are treated as identical. 4462 4463 It is not clear how general this feature can or should be, or what 4464syntax should be used for it. 4465 4466 A partial substitute is to filter one or both files before comparing, 4467e.g.: 4468 4469 sed 's/foo/bar/g' file1 | diff - file2 4470 4471 However, this outputs the filtered text, not the original. 4472 4473 4474File: diffutils.info-t, Node: Speedups, Prev: Ignoring Changes, Up: Shortcomings 4475 447618.1.7 Improving Performance 4477---------------------------- 4478 4479When comparing two large directory structures, one of which was 4480originally copied from the other with time stamps preserved (e.g., with 4481`cp -pR'), it would greatly improve performance if an option told 4482`diff' to assume that two files with the same size and time stamps have 4483the same content. *Note diff Performance::. 4484 4485 4486File: diffutils.info-t, Node: Bugs, Prev: Shortcomings, Up: Projects 4487 448818.2 Reporting Bugs 4489=================== 4490 4491If you think you have found a bug in GNU `cmp', `diff', `diff3', or 4492`sdiff', please report it by electronic mail to the GNU utilities bug 4493report mailing list 4494(http://mail.gnu.org/mailman/listinfo/bug-gnu-utils) 4495<bug-gnu-utils@gnu.org>. Please send bug reports for GNU `patch' to 4496<bug-patch@gnu.org>. Send as precise a description of the problem as 4497you can, including the output of the `--version' option and sample 4498input files that produce the bug, if applicable. If you have a 4499nontrivial fix for the bug, please send it as well. If you have a 4500patch, please send it too. It may simplify the maintainer's job if the 4501patch is relative to a recent test release, which you can find in the 4502directory `ftp://alpha.gnu.org/gnu/diffutils/'. 4503 4504 4505File: diffutils.info-t, Node: Copying This Manual, Next: Translations, Prev: Projects, Up: Top 4506 4507Appendix A Copying This Manual 4508****************************** 4509 4510 Version 1.3, 3 November 2008 4511 4512 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 4513 `http://fsf.org/' 4514 4515 Everyone is permitted to copy and distribute verbatim copies 4516 of this license document, but changing it is not allowed. 4517 4518 0. PREAMBLE 4519 4520 The purpose of this License is to make a manual, textbook, or other 4521 functional and useful document "free" in the sense of freedom: to 4522 assure everyone the effective freedom to copy and redistribute it, 4523 with or without modifying it, either commercially or 4524 noncommercially. Secondarily, this License preserves for the 4525 author and publisher a way to get credit for their work, while not 4526 being considered responsible for modifications made by others. 4527 4528 This License is a kind of "copyleft", which means that derivative 4529 works of the document must themselves be free in the same sense. 4530 It complements the GNU General Public License, which is a copyleft 4531 license designed for free software. 4532 4533 We have designed this License in order to use it for manuals for 4534 free software, because free software needs free documentation: a 4535 free program should come with manuals providing the same freedoms 4536 that the software does. But this License is not limited to 4537 software manuals; it can be used for any textual work, regardless 4538 of subject matter or whether it is published as a printed book. 4539 We recommend this License principally for works whose purpose is 4540 instruction or reference. 4541 4542 1. APPLICABILITY AND DEFINITIONS 4543 4544 This License applies to any manual or other work, in any medium, 4545 that contains a notice placed by the copyright holder saying it 4546 can be distributed under the terms of this License. Such a notice 4547 grants a world-wide, royalty-free license, unlimited in duration, 4548 to use that work under the conditions stated herein. The 4549 "Document", below, refers to any such manual or work. Any member 4550 of the public is a licensee, and is addressed as "you". You 4551 accept the license if you copy, modify or distribute the work in a 4552 way requiring permission under copyright law. 4553 4554 A "Modified Version" of the Document means any work containing the 4555 Document or a portion of it, either copied verbatim, or with 4556 modifications and/or translated into another language. 4557 4558 A "Secondary Section" is a named appendix or a front-matter section 4559 of the Document that deals exclusively with the relationship of the 4560 publishers or authors of the Document to the Document's overall 4561 subject (or to related matters) and contains nothing that could 4562 fall directly within that overall subject. (Thus, if the Document 4563 is in part a textbook of mathematics, a Secondary Section may not 4564 explain any mathematics.) The relationship could be a matter of 4565 historical connection with the subject or with related matters, or 4566 of legal, commercial, philosophical, ethical or political position 4567 regarding them. 4568 4569 The "Invariant Sections" are certain Secondary Sections whose 4570 titles are designated, as being those of Invariant Sections, in 4571 the notice that says that the Document is released under this 4572 License. If a section does not fit the above definition of 4573 Secondary then it is not allowed to be designated as Invariant. 4574 The Document may contain zero Invariant Sections. If the Document 4575 does not identify any Invariant Sections then there are none. 4576 4577 The "Cover Texts" are certain short passages of text that are 4578 listed, as Front-Cover Texts or Back-Cover Texts, in the notice 4579 that says that the Document is released under this License. A 4580 Front-Cover Text may be at most 5 words, and a Back-Cover Text may 4581 be at most 25 words. 4582 4583 A "Transparent" copy of the Document means a machine-readable copy, 4584 represented in a format whose specification is available to the 4585 general public, that is suitable for revising the document 4586 straightforwardly with generic text editors or (for images 4587 composed of pixels) generic paint programs or (for drawings) some 4588 widely available drawing editor, and that is suitable for input to 4589 text formatters or for automatic translation to a variety of 4590 formats suitable for input to text formatters. A copy made in an 4591 otherwise Transparent file format whose markup, or absence of 4592 markup, has been arranged to thwart or discourage subsequent 4593 modification by readers is not Transparent. An image format is 4594 not Transparent if used for any substantial amount of text. A 4595 copy that is not "Transparent" is called "Opaque". 4596 4597 Examples of suitable formats for Transparent copies include plain 4598 ASCII without markup, Texinfo input format, LaTeX input format, 4599 SGML or XML using a publicly available DTD, and 4600 standard-conforming simple HTML, PostScript or PDF designed for 4601 human modification. Examples of transparent image formats include 4602 PNG, XCF and JPG. Opaque formats include proprietary formats that 4603 can be read and edited only by proprietary word processors, SGML or 4604 XML for which the DTD and/or processing tools are not generally 4605 available, and the machine-generated HTML, PostScript or PDF 4606 produced by some word processors for output purposes only. 4607 4608 The "Title Page" means, for a printed book, the title page itself, 4609 plus such following pages as are needed to hold, legibly, the 4610 material this License requires to appear in the title page. For 4611 works in formats which do not have any title page as such, "Title 4612 Page" means the text near the most prominent appearance of the 4613 work's title, preceding the beginning of the body of the text. 4614 4615 The "publisher" means any person or entity that distributes copies 4616 of the Document to the public. 4617 4618 A section "Entitled XYZ" means a named subunit of the Document 4619 whose title either is precisely XYZ or contains XYZ in parentheses 4620 following text that translates XYZ in another language. (Here XYZ 4621 stands for a specific section name mentioned below, such as 4622 "Acknowledgements", "Dedications", "Endorsements", or "History".) 4623 To "Preserve the Title" of such a section when you modify the 4624 Document means that it remains a section "Entitled XYZ" according 4625 to this definition. 4626 4627 The Document may include Warranty Disclaimers next to the notice 4628 which states that this License applies to the Document. These 4629 Warranty Disclaimers are considered to be included by reference in 4630 this License, but only as regards disclaiming warranties: any other 4631 implication that these Warranty Disclaimers may have is void and 4632 has no effect on the meaning of this License. 4633 4634 2. VERBATIM COPYING 4635 4636 You may copy and distribute the Document in any medium, either 4637 commercially or noncommercially, provided that this License, the 4638 copyright notices, and the license notice saying this License 4639 applies to the Document are reproduced in all copies, and that you 4640 add no other conditions whatsoever to those of this License. You 4641 may not use technical measures to obstruct or control the reading 4642 or further copying of the copies you make or distribute. However, 4643 you may accept compensation in exchange for copies. If you 4644 distribute a large enough number of copies you must also follow 4645 the conditions in section 3. 4646 4647 You may also lend copies, under the same conditions stated above, 4648 and you may publicly display copies. 4649 4650 3. COPYING IN QUANTITY 4651 4652 If you publish printed copies (or copies in media that commonly 4653 have printed covers) of the Document, numbering more than 100, and 4654 the Document's license notice requires Cover Texts, you must 4655 enclose the copies in covers that carry, clearly and legibly, all 4656 these Cover Texts: Front-Cover Texts on the front cover, and 4657 Back-Cover Texts on the back cover. Both covers must also clearly 4658 and legibly identify you as the publisher of these copies. The 4659 front cover must present the full title with all words of the 4660 title equally prominent and visible. You may add other material 4661 on the covers in addition. Copying with changes limited to the 4662 covers, as long as they preserve the title of the Document and 4663 satisfy these conditions, can be treated as verbatim copying in 4664 other respects. 4665 4666 If the required texts for either cover are too voluminous to fit 4667 legibly, you should put the first ones listed (as many as fit 4668 reasonably) on the actual cover, and continue the rest onto 4669 adjacent pages. 4670 4671 If you publish or distribute Opaque copies of the Document 4672 numbering more than 100, you must either include a 4673 machine-readable Transparent copy along with each Opaque copy, or 4674 state in or with each Opaque copy a computer-network location from 4675 which the general network-using public has access to download 4676 using public-standard network protocols a complete Transparent 4677 copy of the Document, free of added material. If you use the 4678 latter option, you must take reasonably prudent steps, when you 4679 begin distribution of Opaque copies in quantity, to ensure that 4680 this Transparent copy will remain thus accessible at the stated 4681 location until at least one year after the last time you 4682 distribute an Opaque copy (directly or through your agents or 4683 retailers) of that edition to the public. 4684 4685 It is requested, but not required, that you contact the authors of 4686 the Document well before redistributing any large number of 4687 copies, to give them a chance to provide you with an updated 4688 version of the Document. 4689 4690 4. MODIFICATIONS 4691 4692 You may copy and distribute a Modified Version of the Document 4693 under the conditions of sections 2 and 3 above, provided that you 4694 release the Modified Version under precisely this License, with 4695 the Modified Version filling the role of the Document, thus 4696 licensing distribution and modification of the Modified Version to 4697 whoever possesses a copy of it. In addition, you must do these 4698 things in the Modified Version: 4699 4700 A. Use in the Title Page (and on the covers, if any) a title 4701 distinct from that of the Document, and from those of 4702 previous versions (which should, if there were any, be listed 4703 in the History section of the Document). You may use the 4704 same title as a previous version if the original publisher of 4705 that version gives permission. 4706 4707 B. List on the Title Page, as authors, one or more persons or 4708 entities responsible for authorship of the modifications in 4709 the Modified Version, together with at least five of the 4710 principal authors of the Document (all of its principal 4711 authors, if it has fewer than five), unless they release you 4712 from this requirement. 4713 4714 C. State on the Title page the name of the publisher of the 4715 Modified Version, as the publisher. 4716 4717 D. Preserve all the copyright notices of the Document. 4718 4719 E. Add an appropriate copyright notice for your modifications 4720 adjacent to the other copyright notices. 4721 4722 F. Include, immediately after the copyright notices, a license 4723 notice giving the public permission to use the Modified 4724 Version under the terms of this License, in the form shown in 4725 the Addendum below. 4726 4727 G. Preserve in that license notice the full lists of Invariant 4728 Sections and required Cover Texts given in the Document's 4729 license notice. 4730 4731 H. Include an unaltered copy of this License. 4732 4733 I. Preserve the section Entitled "History", Preserve its Title, 4734 and add to it an item stating at least the title, year, new 4735 authors, and publisher of the Modified Version as given on 4736 the Title Page. If there is no section Entitled "History" in 4737 the Document, create one stating the title, year, authors, 4738 and publisher of the Document as given on its Title Page, 4739 then add an item describing the Modified Version as stated in 4740 the previous sentence. 4741 4742 J. Preserve the network location, if any, given in the Document 4743 for public access to a Transparent copy of the Document, and 4744 likewise the network locations given in the Document for 4745 previous versions it was based on. These may be placed in 4746 the "History" section. You may omit a network location for a 4747 work that was published at least four years before the 4748 Document itself, or if the original publisher of the version 4749 it refers to gives permission. 4750 4751 K. For any section Entitled "Acknowledgements" or "Dedications", 4752 Preserve the Title of the section, and preserve in the 4753 section all the substance and tone of each of the contributor 4754 acknowledgements and/or dedications given therein. 4755 4756 L. Preserve all the Invariant Sections of the Document, 4757 unaltered in their text and in their titles. Section numbers 4758 or the equivalent are not considered part of the section 4759 titles. 4760 4761 M. Delete any section Entitled "Endorsements". Such a section 4762 may not be included in the Modified Version. 4763 4764 N. Do not retitle any existing section to be Entitled 4765 "Endorsements" or to conflict in title with any Invariant 4766 Section. 4767 4768 O. Preserve any Warranty Disclaimers. 4769 4770 If the Modified Version includes new front-matter sections or 4771 appendices that qualify as Secondary Sections and contain no 4772 material copied from the Document, you may at your option 4773 designate some or all of these sections as invariant. To do this, 4774 add their titles to the list of Invariant Sections in the Modified 4775 Version's license notice. These titles must be distinct from any 4776 other section titles. 4777 4778 You may add a section Entitled "Endorsements", provided it contains 4779 nothing but endorsements of your Modified Version by various 4780 parties--for example, statements of peer review or that the text 4781 has been approved by an organization as the authoritative 4782 definition of a standard. 4783 4784 You may add a passage of up to five words as a Front-Cover Text, 4785 and a passage of up to 25 words as a Back-Cover Text, to the end 4786 of the list of Cover Texts in the Modified Version. Only one 4787 passage of Front-Cover Text and one of Back-Cover Text may be 4788 added by (or through arrangements made by) any one entity. If the 4789 Document already includes a cover text for the same cover, 4790 previously added by you or by arrangement made by the same entity 4791 you are acting on behalf of, you may not add another; but you may 4792 replace the old one, on explicit permission from the previous 4793 publisher that added the old one. 4794 4795 The author(s) and publisher(s) of the Document do not by this 4796 License give permission to use their names for publicity for or to 4797 assert or imply endorsement of any Modified Version. 4798 4799 5. COMBINING DOCUMENTS 4800 4801 You may combine the Document with other documents released under 4802 this License, under the terms defined in section 4 above for 4803 modified versions, provided that you include in the combination 4804 all of the Invariant Sections of all of the original documents, 4805 unmodified, and list them all as Invariant Sections of your 4806 combined work in its license notice, and that you preserve all 4807 their Warranty Disclaimers. 4808 4809 The combined work need only contain one copy of this License, and 4810 multiple identical Invariant Sections may be replaced with a single 4811 copy. If there are multiple Invariant Sections with the same name 4812 but different contents, make the title of each such section unique 4813 by adding at the end of it, in parentheses, the name of the 4814 original author or publisher of that section if known, or else a 4815 unique number. Make the same adjustment to the section titles in 4816 the list of Invariant Sections in the license notice of the 4817 combined work. 4818 4819 In the combination, you must combine any sections Entitled 4820 "History" in the various original documents, forming one section 4821 Entitled "History"; likewise combine any sections Entitled 4822 "Acknowledgements", and any sections Entitled "Dedications". You 4823 must delete all sections Entitled "Endorsements." 4824 4825 6. COLLECTIONS OF DOCUMENTS 4826 4827 You may make a collection consisting of the Document and other 4828 documents released under this License, and replace the individual 4829 copies of this License in the various documents with a single copy 4830 that is included in the collection, provided that you follow the 4831 rules of this License for verbatim copying of each of the 4832 documents in all other respects. 4833 4834 You may extract a single document from such a collection, and 4835 distribute it individually under this License, provided you insert 4836 a copy of this License into the extracted document, and follow 4837 this License in all other respects regarding verbatim copying of 4838 that document. 4839 4840 7. AGGREGATION WITH INDEPENDENT WORKS 4841 4842 A compilation of the Document or its derivatives with other 4843 separate and independent documents or works, in or on a volume of 4844 a storage or distribution medium, is called an "aggregate" if the 4845 copyright resulting from the compilation is not used to limit the 4846 legal rights of the compilation's users beyond what the individual 4847 works permit. When the Document is included in an aggregate, this 4848 License does not apply to the other works in the aggregate which 4849 are not themselves derivative works of the Document. 4850 4851 If the Cover Text requirement of section 3 is applicable to these 4852 copies of the Document, then if the Document is less than one half 4853 of the entire aggregate, the Document's Cover Texts may be placed 4854 on covers that bracket the Document within the aggregate, or the 4855 electronic equivalent of covers if the Document is in electronic 4856 form. Otherwise they must appear on printed covers that bracket 4857 the whole aggregate. 4858 4859 8. TRANSLATION 4860 4861 Translation is considered a kind of modification, so you may 4862 distribute translations of the Document under the terms of section 4863 4. Replacing Invariant Sections with translations requires special 4864 permission from their copyright holders, but you may include 4865 translations of some or all Invariant Sections in addition to the 4866 original versions of these Invariant Sections. You may include a 4867 translation of this License, and all the license notices in the 4868 Document, and any Warranty Disclaimers, provided that you also 4869 include the original English version of this License and the 4870 original versions of those notices and disclaimers. In case of a 4871 disagreement between the translation and the original version of 4872 this License or a notice or disclaimer, the original version will 4873 prevail. 4874 4875 If a section in the Document is Entitled "Acknowledgements", 4876 "Dedications", or "History", the requirement (section 4) to 4877 Preserve its Title (section 1) will typically require changing the 4878 actual title. 4879 4880 9. TERMINATION 4881 4882 You may not copy, modify, sublicense, or distribute the Document 4883 except as expressly provided under this License. Any attempt 4884 otherwise to copy, modify, sublicense, or distribute it is void, 4885 and will automatically terminate your rights under this License. 4886 4887 However, if you cease all violation of this License, then your 4888 license from a particular copyright holder is reinstated (a) 4889 provisionally, unless and until the copyright holder explicitly 4890 and finally terminates your license, and (b) permanently, if the 4891 copyright holder fails to notify you of the violation by some 4892 reasonable means prior to 60 days after the cessation. 4893 4894 Moreover, your license from a particular copyright holder is 4895 reinstated permanently if the copyright holder notifies you of the 4896 violation by some reasonable means, this is the first time you have 4897 received notice of violation of this License (for any work) from 4898 that copyright holder, and you cure the violation prior to 30 days 4899 after your receipt of the notice. 4900 4901 Termination of your rights under this section does not terminate 4902 the licenses of parties who have received copies or rights from 4903 you under this License. If your rights have been terminated and 4904 not permanently reinstated, receipt of a copy of some or all of 4905 the same material does not give you any rights to use it. 4906 4907 10. FUTURE REVISIONS OF THIS LICENSE 4908 4909 The Free Software Foundation may publish new, revised versions of 4910 the GNU Free Documentation License from time to time. Such new 4911 versions will be similar in spirit to the present version, but may 4912 differ in detail to address new problems or concerns. See 4913 `http://www.gnu.org/copyleft/'. 4914 4915 Each version of the License is given a distinguishing version 4916 number. If the Document specifies that a particular numbered 4917 version of this License "or any later version" applies to it, you 4918 have the option of following the terms and conditions either of 4919 that specified version or of any later version that has been 4920 published (not as a draft) by the Free Software Foundation. If 4921 the Document does not specify a version number of this License, 4922 you may choose any version ever published (not as a draft) by the 4923 Free Software Foundation. If the Document specifies that a proxy 4924 can decide which future versions of this License can be used, that 4925 proxy's public statement of acceptance of a version permanently 4926 authorizes you to choose that version for the Document. 4927 4928 11. RELICENSING 4929 4930 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any 4931 World Wide Web server that publishes copyrightable works and also 4932 provides prominent facilities for anybody to edit those works. A 4933 public wiki that anybody can edit is an example of such a server. 4934 A "Massive Multiauthor Collaboration" (or "MMC") contained in the 4935 site means any set of copyrightable works thus published on the MMC 4936 site. 4937 4938 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 4939 license published by Creative Commons Corporation, a not-for-profit 4940 corporation with a principal place of business in San Francisco, 4941 California, as well as future copyleft versions of that license 4942 published by that same organization. 4943 4944 "Incorporate" means to publish or republish a Document, in whole or 4945 in part, as part of another Document. 4946 4947 An MMC is "eligible for relicensing" if it is licensed under this 4948 License, and if all works that were first published under this 4949 License somewhere other than this MMC, and subsequently 4950 incorporated in whole or in part into the MMC, (1) had no cover 4951 texts or invariant sections, and (2) were thus incorporated prior 4952 to November 1, 2008. 4953 4954 The operator of an MMC Site may republish an MMC contained in the 4955 site under CC-BY-SA on the same site at any time before August 1, 4956 2009, provided the MMC is eligible for relicensing. 4957 4958 4959ADDENDUM: How to use this License for your documents 4960==================================================== 4961 4962To use this License in a document you have written, include a copy of 4963the License in the document and put the following copyright and license 4964notices just after the title page: 4965 4966 Copyright (C) YEAR YOUR NAME. 4967 Permission is granted to copy, distribute and/or modify this document 4968 under the terms of the GNU Free Documentation License, Version 1.3 4969 or any later version published by the Free Software Foundation; 4970 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 4971 Texts. A copy of the license is included in the section entitled ``GNU 4972 Free Documentation License''. 4973 4974 If you have Invariant Sections, Front-Cover Texts and Back-Cover 4975Texts, replace the "with...Texts." line with this: 4976 4977 with the Invariant Sections being LIST THEIR TITLES, with 4978 the Front-Cover Texts being LIST, and with the Back-Cover Texts 4979 being LIST. 4980 4981 If you have Invariant Sections without Cover Texts, or some other 4982combination of the three, merge those two alternatives to suit the 4983situation. 4984 4985 If your document contains nontrivial examples of program code, we 4986recommend releasing these examples in parallel under your choice of 4987free software license, such as the GNU General Public License, to 4988permit their use in free software. 4989 4990 4991File: diffutils.info-t, Node: Translations, Next: Index, Prev: Copying This Manual, Up: Top 4992 4993Appendix B Translations of This Manual 4994************************************** 4995 4996Nishio Futoshi of the GNUjdoc project has prepared a Japanese 4997translation of this manual. Its most recent version can be found at 4998`http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/'. 4999 5000 5001File: diffutils.info-t, Node: Index, Prev: Translations, Up: Top 5002 5003Appendix C Index 5004**************** 5005 5006[index] 5007* Menu: 5008 5009* ! output format: Context. (line 6) 5010* +- output format: Unified Format. (line 6) 5011* < output format: Normal. (line 6) 5012* <<<<<<< for marking conflicts: Marking Conflicts. (line 6) 5013* _POSIX2_VERSION: Standards conformance. 5014 (line 24) 5015* aligning tab stops: Tabs. (line 6) 5016* alternate file names: Alternate Names. (line 6) 5017* backup file names: Backup Names. (line 6) 5018* backup file strategy: Backups. (line 6) 5019* binary file diff: Binary. (line 6) 5020* blank and tab difference suppression: White Space. (line 6) 5021* blank line difference suppression: Blank Lines. (line 6) 5022* brief difference reports: Brief. (line 6) 5023* bug reports: Bugs. (line 6) 5024* C function headings: C Function Headings. (line 6) 5025* C if-then-else output format: If-then-else. (line 6) 5026* case difference suppression: Case Folding. (line 6) 5027* ClearCase: Revision Control. (line 6) 5028* cmp invocation: Invoking cmp. (line 6) 5029* cmp options: cmp Options. (line 6) 5030* columnar output: Side by Side. (line 6) 5031* common mistakes with patches: Avoiding Common Mistakes. 5032 (line 6) 5033* comparing three files: Comparing Three Files. 5034 (line 6) 5035* conflict: diff3 Merging. (line 26) 5036* conflict marking: Marking Conflicts. (line 6) 5037* context output format: Context. (line 6) 5038* creating files: Creating and Removing. 5039 (line 6) 5040* diagnostics from patch: patch Messages. (line 6) 5041* diff invocation: Invoking diff. (line 6) 5042* diff merging: Interactive Merging. (line 6) 5043* diff options: diff Options. (line 6) 5044* diff sample input: Sample diff Input. (line 6) 5045* diff3 hunks: diff3 Hunks. (line 6) 5046* diff3 invocation: Invoking diff3. (line 6) 5047* diff3 options: diff3 Options. (line 6) 5048* diff3 sample input: Sample diff3 Input. (line 6) 5049* directories and patch: patch Directories. (line 6) 5050* directory structure changes: Changing Structure. (line 6) 5051* dry runs for patch: Dry Runs. (line 6) 5052* ed script output format: ed Scripts. (line 6) 5053* EDITOR: Merge Commands. (line 50) 5054* empty files, removing: Creating and Removing. 5055 (line 6) 5056* exabyte, definition of: cmp Options. (line 109) 5057* exbibyte, definition of: cmp Options. (line 113) 5058* file name alternates: Alternate Names. (line 6) 5059* file names with unusual characters: Unusual File Names. (line 6) 5060* format of diff output: Output Formats. (line 6) 5061* format of diff3 output: Comparing Three Files. 5062 (line 6) 5063* formats for if-then-else line groups: Line Group Formats. (line 6) 5064* forward ed script output format: Forward ed. (line 6) 5065* full lines: Incomplete Lines. (line 6) 5066* function headings, C: C Function Headings. (line 6) 5067* fuzz factor when patching: Inexact. (line 6) 5068* gibibyte, definition of: cmp Options. (line 92) 5069* gigabyte, definition of: cmp Options. (line 88) 5070* headings: Sections. (line 6) 5071* hunks: Hunks. (line 6) 5072* hunks for diff3: diff3 Hunks. (line 6) 5073* if-then-else output format: If-then-else. (line 6) 5074* ifdef output format: If-then-else. (line 6) 5075* imperfect patch application: Imperfect. (line 6) 5076* incomplete line merging: Merging Incomplete Lines. 5077 (line 6) 5078* incomplete lines: Incomplete Lines. (line 6) 5079* inexact patches: Inexact. (line 6) 5080* inhibit messages from patch: More or Fewer Messages. 5081 (line 6) 5082* interactive merging: Interactive Merging. (line 6) 5083* introduction: Comparison. (line 6) 5084* intuiting file names from patches: Multiple Patches. (line 6) 5085* invoking cmp: Invoking cmp. (line 6) 5086* invoking diff: Invoking diff. (line 6) 5087* invoking diff3: Invoking diff3. (line 6) 5088* invoking patch: Invoking patch. (line 6) 5089* invoking sdiff: Invoking sdiff. (line 6) 5090* keyboard input to patch: patch and Keyboard Input. 5091 (line 6) 5092* kibibyte, definition of: cmp Options. (line 76) 5093* kilobyte, definition of: cmp Options. (line 71) 5094* LC_COLLATE: Comparing Directories. 5095 (line 6) 5096* LC_NUMERIC: Line Group Formats. (line 144) 5097* LC_TIME: Detailed Context. (line 12) 5098* line formats: Line Formats. (line 6) 5099* line group formats: Line Group Formats. (line 6) 5100* mebibyte, definition of: cmp Options. (line 85) 5101* megabyte, definition of: cmp Options. (line 81) 5102* merge commands: Merge Commands. (line 6) 5103* merged diff3 format: Bypassing ed. (line 6) 5104* merged output format: If-then-else. (line 6) 5105* merging from a common ancestor: diff3 Merging. (line 6) 5106* merging interactively: Merge Commands. (line 6) 5107* messages from patch: patch Messages. (line 6) 5108* multibyte characters: Internationalization. 5109 (line 6) 5110* multiple patches: Multiple Patches. (line 6) 5111* newline treatment by diff: Incomplete Lines. (line 6) 5112* normal output format: Normal. (line 6) 5113* options for cmp: cmp Options. (line 6) 5114* options for diff: diff Options. (line 6) 5115* options for diff3: diff3 Options. (line 6) 5116* options for patch: patch Options. (line 6) 5117* options for sdiff: sdiff Options. (line 6) 5118* output formats: Output Formats. (line 6) 5119* overlap: diff3 Merging. (line 26) 5120* overlapping change, selection of: Which Changes. (line 6) 5121* overview of diff and patch: Overview. (line 6) 5122* paginating diff output: Pagination. (line 6) 5123* patch consumer tips: Tips for Patch Consumers. 5124 (line 6) 5125* patch input format: patch Input. (line 6) 5126* patch invocation: Invoking patch. (line 6) 5127* patch messages and questions: patch Messages. (line 6) 5128* patch options: patch Options. (line 6) 5129* patch producer tips: Tips for Patch Producers. 5130 (line 6) 5131* patch, common mistakes: Avoiding Common Mistakes. 5132 (line 6) 5133* PATCH_GET: Revision Control. (line 13) 5134* PATCH_VERSION_CONTROL: Backup Names. (line 21) 5135* patches, shrinking: Generating Smaller Patches. 5136 (line 6) 5137* patching directories: patch Directories. (line 6) 5138* pebibyte, definition of: cmp Options. (line 106) 5139* performance of diff: diff Performance. (line 6) 5140* petabyte, definition of: cmp Options. (line 102) 5141* POSIX <1>: Standards conformance. 5142 (line 6) 5143* POSIX: patch and POSIX. (line 6) 5144* POSIXLY_CORRECT <1>: Standards conformance. 5145 (line 6) 5146* POSIXLY_CORRECT: patch and POSIX. (line 6) 5147* projects for directories: Shortcomings. (line 6) 5148* quoting style: patch Quoting Style. (line 6) 5149* QUOTING_STYLE: patch Quoting Style. (line 30) 5150* RCS: Revision Control. (line 6) 5151* RCS script output format: RCS. (line 6) 5152* regular expression matching headings: Specified Headings. (line 6) 5153* regular expression suppression: Specified Lines. (line 6) 5154* reject file names: Reject Names. (line 6) 5155* removing empty files: Creating and Removing. 5156 (line 6) 5157* reporting bugs: Bugs. (line 6) 5158* reversed patches: Reversed Patches. (line 6) 5159* revision control: Revision Control. (line 6) 5160* sample input for diff: Sample diff Input. (line 6) 5161* sample input for diff3: Sample diff3 Input. (line 6) 5162* SCCS: Revision Control. (line 6) 5163* script output formats: Scripts. (line 6) 5164* sdiff invocation: Invoking sdiff. (line 6) 5165* sdiff options: sdiff Options. (line 6) 5166* sdiff output format: sdiff Option Summary. 5167 (line 6) 5168* section headings: Sections. (line 6) 5169* side by side: Side by Side. (line 6) 5170* side by side format: Side by Side Format. (line 6) 5171* SIMPLE_BACKUP_SUFFIX: Backup Names. (line 12) 5172* special files: Special Files. (line 6) 5173* specified headings: Specified Headings. (line 6) 5174* summarizing which files differ: Brief. (line 6) 5175* System V diff3 compatibility: Saving the Changed File. 5176 (line 6) 5177* tab and blank difference suppression: White Space. (line 6) 5178* tab stop alignment: Tabs. (line 6) 5179* tebibyte, definition of: cmp Options. (line 99) 5180* terabyte, definition of: cmp Options. (line 95) 5181* testing patch: Dry Runs. (line 6) 5182* text versus binary diff: Binary. (line 6) 5183* time stamp format, context diffs: Detailed Context. (line 12) 5184* time stamp format, unified diffs: Detailed Unified. (line 12) 5185* time stamps on patched files: Patching Time Stamps. 5186 (line 6) 5187* traditional patch: patch and Tradition. (line 6) 5188* trailing blanks: Trailing Blanks. (line 6) 5189* two-column output: Side by Side. (line 6) 5190* unified output format: Unified Format. (line 6) 5191* unmerged change: Which Changes. (line 6) 5192* varying-width characters: Internationalization. 5193 (line 6) 5194* verbose messages from patch: More or Fewer Messages. 5195 (line 6) 5196* version control: Revision Control. (line 6) 5197* VERSION_CONTROL <1>: Backup Names. (line 21) 5198* VERSION_CONTROL: Revision Control. (line 22) 5199* white space in patches: Changed White Space. (line 6) 5200* yottabyte, definition of: cmp Options. (line 124) 5201* zettabyte, definition of: cmp Options. (line 116) 5202 5203 5204 5205Tag Table: 5206Node: Top1434 5207Node: Overview3648 5208Node: Comparison7279 5209Node: Hunks9984 5210Node: White Space11428 5211Node: Blank Lines13269 5212Node: Specified Lines14263 5213Node: Case Folding15391 5214Node: Brief15810 5215Node: Binary17135 5216Node: Output Formats21222 5217Node: Sample diff Input21949 5218Node: Context23450 5219Node: Context Format25029 5220Node: Example Context25823 5221Node: Less Context27332 5222Node: Detailed Context28523 5223Node: Unified Format30723 5224Node: Example Unified31522 5225Node: Detailed Unified32562 5226Node: Sections34207 5227Node: Specified Headings34968 5228Node: C Function Headings36521 5229Node: Alternate Names37368 5230Node: Side by Side38284 5231Node: Side by Side Format40436 5232Node: Example Side by Side41339 5233Node: Normal42681 5234Node: Example Normal43683 5235Node: Detailed Normal44421 5236Node: Scripts46162 5237Node: ed Scripts46569 5238Node: Example ed47777 5239Node: Detailed ed48229 5240Node: Forward ed49990 5241Node: RCS50768 5242Node: If-then-else51985 5243Node: Line Group Formats53665 5244Node: Line Formats59543 5245Node: Example If-then-else62815 5246Node: Detailed If-then-else63896 5247Node: Incomplete Lines65782 5248Node: Comparing Directories67422 5249Node: Adjusting Output71856 5250Node: Tabs72365 5251Node: Trailing Blanks73981 5252Node: Pagination75209 5253Node: diff Performance75679 5254Node: Comparing Three Files78768 5255Node: Sample diff3 Input79648 5256Node: Example diff3 Normal80598 5257Node: Detailed diff3 Normal81660 5258Node: diff3 Hunks83450 5259Node: diff3 Merging84719 5260Node: Which Changes86965 5261Node: Marking Conflicts88367 5262Node: Bypassing ed90825 5263Node: Merging Incomplete Lines92170 5264Node: Saving the Changed File92898 5265Node: Interactive Merging93516 5266Node: sdiff Option Summary94227 5267Node: Merge Commands95432 5268Node: Merging with patch96723 5269Node: patch Input99097 5270Node: Revision Control99781 5271Node: Imperfect100953 5272Node: Changed White Space102103 5273Node: Reversed Patches102902 5274Node: Inexact104368 5275Node: Dry Runs107928 5276Node: Creating and Removing108794 5277Node: Patching Time Stamps109845 5278Node: Multiple Patches112046 5279Node: patch Directories114711 5280Node: Backups116338 5281Node: Backup Names117405 5282Ref: Backup Names-Footnote-1120374 5283Node: Reject Names120501 5284Node: patch Messages121092 5285Node: More or Fewer Messages122154 5286Node: patch and Keyboard Input122787 5287Node: patch Quoting Style123818 5288Node: patch and POSIX124970 5289Node: patch and Tradition125812 5290Node: Making Patches129270 5291Node: Tips for Patch Producers130098 5292Node: Tips for Patch Consumers131356 5293Node: Avoiding Common Mistakes131995 5294Node: Generating Smaller Patches134522 5295Node: Invoking cmp136285 5296Node: cmp Options137710 5297Node: Invoking diff141373 5298Node: diff Options143231 5299Node: Invoking diff3151877 5300Node: diff3 Options152517 5301Node: Invoking patch155552 5302Node: patch Options156762 5303Node: Invoking sdiff161991 5304Node: sdiff Options163136 5305Node: Standards conformance166109 5306Node: Projects167857 5307Node: Shortcomings168570 5308Node: Internationalization169674 5309Node: Changing Structure170842 5310Node: Special Files171948 5311Node: Unusual File Names173062 5312Node: Time Stamp Order173703 5313Node: Ignoring Changes174348 5314Node: Speedups175120 5315Node: Bugs175586 5316Node: Copying This Manual176441 5317Node: Translations201582 5318Node: Index201956 5319 5320End Tag Table 5321