Warning, /sdk/kdiff3/doc/en/index.docbook is written in an unsupported language. File is not indexed.
0001 <?xml version="1.0" encoding="utf-8"?> 0002 <!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [ 0003 <!ENTITY kdiff3 "<application>KDiff3</application>"> 0004 <!ENTITY % addindex "IGNORE"> 0005 <!ENTITY % English "INCLUDE"> 0006 ]> 0007 0008 <book lang="&language;"> 0009 0010 <!-- This header contains all of the meta-information for the document such 0011 as Authors, publish date, the abstract, and Keywords --> 0012 0013 <bookinfo> 0014 <title>The &kdiff3; Handbook</title> 0015 0016 <authorgroup> 0017 <othercredit role="developer"> 0018 <firstname>Michael</firstname> 0019 <surname>Reeves</surname> 0020 <affiliation><address> 0021 <email>reeves.87@gmail.com</email> 0022 </address></affiliation> 0023 </othercredit> 0024 <othercredit role="developer"> 0025 <firstname>Joachim</firstname> 0026 <surname>Eibl</surname> 0027 <affiliation><address> 0028 <email>joachim.eibl at gmx.de</email> 0029 </address></affiliation> 0030 </othercredit> 0031 <!-- TRANS:ROLES_OF_TRANSLATORS --> 0032 </authorgroup> 0033 0034 <copyright> 0035 <year>2002-2007</year> 0036 <holder>Joachim Eibl</holder> 0037 </copyright> 0038 <copyright> 0039 <year>2017-2019</year> 0040 <holder>Michael Reeves</holder> 0041 </copyright> 0042 <!-- Translators: put here the copyright notice of the translation --> 0043 <!-- Put here the FDL notice. Read the explanation in fdl-notice.docbook 0044 and in the FDL itself on how to use it. --> 0045 <legalnotice>&FDLNotice;</legalnotice> 0046 0047 <!-- Date and version information of the documentation 0048 Don't forget to include this last date and this last revision number, we 0049 need them for translation coordination ! 0050 Please respect the format of the date (YYYY-MM-DD) and of the version 0051 (V.MM.LL), it could be used by automation scripts. 0052 Do NOT change these in the translation. --> 0053 0054 <date>2023-12-23</date> 0055 <releaseinfo>1.11.0</releaseinfo> 0056 0057 0058 <abstract> 0059 <para> 0060 &kdiff3; is a file and folder diff and merge tool which 0061 <itemizedlist> 0062 <listitem><para>compares and merges two or three text input files or folders,</para></listitem> 0063 <listitem><para>shows the differences line by line and character by character(!),</para></listitem> 0064 <listitem><para>provides an automatic merge-facility,</para></listitem> 0065 <listitem><para>has an editor for comfortable solving of merge-conflicts,</para></listitem> 0066 <listitem><para>provides network transparency via KIO,</para></listitem> 0067 <listitem><para>has options to highlight or hide changes in white-space or comments,</para></listitem> 0068 <listitem><para>supports Unicode, UTF-8 and other file encodings,</para></listitem> 0069 <listitem><para>prints differences,</para></listitem> 0070 <listitem><para>supports version control keyword and history merging.</para></listitem> 0071 </itemizedlist> 0072 </para><para> 0073 This document describes &kdiff3;-version 1.12. 0074 </para> 0075 </abstract> 0076 0077 <!-- This is a set of Keywords for indexing by search engines. 0078 Please at least include KDE, the KDE package it is in, the name 0079 of your application, and a few relevant keywords. --> 0080 0081 <keywordset> 0082 <keyword>KDE</keyword> 0083 <keyword>kdiff3</keyword> 0084 <keyword>diff</keyword> 0085 <keyword>merge</keyword> 0086 <keyword>CVS</keyword> 0087 <keyword>triple diff</keyword> 0088 <keyword>compare</keyword> 0089 <keyword>files</keyword> 0090 <keyword>folders</keyword> 0091 <keyword>directories</keyword> 0092 <keyword>version control</keyword> 0093 <keyword>three-way-merge</keyword> 0094 <keyword>in-line-differences</keyword> 0095 <keyword>synchronise</keyword> 0096 <keyword>kpart</keyword> 0097 <keyword>kio</keyword> 0098 <keyword>network transparent</keyword> 0099 <keyword>editor</keyword> 0100 <keyword>white space</keyword> 0101 <keyword>comments</keyword> 0102 </keywordset> 0103 0104 </bookinfo> 0105 0106 <chapter id="introduction"><title>Introduction</title> 0107 <sect1 id="why"><title>Yet Another Diff Frontend?</title> 0108 <para> 0109 Several graphical diff tools exist. Why choose &kdiff3;? Let me say, why I wrote it. 0110 </para><para> 0111 &kdiff3; started because I had to do a difficult merge. Merging is necessary when several 0112 people work on the same files in a project. A merge can be somewhat automated, when the 0113 merge-tool not only has the new modified files (called "branches"), but also the original file 0114 (called "base"). The merge tool will automatically choose any modification that was only 0115 done in one branch. When several contributors change the same lines, then the merge tool 0116 detects a conflict which must be solved manually. 0117 </para><para> 0118 The merge then was difficult because one contributor had changed many things and corrected 0119 the indentation in many places. Another contributor also had changed much text in the same file, 0120 which resulted in several merge conflicts. 0121 </para><para> 0122 The tool I used then, only showed the changed lines, but not what had changed within these 0123 lines. And there was no information about where only the indentation was changed. The merge 0124 was a little nightmare. 0125 </para><para> 0126 So this was the start. The first version could show differences within a line and showed white space differences. 0127 Later many other features were added to increase the usefulness. 0128 </para><para> 0129 For example if you want to compare some text quickly, then you can copy it to the clipboard and 0130 paste it into either diff window. 0131 </para><para> 0132 A feature that required a big effort was the folder comparison and merge facility, which turned 0133 the program almost into a full file browser. 0134 </para><para> 0135 I hope &kdiff3; works for you too. Have fun! 0136 </para><para> 0137 Joachim Eibl (2003) 0138 </para> 0139 </sect1> 0140 0141 <sect1 id="screenshots"><title>Screenshots and Features</title> 0142 <para>This screenshot shows the difference between two text files (using an early version of &kdiff3;):</para> 0143 <screenshot><mediaobject> 0144 <imageobject><imagedata fileref="screenshot_diff.png" format="PNG"/></imageobject> 0145 </mediaobject></screenshot> 0146 0147 <para> 0148 3-way-merging is fully supported. This is useful if two people change code independently. 0149 The original file (the base) is used to help &kdiff3; to automatically select the correct 0150 changes. 0151 The merge-editor below the diff-windows allows you to solve conflicts, while showing you the output you will get. 0152 You can even edit the output. 0153 This screenshot shows three input files being merged: 0154 </para><para> 0155 <screenshot><mediaobject> 0156 <imageobject><imagedata fileref="screenshot_merge.png" format="PNG"/></imageobject> 0157 </mediaobject></screenshot> 0158 </para> 0159 0160 <para id="dirmergebigscreenshot">&kdiff3; also helps you to compare and merge complete folders. 0161 This screenshot shows &kdiff3; during a folder merge: 0162 </para><para> 0163 <screenshot><mediaobject> 0164 <imageobject><imagedata fileref="dirmergebig.png" format="PNG"/></imageobject> 0165 </mediaobject></screenshot> 0166 </para> 0167 </sect1> 0168 0169 <sect1 id="features"><title>More Features</title> 0170 <sect2><title> Line-By-Line And Char-By-Char Diff-Viewer</title> 0171 <para>By using the possibilities of a graphical color display &kdiff3; shows 0172 exactly what the difference is. When you have to do many code-reviews, you will like this. 0173 </para> 0174 <screenshot><mediaobject> 0175 <imageobject><imagedata fileref="letter_by_letter.png" format="PNG"/></imageobject> 0176 </mediaobject></screenshot> 0177 </sect2> 0178 0179 <sect2><title> See White-Space Differences At One Glance</title> 0180 <para>Spaces and tabs that differ appear visibly. When lines differ only 0181 in the amount of white space this can be seen at one look in the summary 0182 column on the left side. (No more worries when people change the indentation.) 0183 </para> 0184 <screenshot><mediaobject> 0185 <imageobject><imagedata fileref="white_space.png" format="PNG"/></imageobject> 0186 </mediaobject></screenshot> 0187 </sect2> 0188 0189 <sect2><title> Triple-Diff</title> 0190 <para> Analyze three files and see where they differ. 0191 </para><para> 0192 The left/middle/right windows are named <guilabel>A</guilabel>/<guilabel>B</guilabel>/<guilabel>C</guilabel> and have the blue/green/magenta color respectively. 0193 </para><para> 0194 If one file is the same and one file is different on a line then the 0195 color shows which file is different. The red color means that both other 0196 files are different. 0197 </para> 0198 <screenshot><mediaobject> 0199 <imageobject><imagedata fileref="triple_diff.png" format="PNG"/></imageobject> 0200 </mediaobject></screenshot> 0201 </sect2> 0202 0203 <sect2><title> Comfortable Merge Of Two Or Three Input Files</title> 0204 <para> &kdiff3; can be used to merge two or three input files and automatically 0205 merges as much as possible. The result is presented in an editable window 0206 where most conflicts can be solved with a single mouseclick: Select the 0207 respective <guibutton>...</guibutton> buttons at the <guilabel>A</guilabel>/ 0208 <guilabel>B</guilabel>/<guilabel>C</guilabel> windows to select the source 0209 that should be used. You can also select more than one source. Since this 0210 output window is an editor even conflicts which need further corrections 0211 can be solved here without requiring another tool. 0212 </para> 0213 </sect2> 0214 0215 <sect2><title>And ...</title> 0216 <itemizedlist> 0217 <listitem><para>Fast navigation via buttons.</para></listitem> 0218 <listitem><para>A mouse-click into a summary column sync's all windows to show the same position.</para></listitem> 0219 <listitem><para>Select and copy from any window and paste into the merge result window.</para></listitem> 0220 <listitem><para>Overview column that shows where the changes and conflicts are.</para></listitem> 0221 <listitem><para>The colors are adjustable to your specific preferences.</para></listitem> 0222 <listitem><para>Adjustable Tab size.</para></listitem> 0223 <listitem><para>Option to insert spaces instead of tabs.</para></listitem> 0224 <listitem><para>Open files comfortably via dialog or specify files on the command line.</para></listitem> 0225 <listitem><para>Search for strings in all text windows with <menuchoice><guimenu>Edit</guimenu><guimenuitem>Find</guimenuitem></menuchoice> (<keycombo>&Ctrl;<keycap>F</keycap></keycombo>) and <menuchoice><guimenu>Edit</guimenu><guimenuitem>Find Next</guimenuitem></menuchoice> (<keycap>F3</keycap>) menu items.</para></listitem> 0226 <listitem><para>Show the line numbers for each line. </para></listitem> 0227 <listitem><para>Paste clipboard or drag text into a diff input window.</para></listitem> 0228 <listitem><para>Network transparency via KIO.</para></listitem> 0229 <listitem><para>Can be used as diff-viewer from the &kdevelop; 3.</para></listitem> 0230 <listitem><para>Word-wrap for long lines.</para></listitem> 0231 <listitem><para>Support for Unicode, UTF-8 and other codecs.</para></listitem> 0232 <listitem><para>Support for right to left languages.</para></listitem> 0233 <listitem><para>...</para></listitem> 0234 </itemizedlist> 0235 </sect2> 0236 </sect1> 0237 </chapter> 0238 0239 <chapter id="documentation"><title>File Comparison And Merge</title> 0240 0241 <sect1 id="commandline"><title>Command-Line Options</title> 0242 0243 <sect2><title>Comparing 2 files: </title> 0244 <screen> 0245 <command>kdiff3</command> <replaceable>file1 file2</replaceable> 0246 </screen> 0247 </sect2> 0248 0249 <sect2><title>Merging 2 files: </title> 0250 <screen> 0251 <command>kdiff3</command> <replaceable>file1 file2</replaceable> -m 0252 <command>kdiff3</command> <replaceable>file1 file2</replaceable> -o <replaceable>outputfile</replaceable> 0253 </screen> 0254 </sect2> 0255 0256 <sect2><title>Comparing 3 files: </title> 0257 <screen> 0258 <command>kdiff3</command> <replaceable>file1 file2 file3</replaceable> 0259 </screen> 0260 </sect2> 0261 0262 <sect2><title>Merging 3 files: </title> 0263 <screen> 0264 <command>kdiff3</command> <replaceable>file1 file2 file3</replaceable> -m 0265 <command>kdiff3</command> <replaceable>file1 file2 file3</replaceable> -o <replaceable>outputfile</replaceable> 0266 </screen> 0267 <para> 0268 Note that <replaceable>file1</replaceable> will be treated as 0269 base of <replaceable>file2</replaceable> and 0270 <replaceable>file3</replaceable>. 0271 </para> 0272 </sect2> 0273 0274 <sect2><title>Special case: Files with the same name </title> 0275 <para> 0276 If all files have the same name but are in different folders, you can 0277 reduce typework by specifying the filename only for the first file, ⪚: 0278 </para> 0279 <screen> 0280 <command>kdiff3</command> <replaceable>folder1/filename folder2 folder3</replaceable> 0281 </screen> 0282 </sect2> 0283 0284 <sect2><title>Commandline for starting a folder comparison or merge: </title> 0285 <para>This is very similar, but now it's about folders.</para> 0286 <screen> 0287 <command>kdiff3</command> <replaceable>folder1 folder2</replaceable> 0288 <command>kdiff3</command> <replaceable>folder1 folder2</replaceable> -o <replaceable>destdir</replaceable> 0289 <command>kdiff3</command> <replaceable>folder1 folder2 folder3</replaceable> 0290 <command>kdiff3</command> <replaceable>folder1 folder2 folder3</replaceable> -o <replaceable>destdir</replaceable> 0291 </screen> 0292 <para>For folder comparison and merge you can continue to read <link linkend="dirmerge">here</link>.</para> 0293 </sect2> 0294 0295 <sect2><title>Other command line options</title> 0296 <para>To see all available command line options type</para> 0297 <screen> 0298 <command>kdiff3</command> --help 0299 </screen> 0300 <para>Example output:</para> 0301 <screen> 0302 Options: 0303 -m, --merge Merge the input. 0304 -b, --base file Explicit base file. For compatibility with certain tools. 0305 -o, --output file Output file. Implies -m. E.g.: -o newfile.txt 0306 --out file Output file, again. (For compatibility with certain tools.) 0307 --noauto Ignore --auto and always show GUI. 0308 --auto No GUI if all conflicts are auto-solvable. (Needs -o file) 0309 --L1 alias1 Visible name replacement for input file 1 (base). 0310 --L2 alias2 Visible name replacement for input file 2. 0311 --L3 alias3 Visible name replacement for input file 3. 0312 -L, --fname alias Alternative visible name replacement. Supply this once for every input. 0313 --cs string Override a config setting. Use once for every setting. E.g.: --cs "AutoAdvance=1" 0314 --confighelp Show list of config settings and current values. 0315 --config file Use a different config file. 0316 </screen> 0317 <para>The option <option>--cs</option> allows you to adjust a configuration value that is otherwise only adjustable via the configure dialogs. 0318 But be aware that when &kdiff3; then terminates the changed value will be stored along with the other settings. 0319 With <option>--confighelp</option> you can find out the names of the available items and current values.</para> 0320 <para>Via <option>--config</option> you can specify a different config file. When you often use &kdiff3; 0321 with completely different setups this allows you to easily switch between them.</para> 0322 </sect2> 0323 <sect2><title>Ignorable command line options</title> 0324 <para>Many people want to use &kdiff3; with some version control system. But when that version control system calls &kdiff3; using command line parameters that &kdiff3; doesn't recognise, then &kdiff3; terminates with an error. 0325 The <guilabel>Integration</guilabel> item in the settings dialog allow to specify command line parameters that should be ignored by &kdiff3;. 0326 They will appear in the usage help like in this example:</para> 0327 <screen> 0328 --<replaceable>foo</replaceable> Ignored. (User defined.) 0329 </screen> 0330 <variablelist> 0331 <varlistentry><term><guilabel>Command line options to ignore:</guilabel></term><listitem><para> 0332 A list of options, separated via semicolon ';'. When one of these options appears on the commandline, 0333 then &kdiff3; will ignore it and run without reporting an error. 0334 (Default is "<literal>u;query;html;abort</literal>").</para></listitem></varlistentry> 0335 </variablelist> 0336 <para>When this isn't enough, then it is recommended to write a shell script that does the option translation.</para> 0337 </sect2> 0338 0339 </sect1> 0340 0341 <sect1 id="opendialog"><title>Open-Dialog</title> 0342 <para> 0343 Since many input files must be selectable, the program has a special open dialog: 0344 </para> 0345 <screenshot><mediaobject> 0346 <imageobject><imagedata fileref="open_dialog.png" format="PNG"/></imageobject> 0347 </mediaobject></screenshot> 0348 <para> 0349 The open dialog allows you to edit the filenames by hand, selecting a file 0350 via the file-browser via the <guibutton>File...</guibutton> button or allows 0351 you to choose recent files from the drop-down lists. If you open the dialog 0352 again, then the current names still remain there. The third input file is not 0353 required. If the entry for <guilabel>C</guilabel> remains empty, then only a 0354 two file diff analysis will be done. 0355 </para><para> 0356 You can also select a folder via the <guibutton>Folder...</guibutton> button. 0357 If for <guilabel>A</guilabel> a folder is specified then a folder-comparison 0358 /merge starts. If <guilabel>A</guilabel> specifies a file but <guilabel>B</guilabel>, 0359 <guilabel>C</guilabel> or the output specify a folder, then &kdiff3; uses the 0360 filename from <guilabel>A</guilabel> in the specified folders. 0361 </para><para> 0362 If <guilabel>Merge</guilabel> check box is selected, then the <guilabel>Output</guilabel> 0363 line becomes editable. But it is not required to specify the output filename 0364 immediately. You can also postpone this until saving. 0365 </para><para> 0366 The <guibutton>Configure...</guibutton> button opens the settings dialog, so that you can set 0367 the options before running the analysis. 0368 </para> 0369 </sect1> 0370 0371 <sect1 id="pasteinput"><title>Paste and Drop Input</title> 0372 <para> 0373 Sometimes you want to compare parts of a text that is not an own file. &kdiff3; also 0374 allows you to paste text from the clipboard into the diff input window that has the focus. 0375 The diff analysis happens immediately then. 0376 In the open dialog you need not specify files then, but just close it via <guibutton>Cancel</guibutton> button. 0377 </para><para> 0378 You can also use drag and drop: Drag a file from a file manager 0379 or selected text from an editor and drop it onto a diff input window. 0380 </para><para> 0381 What's the idea? Sometimes a file contains two similar functions, but checking how similar 0382 they really are is a big effort if you first must create two files and then load them. Now 0383 you can simply copy, paste and compare the relevant sections. 0384 </para><note><para> 0385 Currently you cannot drag anything from &kdiff3;. Only dropping in the diff input 0386 is supported. 0387 </para></note><warning><para> 0388 Some editors still interpret the drag and drop into another program like cut 0389 (instead of copy) and paste. Your original data might be lost then. 0390 </para></warning> 0391 </sect1> 0392 0393 <sect1 id="interpretinginformation"><title>Comparing Files And Interpreting The Information In The Input Windows</title> 0394 <screenshot><mediaobject> 0395 <imageobject><imagedata fileref="screenshot_diff.png" format="PNG"/></imageobject> 0396 </mediaobject></screenshot> 0397 <sect2><title>Info Line</title><para> 0398 At the top of each text window is its "info line". The info lines of 0399 the input windows contain a letter <guilabel>A</guilabel>, <guilabel>B</guilabel> 0400 or <guilabel>C</guilabel>, the editable filename, a button for browsing, and the 0401 line number of the first visible line in the window. (Note that window <guilabel>C</guilabel> 0402 is optional.) Each info line appears in a different color. 0403 </para><para> 0404 When you selected another file via browsing or finished editing the filename here 0405 by pressing &Enter;, the new file will be loaded and 0406 compared with the already loaded file(s). 0407 </para></sect2><sect2><title>Coloring</title><para> 0408 The three input windows are assigned the letters <guilabel>A</guilabel>, <guilabel>B</guilabel> 0409 and <guilabel>C</guilabel>. 0410 <guilabel>A</guilabel> has color blue, <guilabel>B</guilabel> has green and <guilabel>C</guilabel> 0411 has magenta. (These are the defaults, but can be changed in the <guilabel>Color</guilabel> 0412 item in the settings dialog.) 0413 </para><para> 0414 When a difference is detected then the color shows which input file differs. 0415 When both other input files differ then the color used to express this is 0416 red by default (<guilabel>Conflict color</guilabel> option in the <guilabel>Color</guilabel> 0417 item in the settings dialog). This colorscheme is especially useful in the 0418 case of three input files, which will be seen in the next section 0419 (<link linkend="merging">Merging</link>). 0420 </para></sect2><sect2><title>Summary Column</title><para> 0421 Left of each text is the "summary" column. If differences occurred on a 0422 line then the summary column shows the respective color. For a white-space-only 0423 difference the summary is chequered. For programming languages where white 0424 space is not so important this is useful to see at one glance if anything 0425 of importance was modified. (In C/C++ white space is only interesting within 0426 strings, comments, for the preprocessor, and some only very esoteric situations.) 0427 </para><para> 0428 The vertical line separating the summary column and the text is interrupted 0429 if the input file had no lines there. When word-wrap is enabled then this vertical 0430 line appears dotted for wrapped lines. 0431 </para></sect2><sect2><title>Overview Column</title><para> 0432 On the right side a "overview" column is visible left of the vertical scrollbar. 0433 It shows the compressed summary column of input <guilabel>A</guilabel>. All the differences 0434 and conflicts are visible at one glance. When only two input windows are 0435 used, then all differences appear red here because every difference is 0436 also a conflict. A black rectangle frames the visible part of the inputs. 0437 For very long input files, when the number of input lines is bigger than 0438 the height of the overview column in pixels, then several input lines share 0439 one overview line. A conflict then has top priority over simple differences, 0440 which have priority over no change, so that no difference or conflict is 0441 lost here. By clicking into this overview column the corresponding text 0442 will be shown. 0443 </para></sect2><sect2 id="manualdiffhelp"><title>Manually Aligning Lines</title><para> 0444 Sometimes the algorithm places the wrong lines next to each other. Or you want to compare 0445 one piece of text with text at a completely different position in the other file. 0446 For these situations you can manually instruct &kdiff3; to align certain lines. 0447 Mark the text for which you want to improve the alignment with the mouse as you would 0448 for copy and paste in the first diff view and then choose <menuchoice><guimenu>Diffview</guimenu><guimenuitem>Add Manual Diff Alignment</guimenuitem></menuchoice> menu item (<keycombo>&Ctrl;<keycap>Y</keycap></keycombo>). An orange bar will appear in 0449 the summary column next to the chosen text. Repeat this for the second and 0450 (if available) third diff view. &kdiff3; will immediately recalculate the differences everytime you do this, 0451 and will align the chosen lines. Of course some of the previously matching lines in between 0452 might not match anymore. 0453 </para><para> 0454 Currently merging doesn't support the use of manual diff help. 0455 </para></sect2><sect2 id="joinsplitsections"><title>Manually Joining and Splitting Diff Sections</title><para> 0456 In some cases &kdiff3; will see too many or too few diff sections for merging. In such a 0457 case you can join or split existing sections. 0458 </para><para> 0459 Add new sections by first selecting text in the lines that belong together in either input window (as for copying to the clipboard). 0460 Then choose <menuchoice><guimenu>Merge</guimenu><guimenuitem>Split Diff At Selection</guimenuitem></menuchoice> menu item. 0461 Splits will be added above the first line and below the last line of the selected text. 0462 If you only want to add one section, then select text beginning at another section-split. 0463 </para><para> 0464 For joining sections in either input window select something in the lines from the sections to join. 0465 (You can join several sections in one step too.) Then choose <menuchoice><guimenu>Merge</guimenu><guimenuitem>Join Selected Diffs</guimenuitem></menuchoice> menu item. 0466 </para></sect2> 0467 </sect1> 0468 0469 0470 <sect1 id="merging"><title>Merging And The Merge Output Editor Window</title> 0471 <screenshot><mediaobject> 0472 <imageobject><imagedata fileref="screenshot_merge.png" format="PNG"/></imageobject> 0473 </mediaobject></screenshot> 0474 <para> 0475 The merge output editor window (below the diff input windows) also has an info line at the top showing <guilabel>Output:</guilabel>, the filename and <replaceable>[Modified]</replaceable> tag if you edited something. Usually it will contain some text through the automatic merge facilities, but often it will also contain conflicts. 0476 </para><para> 0477 !!! Saving is disabled until all conflicts are resolved !!! (Use the <guibutton>Go to Previous/Next Unsolved Conflict</guibutton> buttons to find the remaining conflicts.) 0478 </para><para> 0479 With only two input files every difference is also a conflict that must 0480 be solved manually. 0481 </para><para> 0482 With three input files the first file is treated as base, while the second and third input files contain modifications. When at any line only either input <guilabel>B</guilabel> or input <guilabel>C</guilabel> have changed but not both then the changed source will automatically be selected. Only when <guilabel>B</guilabel> and <guilabel>C</guilabel> have changed on the same lines, then the tool detects a conflict that must be solved manually. When <guilabel>B</guilabel> and <guilabel>C</guilabel> are the same, but not the same as <guilabel>A</guilabel>, then <guilabel>C</guilabel> is selected. 0483 </para><sect2><title>The Summary Column</title><para> 0484 The merge output editor window also has a summary column on the left. It shows the 0485 letter of the input from which a line was selected or nothing if all three 0486 sources where equal on a line. For conflicts it shows a questionmark "?" 0487 and the line shows "<Merge Conflict>", all in red. Because solving 0488 conflicts line by line would take very long, the lines are grouped into 0489 groups that have the same difference and conflict characteristics. 0490 But only-white-space-conflicts are separated from non-white-space-conflicts 0491 in order to ease the merging of files were the indentation changed for many 0492 lines. 0493 </para></sect2><sect2 id="synchronise_views"><title>Setting The Current Group And Synchronising Merge And Diff View Position</title><para> 0494 When clicking into the summary column with the &LMB; in either window then the beginning of the group belonging to that line will shown in all windows. This group then becomes the "current group". It is highlighted with the <guilabel>Current range diff background color</guilabel> option of <guilabel>Integration</guilabel> item in the settings dialog and a black bar appears on the left side of the text. 0495 </para></sect2><sect2><title>Choosing Inputs A, B or C For Current Conflict And Editing</title><para> 0496 The Button bar below the menubar contains three input selector buttons containing the letters <guilabel>A</guilabel>, <guilabel>B</guilabel> and <guilabel>C</guilabel>. Click the input selector button to insert (or remove if already inserted) the lines from the respective source. To choose the lines from several inputs click the respective buttons in the needed order. For example if you want that the lines from <guilabel>B</guilabel> appear before the lines from <guilabel>A</guilabel> in the output, first click <guilabel>B</guilabel>, then <guilabel>A</guilabel>. 0497 </para><para> 0498 If you use the <guibutton>Automatically Go to Next Unsolved Conflict After Source Selection</guibutton> button (see <link linkend="autoadvance">Auto-Advance</link> section), you should disable this before choosing lines from several inputs or if you want to edit the lines after your choice. Otherwise &kdiff3; will jump to the next conflict after choosing the first input. 0499 </para><para> 0500 It is often helpful directly edit the merge output. 0501 The summary column will show "m" for every line that was manually modified. 0502 When for instance the differences are aligned in a way that simply choosing 0503 the inputs won't be satisfactory, then you can mark the needed text and use 0504 normal <link linkend="selections">copy and paste</link> to put it into the merge output. 0505 </para><para> 0506 Sometimes, when a line is removed either by automatic merge or by editing 0507 and no other lines remain in that group, then the text <No src line> 0508 will appear in that line. This is just a placeholder for the group for 0509 when you might change your mind and select some source again. This text won't 0510 appear in the saved file or in any selections you want to copy and paste. 0511 </para><para> 0512 The text "<Merge Conflict>" will appear in the clipboard if you 0513 copy and paste some text containing such a line. But still be careful to 0514 do so. 0515 </para></sect2><sect2><title>Choosing Input A, B, or C for All Conflicts</title><para> 0516 The normal merge will start by solving simple conflicts automatically. But the <guimenu>Merge</guimenu> menu provides some actions for other common needs. If you have to select the same source for most conflicts, then you can choose <guilabel>A</guilabel>, <guilabel>B</guilabel> or <guilabel>C</guilabel> everywhere, or only for the remaining unsolved conflicts, or for unsolved white space conflicts. If you want to decide every single delta yourself, you can <guimenuitem>Set Deltas to Conflicts</guimenuitem>. Or if you want to return to the automatic choices of &kdiff3; then select <guimenuitem>Automatically Solve Simple Conflicts</guimenuitem>. &kdiff3; then restarts the merge. For actions that change your previous modifications &kdiff3; will ask for your confirmation before proceeding. 0517 </para><note><para> 0518 When choosing either source for unsolved white space conflicts and the <guilabel>Ignore numbers (treat as white space)</guilabel> or <guilabel>Ignore C/C++ comments (treat as white space)</guilabel> options at <guilabel>Diff</guilabel> item in the settings dialog are used then changes in numbers or comments will be treated like white space too. 0519 0520 </para></note></sect2><sect2 id="vcskeywordsmergesupport"><title>Automatic Merge of Version Control Keywords and History (Log)</title><para> 0521 Many version control systems support special keywords in the file. (⪚ "<literal>$Date$</literal>", "<literal>$Header$</literal>", "<literal>$Author$</literal>", "<literal>$Log$</literal>", &etc;) During the check-in the version control system (VCS) changes these lines. For instance "<literal>$Date$</literal>" will turn into "<literal>$Date: 2005/03/22 18:45:01 $</literal>". Since this line will be different in every version of the file, it would require manual interaction during the merge. 0522 </para><para> 0523 &kdiff3; offers automatic merge for these items at <guilabel>Merge</guilabel> item in the settings dialog. For simple lines that match the <guilabel>Auto merge regular expression</guilabel> option in all input-files &kdiff3; will choose the line from <guilabel>B</guilabel> or - if available - from <guilabel>C</guilabel>. (Additionally it is necessary that the lines in question line up in the comparison and the previous line contains no conflict.) This auto merge can either be run immediately after a merge starts (activate the option <guilabel>Run regular expression auto merge on merge start</guilabel>) or later via <menuchoice><guimenu>Merge</guimenu><guimenuitem>Run Regular Expression Auto Merge</guimenuitem></menuchoice> menu item. 0524 </para><para> 0525 Automatic merge for version control history (also called "log") is also supported. The history auto-merge can either run immediately when the merge starts by activating the option <guilabel>Merge version control history on merge start</guilabel> at <guilabel>Merge</guilabel> item in the settings dialog or later via the <menuchoice><guimenu>Merge</guimenu><guimenuitem>Automatically Solve History Conflicts</guimenuitem></menuchoice> menu item. 0526 </para><para> 0527 Usually the version control history begins with a line containing the keyword "<literal>$Log$</literal>". This must be matched by the <guilabel>History start regular expression:</guilabel> option. &kdiff3; detects which subsequent lines are in the history by analysing the leading characters that came before the "<literal>$Log$</literal>" keyword. If the same "leading comment" characters also appears in the following lines, then they are also included in the history. 0528 </para><para> 0529 During each check-in the VCS writes a unique line specifying version-, date- and time-information 0530 followed by lines with user comments. 0531 These lines form one history-entry. This history section grows with every check-in and the 0532 most recent entries appear at the top (after the history start line). 0533 </para><para> 0534 When for parallel development two or more developers check-in a branch of the file then 0535 the merge history will contain several entries that appear as conflicts during the merge 0536 of the branches. Since merging these can become very tedious, &kdiff3; offers support with two 0537 possible strategies: Just insert the history information from both contributors at the top 0538 or sort the history information by a user defined key. 0539 </para><para> 0540 The just-insert-all-entries-method is easier to configure. &kdiff3; just needs a method to detect, which lines belong to one history entry. Most VCS insert an empty line after each history entry. If there are no other empty lines, this is a sufficient criterion for &kdiff3;. Just set an empty <guilabel>History entry start regular expression</guilabel> at <guilabel>Merge</guilabel> item in the settings dialog. If the empty line criterion isn't sufficient, you can specify a regular expression to detect the history entry start. 0541 </para><para> 0542 Note that &kdiff3; will remove duplicate history entries. If a history entry appeared several times 0543 in the history of a input file, only one entry will remain in the output. 0544 </para><para> 0545 If you want to sort the history, then you have to specify how the sort key should be built. Use parentheses in the <guilabel>History entry start regular expression</guilabel> at <guilabel>Merge</guilabel> item in the settings dialog to group parts of the regular expression that should later be used for the sort key. Then specify the <guilabel>History entry start sort key order</guilabel> option specifying a comma "," separated list of numbers referring to the position of the group in the regular expression. 0546 </para><para> 0547 Because this is not so easy to get right immediately, you are able to test and improve the regular expressions and key-generation in a dedicated dialog by pressing the <guibutton>Test your regular expressions</guibutton> button. 0548 </para><para>Example: Assume a history that looks like this: 0549 </para> 0550 <screen> 0551 /************************************************************************** 0552 ** HISTORY: $Log: \toms_merge_main_view\MyApplication\src\complexalgorithm.cpp $ 0553 ** 0554 ** \main\integration_branch_12 2 Apr 2001 10:45:41 tom 0555 ** Merged branch simon_branch_15. 0556 ** 0557 ** \main\henry_bugfix_branch_7\1 30 Mar 2001 19:22:05 henry 0558 ** Improved the speed for subroutine convertToMesh(). 0559 ** Fixed crash. 0560 **************************************************************************/ 0561 </screen> 0562 <para> 0563 The history start line matches the regular expression "<literal>.*\$Log.*\$.*</literal>". Then follow the history entries. 0564 </para><para> 0565 The line with the "<literal>$Log$</literal>" keyword begins with two "*" after which follows a space. &kdiff3; uses the first non-white-space string as "leading comment" and assumes that the history ends in the first line without this leading comment. In this example the last line ends with a string that also starts with two "*", but instead of a space character more "*" follow. Hence this line ends the history. 0566 </para><para> 0567 If history sorting isn't required then the history entry start line regular expression 0568 could look like this. (This line is split in two because it wouldn't fit otherwise.) 0569 </para> 0570 <screen> 0571 \s*\\main\\\S+\s+[0-9]+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) 0572 [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\s+.* 0573 </screen> 0574 <para> 0575 For details about regular expressions please see the <ulink url="https://doc.qt.io/qt-5/qregularexpression.html">regular expression documentation</ulink>. Note that "<literal>\s</literal>" (with lowercase "<literal>s</literal>") matches any white space and "<literal>\S</literal>" (with uppercase "<literal>S</literal>") matches any non-white-space. In our example the history entry start contains first the version info with reg. exp. "<literal>\\main\\\S+</literal>", the date consisting of day "<literal>[0-9]+</literal>", month "<literal>(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)</literal>" and year "<literal>[0-9][0-9][0-9][0-9]</literal>", the time "<literal>[0-9][0-9]:[0-9][0-9]:[0-9][0-9]</literal>" and finally the developers login name "<literal>.*</literal>". 0576 </para><para> 0577 Note that the "leading comment" characters (in the example "<literal>**</literal>") will already be removed by &kdiff3; before trying to match, hence the regular expression begins with a match for none or more white-space characters "<literal>\s*</literal>". Because comment characters can differ in each file (⪚ C/C++ uses other comment characters than a Perl script) &kdiff3; takes care of the leading comment characters and you should not specify them in the regular expression. 0578 </para><para> 0579 If you require a sorted history. Then the sortkey must be calculated. For this the 0580 relevant parts in the regular expression must be grouped by parentheses. 0581 (The extra parentheses can also stay in if history sorting is disabled.) 0582 </para> 0583 <screen> 0584 \s*\\main\\(\S+)\s+([0-9]+) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) 0585 ([0-9][0-9][0-9][0-9]) ([0-9][0-9]:[0-9][0-9]:[0-9][0-9])\s+(.*) 0586 </screen> 0587 <para> 0588 The parentheses now contain <literal>1</literal>. version info, <literal>2</literal>. day, <literal>3</literal>. month, <literal>4</literal>. year, <literal>5</literal>. time, <literal>6</literal>. name. 0589 But if we want to sort by date and time, we need to construct a key with the elements in a different order of appearance: 0590 First the year, followed by month, day, time, version info and name. Hence the sortkey order to specify is "<literal>4,3,2,5,1,6</literal>". 0591 </para><para> 0592 Because month names aren't good for sorting ("<literal>Apr</literal>" would be first) &kdiff3; detects in which order the month names were given and uses that number instead ("<literal>Apr</literal>" -> "<literal>04</literal>"). And if a pure number is found it will be transformed to a 4-digit value with leading zeros for sorting. Finally the resulting sort key for the first history entry start line will be: 0593 </para> 0594 <screen> 0595 2001 04 0002 10:45:41 integration_branch_12 tom 0596 </screen> 0597 <para> 0598 For more information also see <link linkend="mergeoptions">Merge Settings</link> section. 0599 </para> 0600 </sect2> 0601 </sect1> 0602 0603 <sect1 id="navigation"><title>Navigation And Editing</title> 0604 <para> 0605 Much navigation will be done with the scroll bars and the mouse but you can also navigate with the keys. If you click into either window then you can use the shortcuts &Left;, &Right;, &Up;, &Down;, &PgUp;, &PgDn;, &Home;, &End;, <keycombo>&Ctrl;&Home;</keycombo> and <keycombo>&Ctrl;&End;</keycombo> as you would in other programs. The overview-column next to the vertical scroll bar of the input files can also be used for navigating by clicking into it. 0606 </para><para> 0607 You can also use the <mousebutton>wheel</mousebutton> mouse to scroll up and down. 0608 </para><para> 0609 In the merge output editor you can also use the other keys for editing. 0610 You can toggle between insert and overwrite mode with the &Ins; key. (Default 0611 is insert-mode.) 0612 </para><para> 0613 A click with the &LMB; into any summary column will synchronise all 0614 windows to show the beginning of the same group of lines (as explained 0615 in section <link linkend="synchronise_views">Setting The Current Group And Synchronising Merge And Diff View Position</link>). 0616 </para><para> 0617 The Button bar also contains nine navigation buttons with which you can 0618 jump to the current/first/last difference, to the previous/next difference 0619 (<keycombo>&Ctrl;&Down;</keycombo>/<keycombo>&Ctrl;&Up;</keycombo>), to the 0620 previous/next conflict (<keycombo>&Ctrl;&PgDn;</keycombo>/<keycombo>&Ctrl;&PgUp;</keycombo>), 0621 or to the previous/next unsolved conflict. Note that for &kdiff3; a "conflict" 0622 that was not automatically solved at the start of the merge stays a "conflict" 0623 even if it is solved. Hence the necessity to distinguish "unsolved conflicts". 0624 </para> 0625 <sect2 id="autoadvance"><title>Auto-Advance</title> 0626 <para> 0627 There also is a button <guibutton>Automatically Go to Next Unsolved Conflict After 0628 Source Selection</guibutton> (Auto-Advance). If you enable this, then, when one source 0629 is selected, &kdiff3; will jump to and select the next unsolved conflict 0630 automatically. This can help when you always want to choose one source only. 0631 When you need both sources, or you want to edit after selecting, then you 0632 probably want to switch this off. Before proceeding to the next unsolved conflict 0633 &kdiff3; shows you the effect of your choice for a short time. This delay is 0634 adjustable in the <guilabel>Merge</guilabel> item in the settings dialog: You can 0635 specify the <guilabel>Auto advance delay (ms):</guilabel> in milli seconds between 0 and 2000. Hint: 0636 Tired of many clicks? - Use a small Auto-Advance-delay and the shortcuts 0637 <keycombo>&Ctrl;<keycap>1</keycap></keycombo>/<keycap>2</keycap>/<keycap>3</keycap> 0638 to select <guilabel>A</guilabel>/<guilabel>B</guilabel>/<guilabel>C</guilabel> for many conflicts. 0639 </para> 0640 </sect2> 0641 </sect1> 0642 0643 <sect1 id="selections"><title>Select, Copy And Paste</title> 0644 <para> 0645 The input windows don't show a cursor, so selections must be made with the 0646 mouse by clicking with the &RMB; at the start, holding down the 0647 mousebutton and moving to the end, where you release the mouse button again. 0648 You can also select a word by double clicking it. In the merge output editor 0649 you can also select via the keyboard by holding the &Shift; key and 0650 navigation with the cursor keys. 0651 </para><para> 0652 If the selection exceeds the visible range you can move the mouse over the 0653 window borders which causes &kdiff3; to scroll in that direction. 0654 </para><para> 0655 For very large selections you can also use the navigation keys while holding down 0656 the mouse. E.g. use &PgUp; and &PgDn; to quickly go to a certain position. At the 0657 end position release the mouse button. 0658 </para><para> 0659 In order to select everything in the current window use <menuchoice><guimenu>Edit</guimenu> 0660 <guimenuitem>Select All</guimenuitem></menuchoice> menu item (<keycombo>&Ctrl;<keycap>A</keycap></keycombo>). 0661 </para><para> 0662 To copy to the clipboard you must press the <guibutton>Copy</guibutton> button (<keycombo>&Ctrl;<keycap>C</keycap></keycombo> or <keycombo>&Ctrl;&Ins;</keycombo>). But there exists an option <guilabel>Auto copy selection</guilabel> at <guilabel>Editor</guilabel> item in the settings dialog. If this is enabled, then whatever you select is copied immediately and you don't need to explicitly copy. But pay attention when using this because the contents of the clipboard might then be destroyed accidentally. 0663 </para><para> 0664 <guibutton>Cut</guibutton> (<keycombo>&Ctrl;<keycap>X</keycap></keycombo> or <keycombo>&Shift;∇</keycombo>) copies to the clipboard and deletes the selected text. 0665 </para><para> 0666 <guibutton>Paste</guibutton> (<keycombo>&Ctrl;<keycap>V</keycap></keycombo> or <keycombo>&Shift;&Ins;</keycombo>) 0667 inserts the text in the clipboard at the cursorposition or over the current selection. 0668 If you paste to either diff input window the contents of the clipboard will 0669 be shown in that window and the comparison will restart immediately. This is 0670 useful if you want to quickly grab a piece of text from somewhere and 0671 compare it with something else without first creating files. 0672 </para> 0673 </sect1> 0674 0675 <sect1 id="saving"><title>Saving</title> 0676 <para> 0677 Saving will only be allowed, when all conflicts were solved. If the file already exists and the <guilabel>Backup files</guilabel> option is enabled at <guilabel>Folder</guilabel> item in the settings dialog then the existing file will be renamed with an <literal role="extension">.orig</literal> extension, but if such a file exists it will be deleted. When you exit or start another diff-analysis and data wasn't saved yet, then &kdiff3; will ask if you want to save, cancel or proceed without saving. (&kdiff3; does not catch any signals. So if you "kill" a &kdiff3; instance then your data will be lost.) 0678 </para><para> 0679 Line endings are saved according to the normal method on the underlying operating system. For Unices each line ends with an linefeed-character "<literal>\n</literal>", while for Win32-based systems each line ends with a carriage-return + a linefeed "<literal>\r\n</literal>". &kdiff3; does not preserve the line-endings of the input files, which also means that you shouldn't use &kdiff3; with binary files. 0680 </para> 0681 </sect1> 0682 0683 <sect1 id="find"><title>Finding Strings</title> 0684 <para> 0685 You can search for a string in any text-window of &kdiff3;. The <menuchoice><guimenu>Edit</guimenu><guimenuitem>Find...</guimenuitem></menuchoice> menu item (<keycombo>&Ctrl;<keycap>F</keycap></keycombo>) opens a dialog that lets you specify the string to search for. You can also select the windows which should be searched. Searching will always start at the top. Use the <menuchoice><guimenu>Edit</guimenu><guimenuitem>Find Next...</guimenuitem></menuchoice> menu item (<keycap>F3</keycap>) to proceed to the next occurrence. If you select to search several windows then the first window will be searched from top to bottom before the search starts in the next window at the top again, &etc; 0686 </para> 0687 </sect1> 0688 0689 <sect1 id="printing"><title>Printing</title> 0690 <para> 0691 &kdiff3; supports printing for textfile differences. The <menuchoice><guimenu>File</guimenu><guimenuitem>Print...</guimenuitem></menuchoice> menu item (<keycombo>&Ctrl;<keycap>P</keycap></keycombo>) opens a dialog that allows you to select the printer and to adjust other options. 0692 </para><para> 0693 There are several possibilities to adjust the range. Due to different printing 0694 dialogs on different operating systems, the method to achieve certain range selections varies. 0695 </para> 0696 <variablelist> 0697 <varlistentry><term>All:</term><listitem><para>Print everything.</para></listitem></varlistentry> 0698 <varlistentry><term>Current:</term><listitem><para>Print a page starting at the first visible line in the window. 0699 (On systems without this option this can be achieved by specifying page number 10000 for printing.)</para></listitem></varlistentry> 0700 <varlistentry><term>Selection:</term><listitem><para> 0701 Before choosing to print select text with the mouse (like for copy and paste) 0702 in one of the diff input windows to define the start and end line. If no text 0703 in one of the diff input windows was selected, then this won't be an available 0704 choice. (On systems without this option this can be achived by specifying page 0705 number 9999 for printing.)</para></listitem></varlistentry> 0706 <varlistentry><term>Range:</term><listitem><para>Specify the first and last page. 0707 </para></listitem></varlistentry> 0708 </variablelist> 0709 <para> 0710 Other important options for printing will be taken from the normal options: 0711 </para><itemizedlist> 0712 <listitem><para>Font, font size</para></listitem> 0713 <listitem><para>Show line numbers</para></listitem> 0714 <listitem><para>Word wrap</para></listitem> 0715 <listitem><para>Colors</para></listitem> 0716 <listitem><para>&etc;</para></listitem> 0717 </itemizedlist> 0718 <para> 0719 Landscape formatting is also recommended for printing. 0720 </para> 0721 </sect1> 0722 0723 <sect1 id="options"><title>Options</title> 0724 <para> 0725 Options and the recent-file-list will be saved when you exit the program, 0726 and reloaded when you start it. (<menuchoice><guimenu>Settings</guimenu> 0727 <guimenuitem>Configure &kdiff3;...</guimenuitem></menuchoice> menu item). 0728 </para> 0729 <sect2><title>Font</title> 0730 <para> 0731 Select a fixed width font. (On some systems this dialog will also 0732 present variable width fonts, but you should not use them.) 0733 </para> 0734 </sect2> 0735 0736 <sect2><title>Colors</title> 0737 <variablelist> 0738 <varlistentry><term><guilabel>Editor and Diff Views:</guilabel></term><listitem> 0739 <variablelist> 0740 <varlistentry><term><guilabel>Foreground color:</guilabel></term><listitem><para> Usually black. </para></listitem></varlistentry> 0741 <varlistentry><term><guilabel>Background color:</guilabel></term><listitem><para> Usually white. </para></listitem></varlistentry> 0742 <varlistentry><term><guilabel>Diff background color:</guilabel></term><listitem><para> Usually light gray. </para></listitem></varlistentry> 0743 <varlistentry><term><guilabel>Color A:</guilabel></term><listitem><para> Usually dark blue. </para></listitem></varlistentry> 0744 <varlistentry><term><guilabel>Color B:</guilabel></term><listitem><para> Usually dark green. </para></listitem></varlistentry> 0745 <varlistentry><term><guilabel>Color C:</guilabel></term><listitem><para> Usually dark magenta. </para></listitem></varlistentry> 0746 <varlistentry><term><guilabel>Conflict color:</guilabel></term><listitem><para> Usually red.</para></listitem></varlistentry> 0747 <varlistentry><term><guilabel>Current range background color:</guilabel></term><listitem><para> Usually light yellow.</para></listitem></varlistentry> 0748 <varlistentry><term><guilabel>Current range diff background color:</guilabel></term><listitem><para> Usually dark yellow.</para></listitem></varlistentry> 0749 <varlistentry><term><guilabel>Color for manually aligned difference ranges:</guilabel></term><listitem><para> Usually orange.</para></listitem></varlistentry> 0750 </variablelist></listitem></varlistentry> 0751 <varlistentry><term><guilabel>Folder Comparison View:</guilabel></term><listitem> 0752 <variablelist> 0753 <varlistentry><term><guilabel>Newest file color:</guilabel></term><listitem><para> Usually green.</para></listitem></varlistentry> 0754 <varlistentry><term><guilabel>Oldest file color:</guilabel></term><listitem><para> Usually red.</para></listitem></varlistentry> 0755 <varlistentry><term><guilabel>Middle age file color:</guilabel></term><listitem><para> Usually strong yellow.</para></listitem></varlistentry> 0756 <varlistentry><term><guilabel>Color for missing files:</guilabel></term><listitem><para> Usually black.</para></listitem></varlistentry> 0757 </variablelist></listitem></varlistentry> 0758 </variablelist> 0759 <para> 0760 Changing the colors for folder comparison will be effective only when starting the next folder comparison. 0761 </para> 0762 <para> 0763 On systems with only 16 or 256 colors some colors are not available in pure 0764 form. On such systems the <guibutton>Defaults</guibutton> button will choose a pure color. 0765 </para> 0766 </sect2> 0767 0768 <sect2><title>Editor Settings</title> 0769 <variablelist> 0770 <varlistentry><term><guilabel>Tab inserts spaces</guilabel></term><listitem><para> 0771 If this is disabled and you press the 	 key, a tab-character is inserted, 0772 otherwise the appropriate amount of characters is inserted.</para></listitem></varlistentry> 0773 <varlistentry><term><guilabel>Tab size:</guilabel></term><listitem><para> 0774 Can be adjusted for your specific needs. Default is <literal>8</literal>.</para></listitem></varlistentry> 0775 <varlistentry><term><guilabel>Auto indentation</guilabel></term><listitem><para> 0776 When pressing &Enter; or <keycap>Return</keycap> the indentation of the previous 0777 line is used for the new line.</para></listitem></varlistentry> 0778 <varlistentry><term><guilabel>Auto copy selection</guilabel></term><listitem><para> 0779 Every selection is immediately copied to the clipboard when active and you needn't 0780 explicitly copy it.</para></listitem></varlistentry> 0781 <varlistentry><term><guilabel>Line end style:</guilabel></term><listitem><para> 0782 When saving you can select what line end style you prefer. The default setting is 0783 the common choice for the used operating system.</para></listitem></varlistentry> 0784 </variablelist> 0785 </sect2> 0786 0787 <sect2 id="diffoptions"><title>Diff Settings</title> 0788 <para> 0789 When comparing files, &kdiff3; first it tries to match lines that are equal 0790 in all input files. Only during this step it might ignore white space. The 0791 second step compares each line. In this step white space will not be ignored. 0792 Also during the merge white space will not be ignored. 0793 </para> 0794 0795 <variablelist> 0796 <varlistentry><term><guilabel>Ignore numbers (treat as white space)</guilabel></term><listitem><para> Default is off. Number characters ('0'-'9', '.', '-') 0797 will be ignored in the first part of the analysis in which the line matching is 0798 done. In the result the differences will be shown nevertheless, but they are treated 0799 as white space. 0800 </para></listitem></varlistentry> 0801 <varlistentry><term><guilabel>Ignore C/C++ comments (treat as white space)</guilabel></term><listitem><para> Default is off. 0802 Changes in comments will be treated like changes in white space. 0803 </para></listitem></varlistentry> 0804 <varlistentry><term><guilabel>Ignore case (treat as white space)</guilabel></term><listitem><para> Default is off. 0805 Case-differences of characters (like 'A' vs. 'a') will be treated like changes in white space. 0806 </para></listitem></varlistentry> 0807 <varlistentry><term><guilabel>Preprocessor command:</guilabel></term><listitem><para> 0808 See <link linkend="preprocessors">next section</link>. 0809 </para></listitem></varlistentry> 0810 <varlistentry><term><guilabel>Line-matching preprocessor command:</guilabel></term><listitem><para> 0811 See <link linkend="preprocessors">next section</link>. 0812 </para></listitem></varlistentry> 0813 <varlistentry><term><guilabel>Try hard (slower)</guilabel></term><listitem><para> 0814 Try hard to find an even smaller delta. (Default is on.) This will probably 0815 be effective for complicated and big files. And slow for very big files. 0816 </para></listitem></varlistentry> 0817 <varlistentry><term><guilabel>Align B and C for 3 input files</guilabel></term><listitem><para> 0818 Try to align <guilabel>B</guilabel> and <guilabel>C</guilabel> when comparing 0819 or merging three input files. Not recommended for merging because merge might 0820 get more complicated. (Default is off.) 0821 </para></listitem></varlistentry> 0822 </variablelist> 0823 </sect2> 0824 0825 <sect2 id="mergeoptions"><title>Merge Settings</title> 0826 <variablelist> 0827 <varlistentry><term><guilabel>Auto advance delay (ms):</guilabel></term><listitem><para> 0828 When in auto-advance-mode this setting specifies how long to show the result of the 0829 selection before jumping to the next unsolved conflict. 0830 </para></listitem></varlistentry> 0831 <varlistentry><term><guilabel>Show info dialogs</guilabel></term><listitem><para> 0832 Show a dialog with information about the number of conflicts. 0833 </para></listitem></varlistentry> 0834 <varlistentry><term><guilabel>White space 2/3-file merge default:</guilabel></term><listitem><para> 0835 Automatically solve all white-space conflict by choosing the specified file. 0836 (Default is manual choice.) Useful if white space really isn't important in many files. 0837 If you need this only occasionally better use <guilabel>Choose A/B/C for All 0838 Unsolved Whitespace Conflicts</guilabel> in the <guimenu>Merge</guimenu> menu. Note that 0839 if you enable either <guilabel>Ignore numbers (treat as white space)</guilabel> or 0840 <guilabel>Ignore C/C++ comments (treat as white space)</guilabel> then this auto-choice 0841 also applies for conflicts in numbers or comments. 0842 </para></listitem></varlistentry> 0843 <varlistentry><term><guilabel>Auto merge regular expression:</guilabel></term><listitem><para> 0844 Regular expression for lines where &kdiff3; should automatically choose one source. See also <link linkend="vcskeywordsmergesupport">Automatic Merge...</link>. 0845 </para></listitem></varlistentry> 0846 <varlistentry><term><guilabel>Run regular expression auto merge on merge start</guilabel></term><listitem><para> 0847 If activated &kdiff3; runs the automatic merge using the <guilabel>Auto merge regular expression:</guilabel> option when a merge is started. 0848 </para></listitem></varlistentry> 0849 <varlistentry><term><guilabel>History entry start regular expression:</guilabel></term><listitem><para> 0850 Regular expression for the start of the merge history entry. 0851 Usually this line contains the "<literal>$Log$</literal>" keyword. 0852 Default value: "<literal>.*\$Log.*\$.*</literal>" 0853 </para></listitem></varlistentry> 0854 <varlistentry><term><guilabel>History entry start regular expression:</guilabel></term><listitem><para> 0855 A merge history entry consists of several lines. 0856 Specify the regular expression to detect the first line (without the leading comment). 0857 Use parentheses to group the keys you want to use for sorting. 0858 If left empty, then &kdiff3; assumes that empty lines separate history entries. 0859 See also <link linkend="vcskeywordsmergesupport">Automatic Merge...</link>. 0860 </para></listitem></varlistentry> 0861 <varlistentry><term><guilabel>History merge sorting</guilabel></term><listitem><para> 0862 Enable version control history sorting. 0863 </para></listitem></varlistentry> 0864 <varlistentry><term><guilabel>History entry start sort key order:</guilabel></term><listitem><para> 0865 Each pair of parentheses used in the regular expression for the history start entry 0866 groups a key that can be used for sorting. 0867 Specify the list of keys (that are numbered in order of occurrence 0868 starting with <literal>1</literal>) using ',' as separator (⪚ "<literal>4,5,6,1,2,3,7</literal>"). 0869 If left empty, then no sorting will be done. 0870 See also <link linkend="vcskeywordsmergesupport">Automatic Merge...</link>. 0871 </para></listitem></varlistentry> 0872 <varlistentry><term><guilabel>Merge version control history on merge start</guilabel></term><listitem><para> 0873 If activated &kdiff3; runs the automatic history merging using aforementioned options when a merge is started. 0874 </para></listitem></varlistentry> 0875 <varlistentry><term><guilabel>Max number of history entries:</guilabel></term><listitem><para> 0876 &kdiff3; truncates the history list after the specified number of entries. Use <literal>-1</literal> to avoid truncation. (Default is <literal>-1</literal>). 0877 </para></listitem></varlistentry> 0878 <varlistentry><term><guilabel>Test your regular expressions</guilabel></term><listitem><para> 0879 This button shows a dialog that allows you to improve and test the regular expressions above. 0880 Just copy the respective data from your files into the example lines. The <guilabel>Match result:</guilabel> option will immediately show whether the match succeeds or not. 0881 The <guilabel>Sort key result:</guilabel> will display the key used for history merge sorting. 0882 </para></listitem></varlistentry> 0883 <varlistentry><term><guilabel>Irrelevant merge command:</guilabel></term><listitem><para> 0884 Specify a command of your own that should be called when &kdiff3; detects 0885 that for a three file merge the file from <guilabel>B</guilabel> doesn't contribute any 0886 relevant data that isn't already contained in the file from <guilabel>C</guilabel>. 0887 The command is called with the three filenames as parameters. 0888 Data matched by the <guilabel>Auto merge regular expression</guilabel> or in the 0889 history isn't considered relevant. 0890 </para></listitem></varlistentry> 0891 <varlistentry><term><guilabel>Auto save and quit on merge without conflicts</guilabel></term><listitem><para> 0892 If &kdiff3; was started for a file-merge from the command line and all conflicts are 0893 solvable without user interaction then automatically save and quit. 0894 (Similar to command line option <option>--auto</option>.) 0895 </para></listitem></varlistentry> 0896 </variablelist> 0897 0898 </sect2> 0899 0900 <sect2><title>Folder Merge</title> 0901 <para> 0902 These options are concerned with scanning the folder and handling the 0903 merge: See the <link linkend="dirmergeoptions">Folder Comparison/Merge 0904 Docs</link> for details. 0905 </para><para> 0906 Yet there is one option here that is also relevant for saving single files: 0907 </para> 0908 <variablelist> 0909 <varlistentry><term><guilabel>Backup files (.orig)</guilabel></term><listitem><para> When a file is saved and an older version already exists, then the original version will be renamed with an <literal role="extension">.orig</literal> extension. If an old backup file with <literal role="extension">.orig</literal> extension already exists then this will be deleted without backup. 0910 </para></listitem></varlistentry> 0911 </variablelist> 0912 </sect2> 0913 0914 <sect2><title>Regional and Language Options</title> 0915 <variablelist> 0916 <varlistentry><term><guilabel>Use the same encoding for everything</guilabel></term><listitem><para>The following encoding options can be adjusted separately for each item or if this option is true, all values will take the first value. 0917 </para></listitem></varlistentry> 0918 <varlistentry><term><guilabel>Note: Local Encoding is "..."</guilabel></term><listitem><para>Above the codec-selectors appears this note that tells you what the local encoding is. (This is not adjustable but for your information just in case you don't know your local encoding, but need to select it.) 0919 </para></listitem></varlistentry> 0920 <varlistentry><term><guilabel>Auto Detect</guilabel></term><listitem><para> This option attempts to use the BOM or meta data from XML/HTML documents to detect encoding. Failing that it will check if a short sample from the beginning of the file can be interpreted as UTF-8. If this check passes UTF-8 will be used. Otherwise it will fall back to the user selected codec. Only UTF-8 is supported with no BOM or metadata present. 0921 </para></listitem></varlistentry> 0922 <varlistentry><term><guilabel>File Encoding for A/B/C:</guilabel></term><listitem><para> Adjust the file encoding for input files. This has an effect on how the special characters are interpreted. Since you can adjust each codec separately you can even compare and merge files that were saved using different codecs. 0923 </para></listitem></varlistentry> 0924 <varlistentry><term><guilabel>File Encoding for Merge Output and Saving:</guilabel></term><listitem><para> When you have edited a file, then you can adjust which encoding will be used when saving to disk. 0925 </para></listitem></varlistentry> 0926 <varlistentry><term><guilabel>File Encoding for Preprocessor Files:</guilabel></term><listitem><para>When you define preprocessors then they might not be able to operate on your codec. (⪚: Your files are 16 bit unicode and your preprocessor can only take 8 bit &ASCII;.) With this option you can define the encoding of preprocessor output. 0927 </para></listitem></varlistentry> 0928 <varlistentry><term><guilabel>Right To Left Language:</guilabel></term><listitem><para>Some languages are written right to left. When this option is enabled, &kdiff3; draws the text from right to left in the diff input windows and in the merge output window. Note that if you start &kdiff3; with the command line option <option>--reverse</option> then all layouting will be done right to left too. (This is a feature provided by &Qt;.) 0929 </para><note><para> 0930 This documentation was written assuming that this option or reverse layout are disabled. So some references to "left" or "right" must be replaced by their respective counterpart if you use these options. 0931 </para></note></listitem></varlistentry> 0932 0933 </variablelist> 0934 </sect2> 0935 0936 <sect2><title>Miscellaneous</title> 0937 <para>(These options and actions are available in menus or the buttonbar.)</para> 0938 <variablelist> 0939 <varlistentry><term><emphasis>Overview options:</emphasis></term><listitem><para> 0940 These choices are only available when you compare three files. In normal mode all 0941 differences are shown in one color-coded overview-column. But sometimes you are 0942 especially interested in the differences between only two of these three files. 0943 Selecting "A vs. B", "A vs. C" or "B vs. C"-overview will show a second overview 0944 column with the required information next to the normal overview. 0945 </para></listitem></varlistentry> 0946 <varlistentry><term><guimenuitem>Word Wrap Diff Windows</guimenuitem></term><listitem><para> 0947 Wrap lines when their length would exceed the width of a window. 0948 </para></listitem></varlistentry> 0949 <varlistentry><term><guibutton>Show Window A/B/C:</guibutton></term><listitem><para> Sometimes you want to use the space on 0950 the screen better for long lines. Hide the windows that are not important. 0951 (In the Windows-menu.)</para></listitem></varlistentry> 0952 <varlistentry><term><guibutton>Toggle Split Orientation</guibutton></term><listitem><para> 0953 Switch between diff windows shown next to each other (<guilabel>A</guilabel> left of <guilabel>B</guilabel> left of <guilabel>C</guilabel>) or above each other (<guilabel>A</guilabel> above <guilabel>B</guilabel> above <guilabel>C</guilabel>). This should also help for long lines. (In the <guimenu>Window</guimenu> menu.) 0954 </para></listitem></varlistentry> 0955 <varlistentry><term><guibutton>Merge Current File</guibutton></term><listitem><para> Works if you only compare 0956 two files. A single click starts the merge and uses the filename of the last 0957 input-file as the default output filename. (When this is used to restart 0958 a merge, then the output filename will be preserved.)</para></listitem></varlistentry> 0959 <varlistentry><term><guibutton>Show White Space</guibutton></term><listitem><para> Turn this off to suppress 0960 any highlighting of white-space-only changes in the text or overview-columns. 0961 (Note that this also applies to changes in numbers or comments if the options 0962 <guilabel>Ignore numbers (treat as white space)</guilabel> or <guilabel>Ignore C/C++ comments 0963 (treat as white space)</guilabel> are active.)</para></listitem></varlistentry> 0964 <varlistentry><term><guibutton>Show Space && Tabulator Characters</guibutton></term><listitem><para> Sometimes 0965 the visible spaces and tabs are disturbing. You can turn this off.</para></listitem></varlistentry> 0966 <varlistentry><term><guibutton>Show Line Numbers</guibutton></term><listitem><para> You can select if line numbers should be 0967 shown for the input files.</para></listitem></varlistentry> 0968 </variablelist> 0969 </sect2> 0970 0971 <sect2 id="shortcuts"><title>Configuring Keyboard-Shortcuts</title> 0972 <para> 0973 Currently only the &frameworks; version supports user-configurable keyboard-shortcuts. 0974 (Menu <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure Shortcuts...</guimenuitem></menuchoice>) 0975 </para> 0976 </sect2> 0977 </sect1> 0978 0979 <sect1 id="preprocessors"><title>Preprocessor Commands</title> 0980 <para> 0981 &kdiff3; supports two preprocessor options. 0982 </para><para> 0983 <variablelist> 0984 <varlistentry><term><guilabel>Preprocessor command:</guilabel></term><listitem><para> 0985 When any file is read, it will be piped through this external command. 0986 The output of this command will be visible instead of the original file. 0987 You can write your own preprocessor that fulfills your specific needs. 0988 Use this to cut away disturbing parts of the file, or to automatically 0989 correct the indentation &etc; 0990 </para></listitem></varlistentry> 0991 <varlistentry><term><guilabel>Line-matching preprocessor command:</guilabel></term><listitem><para> 0992 When any file is read, it will be piped through this external command. If 0993 a preprocessor-command (see above) is also specified, then the output of the 0994 preprocessor is the input of the line-matching preprocessor. 0995 The output will only be used during the line matching phase of the analysis. 0996 You can write your own preprocessor that fulfills your specific needs. 0997 Each input line must have a corresponding output line. 0998 </para></listitem></varlistentry> 0999 </variablelist> 1000 </para> 1001 <para> 1002 The idea is to allow the user greater flexibility while configuring the diff-result. 1003 But this requires an external program, and many users don't want to write one themselves. 1004 The good news is that very often <command>sed</command> or <command>perl</command> 1005 will do the job. 1006 </para> 1007 <para>Example: Simple testcase: Consider file a.txt (6 lines): 1008 </para> 1009 <screen> 1010 aa 1011 ba 1012 ca 1013 da 1014 ea 1015 fa 1016 </screen> 1017 <para> 1018 And file b.txt (3 lines): 1019 </para> 1020 <screen> 1021 cg 1022 dg 1023 eg 1024 </screen> 1025 <para> 1026 Without a preprocessor the following lines would be placed next to each other: 1027 </para> 1028 <screen> 1029 aa - cg 1030 ba - dg 1031 ca - eg 1032 da 1033 ea 1034 fa 1035 </screen> 1036 <para> 1037 This is probably not wanted since the first letter contains the actually interesting information. 1038 To help the matching algorithm to ignore the second letter we can use a line matching preprocessor 1039 command, that replaces 'g' with 'a': 1040 </para> 1041 <screen> 1042 <command>sed</command> 's/g/a/' 1043 </screen> 1044 <para> 1045 With this command the result of the comparison would be: 1046 </para> 1047 <screen> 1048 aa 1049 ba 1050 ca - cg 1051 da - dg 1052 ea - eg 1053 fa 1054 </screen> 1055 <para> 1056 Internally the matching algorithm sees the files after running the line matching preprocessor, 1057 but on the screen the file is unchanged. (The normal preprocessor would change the data also on 1058 the screen.) 1059 </para> 1060 1061 <sect2 id="sedbasics"><title><command>sed</command> Basics</title> 1062 <para> 1063 This section only introduces some very basic features of <command>sed</command>. For more 1064 information see <ulink url="info:/sed">info:/sed</ulink> or 1065 <ulink url="https://www.gnu.org/software/sed/manual/html_mono/sed.html"> 1066 https://www.gnu.org/software/sed/manual/html_mono/sed.html</ulink>. 1067 A precompiled version for &Windows; can be found at <ulink url="http://unxutils.sourceforge.net"> 1068 http://unxutils.sourceforge.net</ulink>. 1069 Note that the following examples assume that the <command>sed</command> command is in some 1070 folder in the <envar>PATH</envar> environment variable. If this is not the case, you have to specify the full absolute 1071 path for the command. 1072 </para> 1073 <para> 1074 In this context only the <command>sed</command> substitute command is used: 1075 </para> 1076 <screen> 1077 <command>sed</command> 's/<replaceable>REGEXP</replaceable>/<replaceable>REPLACEMENT</replaceable>/<replaceable>FLAGS</replaceable>' 1078 </screen> 1079 <para> 1080 Before you use a new command within &kdiff3;, you should first test it in a console. 1081 Here the <command>echo</command> command is useful. Example: 1082 </para> 1083 <screen> 1084 <command>echo</command> abrakadabra | <command>sed</command> 's/a/o/' 1085 -> obrakadabra 1086 </screen> 1087 <para> 1088 This example shows a very simple sed-command that replaces the first occurrence 1089 of "a" with "o". If you want to replace all occurrences then you need the "g" flag: 1090 </para> 1091 <screen> 1092 <command>echo</command> abrakadabra | <command>sed</command> 's/a/o/g' 1093 -> obrokodobro 1094 </screen> 1095 <para> 1096 The "|"-symbol is the pipe-command that transfers the output of the previous 1097 command to the input of the following command. If you want to test with a longer file 1098 then you can use <command>cat</command> on &UNIX; like systems or <command>type</command> 1099 on &Windows; like systems. <command>sed</command> will do the substitution for each line. 1100 <screen> 1101 <command>cat</command> <replaceable>filename</replaceable> | <command>sed</command> <replaceable>options</replaceable> 1102 </screen> 1103 </para> 1104 </sect2> 1105 <sect2 id="sedforkdiff3"><title>Examples For <command>sed</command> Use In &kdiff3;</title> 1106 <sect3><title>Ignoring Other Types Of Comments</title> 1107 <para> 1108 Currently &kdiff3; understands only C/C++ comments. Using the 1109 <guilabel>Line-matching preprocessor command:</guilabel> option you can also ignore 1110 other types of comments, by converting them into C/C++-comments. 1111 </para> 1112 <para> 1113 Example: To ignore comments starting with "<literal>#</literal>", you would like to convert them to "<literal>//</literal>". Note that you also must enable the <guilabel>Ignore C/C++ comments (treat as white space)</guilabel> option to get an effect. An appropriate <guilabel>Line-matching preprocessor command:</guilabel> would be: 1114 </para> 1115 <screen> 1116 <command>sed</command> 's/#/\/\//' 1117 </screen> 1118 <para> 1119 Since for <command>sed</command> the "<literal>/</literal>" character has a special meaning, it is necessary to place the "<literal>\</literal>" character before each "<literal>/</literal>" in the replacement-string. Sometimes the "<literal>\</literal>" is required to add or remove a special meaning of certain characters. The single quotation marks (') are only important when testing on the command shell as it will otherwise attempt to process some characters. 1120 &kdiff3; does not do this except for the escape sequences '<literal>\"</literal>' and '<literal>\\</literal>'. 1121 </para> 1122 </sect3> 1123 <sect3><title>Caseinsensitive Diff</title> 1124 <para> 1125 Use the following <guilabel>Line-matching preprocessor command:</guilabel> to convert all input to uppercase: 1126 </para> 1127 <screen> 1128 <command>sed</command> 's/\(.*\)/\U\1/' 1129 </screen> 1130 <para> 1131 Here the "<literal>.*</literal>" is a regular expression that matches any string and in this context matches all characters in the line. 1132 The "<literal>\1</literal>" in the replacement string refers to the matched text within the first pair of "<literal>\(</literal>" and "<literal>\)</literal>". 1133 The "<literal>\U</literal>" converts the inserted text to uppercase. 1134 </para> 1135 </sect3> 1136 1137 <sect3><title>Ignoring Version Control Keywords</title> 1138 <para> 1139 CVS and other version control systems use several keywords to insert automatically 1140 generated strings (<ulink url="info:/cvs/Keyword substitution">info:/cvs/Keyword substitution</ulink>). 1141 All of them follow the pattern "<replaceable>$KEYWORD generated text$</replaceable>". We now need a 1142 line-matching preprocessor command that removes only the generated text: 1143 </para> 1144 <screen> 1145 <command>sed</command> 's/\$\(Revision\|Author\|Log\|Header\|Date\).*\$/\$\1\$/' 1146 </screen> 1147 <para> 1148 The "<literal>\|</literal>" separates the possible keywords. You might want to modify this list 1149 according to your needs. 1150 The "<literal>\</literal>" before the "<literal>$</literal>" is necessary because otherwise the "<literal>$</literal>" matches the end of the line. 1151 </para> 1152 <para> 1153 While experimenting with <command>sed</command> you might come to understand and even like 1154 these regular expressions. They are useful because there are many other programs that also 1155 support similar things. 1156 </para> 1157 </sect3> 1158 1159 <sect3><title>Ignoring Numbers</title> 1160 <para> 1161 Ignoring numbers actually is a built-in option. But as another example, this is how 1162 it would look as a line-matching preprocessor command. 1163 </para> 1164 <screen> 1165 <command>sed</command> 's/[0123456789.-]//g' 1166 </screen> 1167 <para> 1168 Any character within '<literal>[</literal>' and '<literal>]</literal>' is a match and will be replaced with nothing. 1169 </para> 1170 </sect3> 1171 1172 <sect3><title>Ignoring Certain Columns</title> 1173 <para> 1174 Sometimes a text is very strictly formatted, and contains columns that you always want to ignore, while there are 1175 other columns you want to preserve for analysis. In the following example the first five columns (characters) are 1176 ignored, the next ten columns are preserved, then again five columns are ignored and the rest of the line is preserved. 1177 </para> 1178 <screen> 1179 <command>sed</command> 's/.....\(..........\).....\(.*\)/\1\2/' 1180 </screen> 1181 <para> 1182 Each dot '<literal>.</literal>' matches any single character. The "<literal>\1</literal>" and "<literal>\2</literal>" in the replacement string refer to the matched text within the first 1183 and second pair of "<literal>\(</literal>" and "<literal>\)</literal>" denoting the text to be preserved. 1184 </para> 1185 </sect3> 1186 1187 <sect3><title>Combining Several Substitutions</title> 1188 <para> 1189 Sometimes you want to apply several substitutions at once. You can then use the 1190 semicolon '<literal>;</literal>' to separate these from each other. Example: 1191 </para> 1192 <screen> 1193 <command>echo</command> abrakadabra | <command>sed</command> 's/a/o/g;s/\(.*\)/\U\1/' 1194 -> OBROKODOBRO 1195 </screen> 1196 </sect3> 1197 1198 <sect3><title>Using <command>perl</command> instead of <command>sed</command></title> 1199 <para> 1200 Instead of <command>sed</command> you might want to use something else like 1201 <command>perl</command>. 1202 </para> 1203 <screen> 1204 <command>perl</command> -p -e 's/<replaceable>REGEXP</replaceable>/<replaceable>REPLACEMENT</replaceable>/<replaceable>FLAGS</replaceable>' 1205 </screen> 1206 <para> 1207 But some details are different in <command>perl</command>. Note that where 1208 <command>sed</command> needed "<literal>\(</literal>" and "<literal>\)</literal>" <command>perl</command> 1209 requires the simpler "<literal>(</literal>" and "<literal>)</literal>" without preceding '<literal>\</literal>'. Example: 1210 </para> 1211 <screen> 1212 <command>sed</command> 's/\(.*\)/\U\1/' 1213 <command>perl</command> -p -e 's/(.*)/\U\1/' 1214 </screen> 1215 </sect3> 1216 </sect2> 1217 1218 <sect2><title>Order Of Preprocessor Execution</title> 1219 <para> 1220 The data is piped through all internal and external preprocessors in the 1221 following order: 1222 </para> 1223 <itemizedlist> 1224 <listitem><para>Normal preprocessor,</para></listitem> 1225 <listitem><para>Line-matching preprocessor,</para></listitem> 1226 <listitem><para>Ignore case (treat as white space) (conversion to uppercase),</para></listitem> 1227 <listitem><para>Detection of C/C++ comments,</para></listitem> 1228 <listitem><para>Ignore numbers (treat as white space),</para></listitem> 1229 <listitem><para>Ignore white space</para></listitem> 1230 </itemizedlist> 1231 <para> 1232 The data after the normal preprocessor will be preserved for display and merging. The 1233 other operations only modify the data that the line-matching-diff-algorithm sees. 1234 </para><para> 1235 In the rare cases where you use a normal preprocessor note that 1236 the line-matching-preprocessor sees the output of the normal preprocessor as input. 1237 </para> 1238 </sect2> 1239 1240 <sect2><title>Warning</title> 1241 <para> 1242 The preprocessor-commands are often very useful, but as with any option that modifies 1243 your texts or hides away certain differences automatically, you might accidentally overlook 1244 certain differences and in the worst case destroy important data. 1245 </para><para> 1246 For this reason during a merge if a normal preprocessor-command is being used &kdiff3; will tell you so and ask you if it should be disabled or not. But it won't warn you if a <guilabel>Line-matching preprocessor command:</guilabel> option is active. The merge will not complete until all conflicts are solved. If you disabled <menuchoice><guimenu>Diffview</guimenu><guimenuitem>Show White Space</guimenuitem></menuchoice> menu item then the differences that were removed with the <guilabel>Line-matching preprocessor command:</guilabel> option will also be invisible. If the <guibutton>Save</guibutton> button remains disabled during a merge (because of remaining conflicts), make sure to enable <menuchoice><guimenu>Diffview</guimenu><guimenuitem>Show White Space</guimenuitem></menuchoice> menu item. If you don't want to merge these less important differences manually 1247 you can select <menuchoice><guimenu>Merge</guimenu><guimenuitem>Choose [A|B|C] for All Unsolved Whitespace Conflicts</guimenuitem></menuchoice> menu item. 1248 </para> 1249 </sect2> 1250 </sect1> 1251 </chapter> 1252 1253 1254 <chapter id="dirmerge"><title>Folder Comparison and Merge with &kdiff3;</title> 1255 <sect1 id="dirmergeintro"><title>Introduction into Folder Comparison and Merge</title> 1256 <para> 1257 Often programmers must modify many files in a folder to achieve their 1258 purpose. For this &kdiff3; also lets you compare and merge complete folders 1259 recursively! 1260 </para><para> 1261 Even though comparing and merging folders seems to be quite obvious, 1262 there are several details that you should know about. Most important is of 1263 course the fact that now many files might be affected by each operation. 1264 If you don't have backups of your original data, then it can be very hard 1265 or even impossible to return to the original state. So before starting a merge, 1266 make sure that your data is safe, and going back is possible. If you make 1267 an archive or use some version control system is your decision, but even 1268 experienced programmers and integrators need the old sources now and then. 1269 And note that even though I (the author of &kdiff3;) try to do my best, I can't 1270 guarantee that there are no bugs. According to the &GNU; GPL there is NO WARRANTY 1271 whatsoever for this program. So be humble and always keep in mind: 1272 </para> 1273 <blockquote><para> 1274 <emphasis>To err is human, but to really mess things up you need a computer.</emphasis> 1275 </para></blockquote> 1276 <para> 1277 So this is what this program can do for you: &kdiff3; ... 1278 </para> 1279 <itemizedlist> 1280 <listitem><para>... reads and compares two or three folders recursively,</para></listitem> 1281 <listitem><para>... takes special care of symbolic links,</para></listitem> 1282 <listitem><para>... lets you browse files on mouse double click,</para></listitem> 1283 <listitem><para>... for each item proposes a merge operation, which you can change 1284 before starting the folder merge,</para></listitem> 1285 <listitem><para>... lets you simulate the merge and lists the actions that would 1286 take place, without actually doing them,</para></listitem> 1287 <listitem><para>... lets you really do the merge, and lets you interact whenever 1288 manual interaction is needed,</para></listitem> 1289 <listitem><para>... lets you run the selected operation for all items (<keycap>F7</keycap> key) or the selected item (<keycap>F6</keycap> key),</para></listitem> 1290 <listitem><para>... lets you continue the merge after manual interaction with <keycap>F7</keycap> key,</para></listitem> 1291 <listitem><para>... optionally creates backups, with the <literal role="extension">.orig</literal> extension,</para></listitem> 1292 <listitem><para>...</para></listitem> 1293 </itemizedlist> 1294 </sect1> 1295 1296 <sect1 id="startingdirmerge"><title>Starting Folder Comparison Or Merge</title> 1297 <para> 1298 This is very similar to the single file merge and comparison. You just 1299 have to specify folders on the command line or in the file-open 1300 dialog. 1301 </para> 1302 <sect2><title>Compare/Merge two folders: </title> 1303 <screen> 1304 <command>kdiff3</command> <replaceable>folder1 folder2</replaceable> 1305 <command>kdiff3</command> <replaceable>folder1 folder2</replaceable> -o <replaceable>destdir</replaceable> 1306 </screen> 1307 <para> 1308 If no destination folder is specified, then &kdiff3; will use <replaceable>folder2</replaceable>. 1309 </para> 1310 </sect2> 1311 1312 <sect2><title>Compare/Merge three folders: </title> 1313 <screen> 1314 <command>kdiff3</command> <replaceable>folder1 folder2 folder3</replaceable> 1315 <command>kdiff3</command> <replaceable>folder1 folder2 folder3</replaceable> -o <replaceable>destdir</replaceable> 1316 </screen> 1317 <para> 1318 When three folders are merged then <replaceable>folder1</replaceable> 1319 is used as the base for the merge. 1320 If no destination folder is specified, then &kdiff3; will use <replaceable>folder3</replaceable> 1321 as the destination folder for the merge. 1322 </para> 1323 1324 <para> 1325 Note that only the comparison starts automatically, not the merge. For this you first must 1326 select a menu entry or the <keycap>F7</keycap> key. (More details later.) 1327 </para> 1328 </sect2> 1329 </sect1> 1330 1331 <sect1 id="dirmergevisible"><title>Folder Merge Visible Information</title> 1332 <para> 1333 While reading the folders a message-box appears that informs you of 1334 the progress. If you abort the folder scan, then only files that have 1335 been compared until then will be listed. 1336 </para><para> 1337 When the folder scan is complete then &kdiff3; will show a listbox with 1338 the results left, ... 1339 </para> 1340 <screenshot><mediaobject> 1341 <imageobject><imagedata fileref="dirbrowser.png" format="PNG"/></imageobject> <!--alt="Image of the folder browser."--> 1342 </mediaobject></screenshot> 1343 <para> 1344 ... and details about the currently selected item on the right: 1345 </para> 1346 <screenshot><mediaobject> 1347 <imageobject><imagedata fileref="iteminfo.png" format="PNG"/></imageobject> 1348 <!--alt="Image with information about the selected item."--> 1349 </mediaobject></screenshot> 1350 1351 <sect2 id="name"><title>The Name Column</title> 1352 <para> 1353 Each file and folder that was found during the scan is shown here in 1354 a tree. You can select an item by clicking it with the mouse once. 1355 </para><para> 1356 The folders are collapsed by default. You can expand and collapse 1357 them by clicking on the "+"/"-" or by double-clicking the item or 1358 by using the &Left;/&Right; cursor keys. The <guimenu>Folder</guimenu> menu also contains two 1359 actions <guimenuitem>Fold All Subfolders</guimenuitem> and <guimenuitem>Unfold All Subfolders</guimenuitem> with which you can 1360 collapse or expand all folders at once. 1361 </para><para> 1362 If you double-click a file item then the file comparison starts and the 1363 file-diff-window will appear. 1364 </para> 1365 <para> 1366 The image in the name column reflects the file type in the first 1367 folder (<guilabel>A</guilabel>). It can be one of these: 1368 </para> 1369 <itemizedlist> 1370 <listitem><para>Normal file</para></listitem> 1371 <listitem><para>Normal folder (folder image)</para></listitem> 1372 <listitem><para>Link to a file (file image with a link arrow)</para></listitem> 1373 <listitem><para>Link to a folder (folder image with a link arrow)</para></listitem> 1374 </itemizedlist> 1375 <para> 1376 If the file type is different in the other folders, then this is visible 1377 in the columns <guilabel>A</guilabel>/<guilabel>B</guilabel>/<guilabel>C</guilabel> 1378 and in the window that shows the details about the selected item. Note that 1379 for such a case no merge operation can be selected automatically. When starting 1380 the merge, then the user will be informed of problems of that kind. 1381 </para> 1382 </sect2> 1383 1384 <sect2 id="coloring"><title>The Columns A/B/C and the Coloring Scheme</title> 1385 <para> 1386 As can be seen in the image above the colors red, green, yellow and black 1387 are used in the columns <guilabel>A</guilabel>/<guilabel>B</guilabel>/<guilabel>C</guilabel>. 1388 </para> 1389 <itemizedlist> 1390 <listitem><para>Black: This item doesn't exist in this folder.</para></listitem> 1391 <listitem><para>Green: Newest item.</para></listitem> 1392 <listitem><para>Yellow: Older than green, newer than red.</para></listitem> 1393 <listitem><para>Red: Oldest item.</para></listitem> 1394 </itemizedlist> 1395 <para> 1396 But for items that were identical in the comparison their color also is 1397 identical even if the age is not. 1398 </para><para> 1399 Folders are considered equal if all items they contain are identical. 1400 Then they also will have the same color. But the age of a folder is not 1401 considered for its color. 1402 </para><para> 1403 The idea for this coloring scheme I came upon in 1404 <ulink url="https://www.samba.org/ftp/paulus/"><command>dirdiff</command> command</ulink>. The colors 1405 resemble the colors of a leaf that is green when new, turns yellow later and red 1406 when old. 1407 </para> 1408 1409 </sect2><sect2 id="operation"><title>The Operation Column</title> 1410 <para> 1411 After comparing the folders &kdiff3; also evaluates a proposal for a 1412 merge operation. This is shown in the <guilabel>Operation</guilabel> column. You can modify 1413 the operation by clicking on the operation you want to change. A small menu 1414 will popup and allows you to select an operation for that item. (You can also 1415 select the most needed operations via keyboard. 1416 <keycombo>&Ctrl;<keycap>1</keycap></keycombo>/<keycap>2</keycap>/<keycap>3</keycap>/<keycap>4</keycap>/∇ 1417 will select <guilabel>A</guilabel>/<guilabel>B</guilabel>/<guilabel>C</guilabel>/<guilabel>Merge</guilabel>/ 1418 <guilabel>Delete</guilabel> respectively if available.) This operation will be executed during the merge. 1419 It depends on the item and on the merge-mode you are in, what operations are available. The merge-mode is one of 1420 </para> 1421 <itemizedlist> 1422 <listitem><para>Three-folder merge (<guilabel>A</guilabel> is treated as older base of both).</para></listitem> 1423 <listitem><para>Two-folder merge.</para></listitem> 1424 <listitem><para>Two-folder sync-mode (activate via <guilabel>Synchronize folders</guilabel> option).</para></listitem> 1425 </itemizedlist> 1426 <para> 1427 In three-folder merge the operation proposal will be: If for an item ... 1428 </para> 1429 <itemizedlist> 1430 <listitem><para> 1431 ... all three folders are equal: Copy from <guilabel>C</guilabel> 1432 </para></listitem> 1433 <listitem><para> 1434 ... <guilabel>A</guilabel> and <guilabel>C</guilabel> are equal but <guilabel>B</guilabel> is not: Copy from <guilabel>B</guilabel> (or if <guilabel>B</guilabel> does not exist, delete the destination if exists) 1435 </para></listitem> 1436 <listitem><para> 1437 ... <guilabel>A</guilabel> and <guilabel>B</guilabel> are equal but <guilabel>C</guilabel> is not: Copy from <guilabel>C</guilabel> (or if <guilabel>C</guilabel> does not exist, delete the destination if exists) 1438 </para></listitem> 1439 <listitem><para> 1440 ... <guilabel>B</guilabel> and <guilabel>C</guilabel> are equal but <guilabel>A</guilabel> is not: Copy from <guilabel>C</guilabel> (or if <guilabel>C</guilabel> does not exist, delete the destination if exists) 1441 </para></listitem> 1442 <listitem><para> 1443 ... only <guilabel>A</guilabel> exists: Delete the destination (if exists) 1444 </para></listitem> 1445 <listitem><para> 1446 ... only <guilabel>B</guilabel> exists: Copy from <guilabel>B</guilabel> 1447 </para></listitem> 1448 <listitem><para> 1449 ... only <guilabel>C</guilabel> exists: Copy from <guilabel>C</guilabel> 1450 </para></listitem> 1451 <listitem><para> 1452 ... <guilabel>A</guilabel>, <guilabel>B</guilabel> and <guilabel>C</guilabel> are not equal: Merge 1453 </para></listitem> 1454 <listitem><para> 1455 ... <guilabel>A</guilabel>, <guilabel>B</guilabel> and <guilabel>C</guilabel> don't have the same file type (⪚ <guilabel>A</guilabel> is a folder, <guilabel>B</guilabel> is a file): "Error: Conflicting File Types". While such items exist the folder merge cannot start. 1456 </para></listitem> 1457 </itemizedlist> 1458 <para> 1459 In two-folder merge the operation proposal will be: If for an item ... 1460 </para> 1461 <itemizedlist> 1462 <listitem><para> 1463 ... both folders are equal: Copy from <guilabel>B</guilabel> 1464 </para></listitem> 1465 <listitem><para> 1466 ... <guilabel>A</guilabel> exists, but not <guilabel>B</guilabel>: Copy from <guilabel>A</guilabel> 1467 </para></listitem> 1468 <listitem><para> 1469 ... <guilabel>B</guilabel> exists, but not <guilabel>A</guilabel>: Copy from <guilabel>B</guilabel> 1470 </para></listitem> 1471 <listitem><para> 1472 ... <guilabel>A</guilabel> and <guilabel>B</guilabel> exist but are not equal: Merge 1473 </para></listitem> 1474 <listitem><para> 1475 ... <guilabel>A</guilabel> and <guilabel>B</guilabel> don't have the same file type (⪚ <guilabel>A</guilabel> is a folder, <guilabel>B</guilabel> is a file): "Error: Conflicting File Types". While such items exist the folder merge cannot start. 1476 </para></listitem> 1477 </itemizedlist> 1478 <para> 1479 Sync-mode is active if only two folders and no explicit destination 1480 were specified and if the <guilabel>Synchronize folders</guilabel> option is active. &kdiff3; 1481 then selects a default operation so that both folders are the same afterwards. 1482 If for an item ... 1483 </para> 1484 <itemizedlist> 1485 <listitem><para> 1486 ... both folders are equal: Nothing will be done. 1487 </para></listitem> 1488 <listitem><para> 1489 ... <guilabel>A</guilabel> exists, but not <guilabel>B</guilabel>: Copy <guilabel>A</guilabel> to <guilabel>B</guilabel> 1490 </para></listitem> 1491 <listitem><para> 1492 ... <guilabel>B</guilabel> exists, but not <guilabel>A</guilabel>: Copy <guilabel>B</guilabel> to <guilabel>A</guilabel> 1493 </para></listitem> 1494 <listitem><para> 1495 ... <guilabel>A</guilabel> and <guilabel>B</guilabel> exist, but are not equal: Merge and store the result in both folders. (For the user the visible save-filename is <guilabel>B</guilabel>, but then &kdiff3; copies <guilabel>B</guilabel> also to <guilabel>A</guilabel>.) 1496 </para></listitem> 1497 <listitem><para> 1498 ... <guilabel>A</guilabel> and <guilabel>B</guilabel> don't have the same file type (⪚ <guilabel>A</guilabel> is a folder, <guilabel>B</guilabel> is a file): "Error: Conflicting File Types". While such items exist the folder merge cannot start. 1499 </para></listitem> 1500 </itemizedlist> 1501 <para> 1502 When two folders are merged and the <guilabel>Copy newer instead of merging (unsafe)</guilabel> option is selected, then &kdiff3; looks at the dates and proposes to choose the newer file. If the files are not equal but have equal dates, then the operation will contain "Error: Dates are equal but files are not." While such items exist the folder merge cannot start. 1503 </para> 1504 </sect2> 1505 1506 <sect2 id="status"><title>The Status Column</title> 1507 <para> 1508 During the merge one file after the other will be processed. The status 1509 column will show <guilabel>Done</guilabel> for items where the merge operation has succeeded, 1510 and other texts if something unexpected happened. When a merge is complete, 1511 then you should make a last check to see if the status for all items is 1512 agreeable. 1513 </para> 1514 </sect2> 1515 1516 <sect2 id="statisticscolulmns"><title>Statistics Columns</title> 1517 <para> 1518 When the file comparison mode <guilabel>Full Analysis</guilabel> is enabled in the options, then 1519 &kdiff3; will show extra columns containing the numbers of Unsolved, Solved, Nonwhite and Whitespace 1520 conflicts. (The <guilabel>Solved</guilabel> column will only show when comparing or merging three folders.) 1521 </para> 1522 </sect2> 1523 1524 <sect2 id="selectingvisiblefiles"><title>Selecting Listed Files</title> 1525 <para> 1526 Several options influence which files are listed here. Some are accessible in the 1527 <link linkend="dirmergeoptions">settings dialog</link>. The <guilabel>Folder</guilabel> menu contains the entries: 1528 </para><para><itemizedlist> 1529 <listitem><para> 1530 <guilabel>Show Identical Files</guilabel>: Files that have been detected equal in all input folders. 1531 </para></listitem> 1532 <listitem><para> 1533 <guilabel>Show Different Files</guilabel>: Files that exist in two or more folders but are not equal. 1534 </para></listitem> 1535 <listitem><para> 1536 <guilabel>Show Files only in A</guilabel>: Files that exist only in <guilabel>A</guilabel>, but not in <guilabel>B</guilabel> or <guilabel>C</guilabel>. 1537 </para></listitem> 1538 <listitem><para> 1539 <guilabel>Show Files only in B</guilabel>: Files that exist only in <guilabel>B</guilabel>, but not in <guilabel>A</guilabel> or <guilabel>C</guilabel>. 1540 </para></listitem> 1541 <listitem><para> 1542 <guilabel>Show Files only in C</guilabel>: Files that exist only in <guilabel>C</guilabel>, but not in <guilabel>A</guilabel> or <guilabel>B</guilabel>. 1543 </para></listitem> 1544 </itemizedlist></para> 1545 <para> 1546 Activate only the <guilabel>Show</guilabel> options for the items you want listed. If for example you only want to list all items that exist either in <guilabel>A</guilabel> or in <guilabel>B</guilabel> but not in both, you'll have to activate <guilabel>Show Files only in A</guilabel> and <guilabel>Show Files only in B</guilabel> and deactivate all others (<guilabel>Show Identical Files</guilabel>, <guilabel>Show Different Files</guilabel>, <guilabel>Show Files only in C</guilabel>). The list will be updated immediately to reflect the change. 1547 </para><para> 1548 These options also apply for folders with one exception: Disabling <guilabel> 1549 Show Different Files</guilabel> will not hide any complete folders. This will 1550 work only for files within. 1551 </para><para> 1552 Note that of these only the <guilabel>Show Identical Files</guilabel> option is persistant. The others are enabled when starting &kdiff3;. 1553 </para> 1554 </sect2> 1555 1556 </sect1> 1557 1558 1559 <sect1 id="dothemerge"><title>Doing A Folder Merge</title> 1560 <para> 1561 You can either merge the currently selected item (file or folder), or all items. 1562 When you have made all your operation choices (in all subfolders too) 1563 then you can start the merge. 1564 </para><para> 1565 Be aware that if you didn't specify a destination folder explicitly, then the destination will be <guilabel>C</guilabel> in three-folder mode, <guilabel>B</guilabel> in two-folder merge mode, and in sync-mode it will be <guilabel>A</guilabel> or/and <guilabel>B</guilabel>. 1566 </para><para> 1567 If you have specified a destination folder also check that all items 1568 that should be in the output, are in the tree. There are some options that 1569 cause certain items to be omitted from the folder comparison and merge. 1570 Check these options to avoid unpleasant surprises: 1571 </para> 1572 <itemizedlist> 1573 <listitem><para><guilabel>Recursive Folders</guilabel>: If this is off, then items in subfolders will not be found.</para></listitem> 1574 <listitem><para><guilabel>Pattern</guilabel>/<guilabel>Anti-Pattern</guilabel>: Include/exclude items that match</para></listitem> 1575 <listitem><para><guilabel>Exclude Hidden Files</guilabel></para></listitem> 1576 <listitem><para><link linkend="selectingvisiblefiles">Show options</link> (<guilabel>Show Identical/Different Files</guilabel>, <guilabel>Files only in A/B/C</guilabel>)</para></listitem> 1577 </itemizedlist> 1578 <para> 1579 If you change the settings in order to list more files, you must do a rescan 1580 via menu <menuchoice><guimenu>Folder</guimenu><guimenuitem>Rescan</guimenuitem> 1581 </menuchoice> yourself. (The reason for this is that for faster comparison-speed 1582 &kdiff3; omits the comparison for files suppressed by these criteria.) If you 1583 changed your file and folder patterns to exclude files, then the file-list will 1584 immediately be updated on closing the options-dialog. 1585 </para><para> 1586 Note that when you write to a completely new folder then you usually also want to copy the identical files. 1587 In that case enable the <guilabel>Show Identical Files</guilabel> option. If your destination folder is one of the inputs, 1588 then this isn't necessary because the file is already there. 1589 </para><para> 1590 If you are satisfied so far, the rest is easy. 1591 </para><para> 1592 To merge all items: Select <guimenuitem>Start/Continue Folder Merge</guimenuitem> 1593 in the <guimenu>Folder</guimenu> menu or press <keycap>F7</keycap> (which is the 1594 default shortcut). To merge only the current item: Select <guilabel>Run Operation 1595 for Current Item</guilabel> or press <keycap>F6</keycap>. 1596 </para><para> 1597 If due to conflicting filetypes some items with invalid operations still 1598 exist, then a messagebox will appear and these items will be pointed out, 1599 so you can select a valid operation for the item. 1600 </para><para> 1601 If you merge all items a dialog will appear giving you the options 1602 <guilabel>Do it</guilabel>, <guilabel>Simulate it</guilabel> and 1603 <guilabel>Cancel</guilabel>. 1604 </para> 1605 <itemizedlist> 1606 <listitem><para>Select <guilabel>Simulate it</guilabel> if you want to see what would be done without 1607 actually doing it. A verbose list of all operations will be shown.</para></listitem> 1608 <listitem><para>Otherwise select <guilabel>Do it</guilabel> to really start merging.</para></listitem> 1609 </itemizedlist> 1610 <para> 1611 Then &kdiff3; will run the specified operation for all items. If manual 1612 interaction is required (single file merge), then a merge window will open 1613 (<link linkend="dirmergebigscreenshot">see the big screenshot</link>). 1614 </para><para> 1615 When you have finished with manually merging a file, again select <guimenuitem>Start/ 1616 Continue Folder Merge</guimenuitem> or the <keycap>F7</keycap> key. If you haven't 1617 saved it yet, a dialog will ask you to do so. Then &kdiff3; will continue with the 1618 next item. 1619 </para><para> 1620 When &kdiff3; encounters an error, it will tell you so and will show the 1621 verbose-status-information. At the bottom of this list, there will be some 1622 error messages which should help you to understand the cause of the problem. 1623 When you continue merging (<keycap>F7</keycap> key) &kdiff3; will give you the choice to retry 1624 or skip the item that caused the problem. This means that before continuing 1625 you can choose another operation or solve the problem by other means. 1626 </para><para> 1627 When the merge is complete, then &kdiff3; will inform you via a message 1628 box. 1629 </para><para> 1630 If some items were merged individually before running the directorymerge then 1631 &kdiff3; remembers this (while this 1632 merge-session goes on), and doesn't merge them again when later the merge for 1633 all items is run. Even when the merge was skipped or nothing was saved these 1634 items count as completed. Only when you change the merge operation the 1635 <guilabel>Done</guilabel> status of the item will be removed and it can be merged again. 1636 </para> 1637 </sect1> 1638 1639 <sect1 id="dirmergeoptions"><title>Options for Comparing and Merging Folders</title> 1640 <para> 1641 The &kdiff3; preferences (menu <menuchoice><guimenu>Settings</guimenu> 1642 <guimenuitem>Configure &kdiff3;...</guimenuitem></menuchoice>) has 1643 a section called "Folder Merge" with these options: 1644 </para> 1645 1646 <variablelist> 1647 <varlistentry><term><guilabel>Recursive folders</guilabel></term><listitem><para> Select whether to search folders 1648 recursively.</para></listitem></varlistentry> 1649 <varlistentry><term><guilabel>File pattern(s):</guilabel></term><listitem><para> Only files that match any pattern here will 1650 be put in the tree. More than one pattern may be specified here by using 1651 the semicolon ";" as separator. Valid wildcards: '*' and '?'. (⪚ "<literal>*.cpp;*.h</literal>"). 1652 Default is "*". This pattern is not used on folders.</para></listitem></varlistentry> 1653 <varlistentry><term><guilabel>File-anti-pattern(s):</guilabel></term><listitem><para> Files that match this pattern 1654 will be excluded from the tree. More than one pattern may be specified here 1655 via using the semicolon ";" as separator. Valid wildcards: '*' and '?'. Default 1656 is "<literal>*.orig;*.o;*.obj</literal>".</para></listitem></varlistentry> 1657 <varlistentry><term><guilabel>Folder-anti-pattern(s):</guilabel></term><listitem><para> Folders that match this pattern 1658 will be excluded from the tree. More than one pattern may be specified here 1659 via using the semicolon ";" as separator. Valid wildcards: '*' and '?'. Default 1660 is "<literal>CVS;deps;.svn</literal>".</para></listitem></varlistentry> 1661 <varlistentry><term><guilabel>Use Ignore File</guilabel></term><listitem><para> 1662 Ignore files and folders that would also be ignored by the your source control. 1663 Many automatically generated files are ignored using ignore lists. 1664 The big advantage is that this can be folder-specific via a local ignore file. 1665 (See version control docs for more detail.) 1666 </para></listitem></varlistentry> 1667 <varlistentry><term><guilabel>Find hidden files and folders</guilabel></term><listitem><para> On some file systems files 1668 have an "Hidden"-attribute. On other systems a filename starting with a dot 1669 "." causes it to be hidden. This option allows you to decide whether to 1670 include these files in the tree or not. Default is on.</para></listitem></varlistentry> 1671 <varlistentry><term><guilabel>Follow file links</guilabel></term><listitem><para> For links to files: When disabled, then 1672 the symbolic links are compared. When enabled, then the files behind the 1673 links are compared. Default is off.</para></listitem></varlistentry> 1674 <varlistentry><term><guilabel>Follow folder links</guilabel></term><listitem><para> For links to folders: When disabled, 1675 then the symbolic links will be compared. When enabled then the link will 1676 be treated like a folder and it will be scanned recursively. (Note that 1677 the program doesn't check if the link is "recursive". So for example a folder 1678 that contains a link to the folder would cause an infinite loop, and after 1679 some time when the stack overflows or all memory is used up, crash the program.) 1680 Default is off.</para></listitem></varlistentry> 1681 <varlistentry><term><guilabel>Case sensitive filename comparison</guilabel></term><listitem><para> 1682 Default is false on &Windows;, true for other operating systems.</para></listitem></varlistentry> 1683 <varlistentry><term><guilabel>File Comparison Mode:</guilabel></term><listitem><para> 1684 <variablelist> 1685 <varlistentry><term><guilabel>Binary comparison</guilabel></term><listitem><para> 1686 This is the default file comparison mode. 1687 </para></listitem></varlistentry> 1688 <varlistentry><term><guilabel>Full analysis</guilabel></term><listitem><para> 1689 Do a full analysis of each file and show the statistics information columns. 1690 (Number of <guilabel>Solved</guilabel>, <guilabel>Unsolved</guilabel>, 1691 <guilabel>Nonwhite</guilabel> and <guilabel>White</guilabel> conflicts.) 1692 The full analysis is slower than a simple binary analysis, and much 1693 slower when used on files that don't contain text. 1694 (Specify the appropriate file-antipatterns.) 1695 </para></listitem></varlistentry> 1696 <varlistentry><term><guilabel>Trust the size and modification date (unsafe)</guilabel></term><listitem><para> 1697 If you compare big folders over a slow network, it might be faster to 1698 compare the modification dates and file length alone. But this speed improvement 1699 comes with the price of a little uncertainty. Use this option with care. 1700 Default is off.</para></listitem></varlistentry> 1701 <varlistentry><term><guilabel>Trust the size (unsafe)</guilabel></term><listitem><para> 1702 Similar to trusting the modification date. No real comparison happens. Two 1703 files are considered equal if their file-sizes are equal. This is useful 1704 when the file-copy operation didn't preserve the modification date. 1705 Use this option with care. Default is off.</para></listitem></varlistentry> 1706 </variablelist></para></listitem></varlistentry> 1707 1708 <varlistentry><term><guilabel>Synchronize folders</guilabel></term><listitem><para> 1709 Activates sync-mode when two folders are compared and no explicit destination 1710 folder was specified. In this mode the proposed operations will be chosen so 1711 that both source folders are equal afterwards. Also the merge result will be 1712 written to both folders. Default is off.</para></listitem></varlistentry> 1713 <varlistentry><term><guilabel>Copy newer instead of merging (unsafe)</guilabel></term><listitem><para> 1714 Instead of merging the proposed operation will copy the newer source if changes 1715 happened. (Considered unsafe, because it implies that you know, that the other 1716 file hasn't been edited too. Check to make sure in every case.) Default is off.</para></listitem></varlistentry> 1717 <varlistentry><term><guilabel>Backup files (.orig)</guilabel></term><listitem><para> 1718 If a file or complete folder is replaced by another or is deleted then the 1719 original version will be renamed with an <literal role="extension">.orig</literal> 1720 extension. If an old backup file with <literal role="extension">.orig</literal> 1721 extension already exists then this will be deleted without backup. This also 1722 affects the normal merging of single files, not only in folder-merge mode. 1723 Default is on.</para></listitem></varlistentry> 1724 </variablelist> 1725 </sect1> 1726 1727 <sect1 id="other"><title>Other Functions in Folder Merge Window</title> 1728 <sect2><title>Split/Full Screen Mode</title> 1729 <para> 1730 Usually the folder-merge list view remains visible while a single file is compared or merged. With the mouse you can move the splitter bar that separates the file list from the text-diff windows. If you don't want this, you can disable <menuchoice><guimenu>Folder</guimenu><guimenuitem>Folder && Text Split Screen View</guimenuitem></menuchoice> menu item. Then you can use <menuchoice><guimenu>Folder</guimenu><guimenuitem>Toggle View</guimenuitem></menuchoice> menu item to switch between the file list and the text-diff view that then occupy the full screen. 1731 </para> 1732 </sect2> 1733 <sect2><title>Comparing or Merging a Single File</title> 1734 <para> 1735 Probably you will prefer a simple double mouse click on a file in order 1736 to compare it. Nevertheless there also exists an entry in the <guimenu>Folder</guimenu> 1737 menu. You can also directly merge a single file by selecting it and choosing 1738 <menuchoice><guimenu>Merge</guimenu><guimenuitem>Merge Current File</guimenuitem></menuchoice> 1739 menu item. On saving the result, the status will be set to done, and the file 1740 will not be merged again if a folder merge is started. 1741 </para><para> 1742 But note that this status information will be lost when you rerun a folder 1743 scan: <menuchoice><guimenu>Folder</guimenu><guimenuitem>Rescan</guimenuitem></menuchoice> 1744 </para> 1745 </sect2> 1746 <sect2><title>Comparing or Merging Files with Different Names</title> 1747 <para> 1748 Sometimes you need to compare or merge files with different names (⪚ the current 1749 file and the backup in the same folder). 1750 </para><para> 1751 Select the exact file by clicking onto the icon in the column <guilabel>A</guilabel>, <guilabel>B</guilabel> or <guilabel>C</guilabel>. The first file selected thus will be marked with an <guilabel>A</guilabel>, the second and third with <guilabel>B</guilabel> and <guilabel>C</guilabel> regardless on what column they are in. Only up to three files can be chosen like this. 1752 </para><para> 1753 Proceed by choosing <menuchoice><guimenu>Folder</guimenu><guimenuitem>Compare Explicitly Selected Files</guimenuitem></menuchoice> or <menuchoice><guimenu>Folder</guimenu><guimenuitem>Merge Explicitly Selected Files</guimenuitem></menuchoice> menu item. For your convenience these menu entries also appear as context menu when you right-click the last selected file. 1754 </para><para> 1755 The comparison or merge of a file will happen in the same window. 1756 If this method is used for folders a new window will be opened. 1757 </para></sect2> 1758 </sect1> 1759 </chapter> 1760 1761 <chapter id="misc"> 1762 <title>Miscellaneous Topics</title> 1763 <sect1 id="networktransparency"> 1764 <title>Network transparency via KIO</title> 1765 <sect2><title>KIO-Slaves</title> 1766 <para> 1767 The KIO library from &frameworks; supports network transparency via KIO-slaves. 1768 &kdiff3; uses this for reading input files and for scanning folders. 1769 This means that you can specify files and folders on local and 1770 remote resources via &URL;s. 1771 </para><para> 1772 Example: 1773 </para><para> 1774 <screen> 1775 <command>kdiff3</command> test.cpp ftp://ftp.faraway.org/test.cpp 1776 <command>kdiff3</command> tar:/home/hacker/archive.tar.gz/folder ./folder 1777 </screen> 1778 </para> 1779 <para>The first line compares a local file with a file on an &FTP; server. The second line 1780 compares a folder within an compressed archive with a local folder. 1781 </para><para> 1782 Other KIO-slaves that are interesting are: 1783 </para> 1784 <itemizedlist> 1785 <listitem><para>Files from the WWW (http:),</para></listitem> 1786 <listitem><para>Files from the &FTP; (ftp:),</para></listitem> 1787 <listitem><para>Encrypted file transfer (fish:, sftp:),</para></listitem> 1788 <listitem><para>&Windows; resources (smb:),</para></listitem> 1789 <listitem><para>Local files (file:),</para></listitem> 1790 </itemizedlist> 1791 <para> 1792 Other things that are possible, but probably less useful are: 1793 </para> 1794 <itemizedlist> 1795 <listitem><para>Man-pages (man:),</para></listitem> 1796 <listitem><para>Info-pages (info:),</para></listitem> 1797 </itemizedlist> 1798 </sect2> 1799 1800 <sect2><title>How To Write &URL;s</title> 1801 <para> 1802 An &URL; has a different syntax compared with paths for local files and folders. 1803 Some things should be considered: 1804 </para> 1805 <itemizedlist> 1806 <listitem><para> 1807 A path can be relative and can contain "." or "..". This is not possible for &URL;s 1808 which are always absolute. 1809 </para></listitem><listitem><para> 1810 Special characters must be written with "escaping". ("<literal>#</literal>" -> "<literal>%23</literal>", space ->"<literal>%20</literal>", &etc;) 1811 E.g. a file with the name "<literal>#</literal>foo<literal>#</literal>" would have the &URL; "file:/<literal>%23</literal>foo<literal>%23</literal>". 1812 </para></listitem><listitem><para> 1813 When &URL;s don't work as expected, try to open them in &konqueror; first. 1814 </para></listitem> 1815 </itemizedlist> 1816 1817 </sect2> 1818 1819 <sect2><title>Capabilities of KIO-Slaves</title> 1820 <para> 1821 Network transparency has one drawback: Not all resources have the same capabilities. 1822 </para><para> 1823 Sometimes this is due to the file system of the server, sometimes due to the protocol. 1824 Here is a short list of restrictions: 1825 </para> 1826 <itemizedlist> 1827 <listitem><para> 1828 Sometimes there is no support for links. 1829 </para></listitem><listitem><para> 1830 Or there is no way to distinguish if a link points to a file or a folder; always 1831 assuming a file. (ftp:, sftp:). 1832 </para></listitem><listitem><para> 1833 Can't always determine the filesize. 1834 </para></listitem><listitem><para> 1835 Limited support for permissions. 1836 </para></listitem><listitem><para> 1837 No possibility to modify permissions or modification time, so permissions or time 1838 of a copy will differ from the original. (See the <guilabel>Trust the size (unsafe)</guilabel> option.) 1839 (To modify permissions or modification time is only possible for local files.) 1840 </para></listitem> 1841 </itemizedlist> 1842 </sect2> 1843 </sect1> 1844 1845 <sect1 id="git"> 1846 <title>Using &kdiff3; as a &git; Diff and Merging Tool</title> 1847 <para> 1848 &kdiff3; can be used as a <ulink url="https://git-scm.com/">&git;</ulink> diff and merge tool. 1849 </para> 1850 <para> 1851 Just add the following lines into your <filename>gitconfig</filename> file. 1852 </para> 1853 <programlisting> 1854 [diff] 1855 tool = kdiff3 1856 [difftool "kdiff3"] 1857 path = <path to kdiff3 binary in your system> 1858 [difftool] 1859 prompt = false 1860 keepBackup = false 1861 trustExitCode = false 1862 [merge] 1863 tool = kdiff3 1864 [mergetool] 1865 prompt = false 1866 keepBackup = false 1867 keepTemporaries = false 1868 [mergetool "kdiff3"] 1869 path = <path to kdiff3 binary in your system> 1870 </programlisting> 1871 <para> 1872 Then to see the difference between two commits use <userinput>git difftool <replaceable>first_hash</replaceable> <replaceable>second_hash</replaceable> --tool=kdiff3 --cc <replaceable>some_file_in_the_git_tree</replaceable></userinput> 1873 </para> 1874 <para> 1875 To merge a branch with &kdiff3; use <userinput>git merge <replaceable>branch_name</replaceable> && git mergetool --tool=kdiff3</userinput> 1876 </para> 1877 <para> 1878 After resolving merging conflicts in the <link linkend="synchronise_views">usual way</link> it is enough to commit the changes to do the job. 1879 </para> 1880 </sect1> 1881 </chapter> 1882 1883 <chapter id="faq"> 1884 <title>Questions and Answers</title> 1885 1886 &reporting.bugs; 1887 &updating.documentation; 1888 1889 <qandaset id="faqlist"> 1890 1891 <qandaentry><question><para> 1892 Why is it called "&kdiff3;"? 1893 </para></question><answer><para> 1894 Tools named <application>KDiff</application> and <application>KDiff2</application> (now called &kompare;) already exist. Also &kdiff3; should suggest that it can merge like the <command>diff3</command> tool in the Diff-Tool collection. 1895 </para></answer></qandaentry> 1896 1897 <qandaentry><question><para> 1898 Why did I release it under GPL? 1899 </para></question><answer><para> 1900 I'm using GPL programs for a very long time now and learned very much by 1901 having a look at many of the sources. Hence this is my "Thank You" to 1902 all programmers that also did so or will do the same. 1903 </para></answer></qandaentry> 1904 1905 <qandaentry><question><para> 1906 Some buttons and functions are missing. What's wrong? 1907 </para></question><answer><para> 1908 You compiled from source but you probably didn't specify the correct prefix 1909 for the installation. By default <command>cmake</command> wants to install in 1910 <filename class="directory">/usr/local</filename> but then the user-interface 1911 resource file (&ie; <filename>kdiff3ui.rc</filename>) can't be found. The 1912 <filename>README</filename> file contains more information about the correct prefix. 1913 </para></answer></qandaentry> 1914 1915 <qandaentry><question><para> 1916 Often lines that are similar but not identical appear next to each other 1917 but sometimes not. Why? 1918 </para></question><answer><para> 1919 Lines where only the amount of white space characters is different are 1920 treated as "equal" at first, while just one different non-white character 1921 causes the lines to be "different". If similar lines appear next to each 1922 other, this actually is coincidence but this fortunately is often the case. 1923 See also <link linkend="manualdiffhelp">Manual Diff Help</link>. 1924 </para></answer></qandaentry> 1925 1926 <qandaentry><question><para> 1927 Why must all conflicts be solved before the merge result can be saved? 1928 </para></question><answer><para> 1929 For each equal or different section the editor in the merge result window remembers where it begins or ends. This is needed so that conflicts can be solved manually by simply selecting the source button (<guilabel>A</guilabel>, <guilabel>B</guilabel> or <guilabel>C</guilabel>). This information is lost while saving as text and it is too much effort to create a special file format that supports saving and restoring all necessary information. 1930 </para></answer></qandaentry> 1931 1932 <qandaentry><question><para> 1933 How can I synchronise the diff and merge views, so that all views show the same text position? 1934 </para></question><answer><para> 1935 Click into the summary column left of the text. (<link linkend="synchronise_views">See also here.</link>) 1936 </para></answer></qandaentry> 1937 1938 <qandaentry><question><para> 1939 Why does <userinput>git difftool --dir-diff</userinput> give "Mix of links and normal files error" when using KDiff3 as the difftool? 1940 </para></question><answer><para> 1941 This is a side effect of git's internal workings. If you try to compare a previous revision to the current work tree git will compare actually files representing the past commit to symlinks pointing to the 1942 worktree. As of 1.9 KDiff3 defaults to having <guilabel>Follow file links</guilabel> and <guilabel>Follow folder links</guilabel> on. Prior to this they were off by default. 1943 This did not matter when not doing if "Full analysis" was also off. However, with <guilabel>Full analysis</guilabel> on KDiff3 would initially attempt to compare the path pointed to by a link rather than follow it. 1944 Prior to 1.8 the resulting error was ignored. However, 1.8 began reporting the error. 1945 </para></answer></qandaentry> 1946 1947 <qandaentry><question><para> 1948 Why does the editor in the merge result window not have an "undo"-function? 1949 </para></question><answer><para> 1950 This was too much effort until now. You can always restore a version from one source (<guilabel>A</guilabel>, <guilabel>B</guilabel> or <guilabel>C</guilabel>) by clicking the respective button. For big editing the use of another editor is recommended anyway. 1951 </para></answer></qandaentry> 1952 1953 <qandaentry><question><para> 1954 When I removed some text, then suddenly "<No src line>" appeared 1955 and cannot be deleted. What does that mean and how can one remove this? 1956 </para></question><answer><para> 1957 For each equal or different section the editor in the merge result window 1958 remembers where it begins or ends. "<No src line>" means that 1959 there is nothing left in a section, not even a new line character. 1960 This can happen either while merging automatically or by editing. This is 1961 no problem, since this hint won't appear in the saved file. If you want 1962 the original source back just select the section (click on the left summary 1963 column) and then click the source button with the needed contents 1964 (<guilabel>A</guilabel>/<guilabel>B</guilabel> or <guilabel>C</guilabel>). 1965 </para></answer></qandaentry> 1966 1967 <qandaentry><question><para> 1968 Why doesn't &kdiff3; support syntax-highlighting? 1969 </para></question><answer><para> 1970 &kdiff3; already uses many colors for difference highlighting. More 1971 highlighting would be confusing. Use another editor for this. 1972 </para></answer></qandaentry> 1973 1974 <qandaentry><question><para> 1975 Can I use &kdiff3; to compare <application>LibreOffice</application>/<trademark 1976 class="registered">OpenOffice.org</trademark>, <application>&Microsoft; Word</application>, 1977 <application>&Microsoft; Excel</application>, &PDF;, &etc; files? 1978 </para></question><answer><para> 1979 Although &kdiff3; will analyse any kind of file the result will probably 1980 not be very satisfactory for you. 1981 </para><para> 1982 &kdiff3; was made to compare pure text files. 1983 <application>LibreOffice</application>/<trademark class="registered"> 1984 OpenOffice.org</trademark>, <application>&Microsoft; Word</application>, 1985 <application>&Microsoft; Excel</application>, &etc; store much more information 1986 in the files (about fonts, pictures, pages, colors, &etc;) which &kdiff3; doesn't 1987 know about. So &kdiff3; will show you the contents of the file interpreted as 1988 pure text, but this might be unreadable or at least it will look very odd. 1989 </para><para> 1990 Since most programs nowadays store their contents in &XML; format, you might 1991 be able to read it as pure text. So if the change was only small, 1992 &kdiff3; still might help you. 1993 </para><para> 1994 The best solution if you only want to compare the text (without embedded objects like pictures) is to use <menuchoice><guimenu>Edit</guimenu><guimenuitem>Select All</guimenuitem></menuchoice> and <menuchoice><guimenu>Edit</guimenu><guimenuitem>Copy</guimenuitem></menuchoice> menu items in your program to copy the interesting text to the clipboard and then in &kdiff3; paste the text into either diff input window. (See also <link linkend="selections">Select, Copy And Paste</link>.) 1995 </para></answer></qandaentry> 1996 1997 <qandaentry><question><para> 1998 Where has the folder option <guimenuitem>List only deltas</guimenuitem> gone? 1999 </para></question><answer><para> 2000 There are now several <link linkend="selectingvisiblefiles">"Show" options</link> in the 2001 <guimenu>Folder</guimenu> menu. Disabling <guimenuitem>Show Identical Files</guimenuitem> 2002 will achieve what enabling <guimenuitem>List only deltas</guimenuitem> used to do. 2003 </para></answer></qandaentry> 2004 2005 <qandaentry><question><para> 2006 How can I make a big selection in the diff input window 2007 because scrolling takes so long? 2008 </para></question><answer><para> 2009 Start the selection as usual (click and hold the &LMB;). Then use the navigation keys (⪚ &PgUp;, &PgDn;) while holding the &LMB; down. (See also <link linkend="selections">Select, Copy And Paste</link>.) 2010 </para></answer></qandaentry> 2011 2012 <qandaentry><question><para> 2013 There is so much information here, but your question is still not answered? 2014 </para></question><answer><para> 2015 Please send me your question. I appreciate every comment. 2016 </para></answer></qandaentry> 2017 2018 </qandaset> 2019 </chapter> 2020 2021 <chapter id="credits"> 2022 2023 <title>Credits and License</title> 2024 2025 <para> 2026 &kdiff3; - File and Folder Comparison and Merge Tool 2027 </para> 2028 <para> 2029 Program copyright 2002-2007 Joachim Eibl <email>joachim.eibl at gmx.de</email> 2030 </para> 2031 <para> 2032 Several cool ideas and bugreports came from colleagues and many people out in the Wild Wild Web. Thank you! 2033 </para> 2034 2035 <para> 2036 Documentation Copyright © 2002-2007 Joachim Eibl <email>joachim.eibl at gmx.de</email> 2037 </para> 2038 2039 <para> 2040 Documentation Copyright © 2017-2019 Michael Reeves <email>reeves.87 at gmail.com</email> 2041 </para> 2042 2043 <!-- TRANS:CREDIT_FOR_TRANSLATORS --> 2044 2045 &underFDL; <!-- FDL: do not remove --> 2046 2047 2048 &underGPL; <!-- GPL License --> 2049 2050 </chapter> 2051 2052 &documentation.index; 2053 </book> 2054 2055 <!-- 2056 Local Variables: 2057 mode: sgml 2058 sgml-minimize-attributes:nil 2059 sgml-general-insert-case:lower 2060 sgml-indent-step:0 2061 sgml-indent-data:nil 2062 End: 2063 2064 vim:tabstop=2:shiftwidth=2:expandtab 2065 -->