xxdiff documentation

Author: Martin Blais
Contact: blais@furius.ca
Date: 2003-12-25
Copyright: Copyright (C) 1999-2004, Martin Blais. All Rights Reserved.

Abstract

User's manual for xxdiff. The official location of xxdiff on the internet is http://xxdiff.sourceforge.net. If you're reading this page from the web, note that you can also access this document from the Help menu of xxdiff.

Table of Contents

1   Introduction

xxdiff is a graphical file and directories comparison and merge tool. This program is an essential software development tool that can be used to

xxdiff doesn't itself compute the differences between files, it just displays them graphically (the rationale behind this is that you can use different tools to compute the actual diffs (for example using Rational ClearCase's cleardiff, which gives more sensible results than GNU diff in certain cases), there is a relatively standard format for difference output (POSIX diff), so it is easy and efficient to parse diff output from different programs, under the UNIX dataflow paradigm, it is common for graphical tools to be built on top of text tools. There are already many good tools to perform diffs, so there's no need to rewrite them.

2   Version

This documentation was generated for version:

4.0

3   Invocation

Usage:

xxdiff [OPTIONS] <file1> <file2> [<file3>]

You can specify either two files (two-way diff), three files (three-way diff), or two directories (directory diff).

You can also specify a mix of regular files and directories. If at least one of the paths specified on the cmdline is a regular file, all other paths that are directories will have the basename of the regular filename appended to them. For example, if you specify:

xxdiff dir1/bn1 dir2/bn2 dir3

xxdiff will be run on dir1/bn1, dir2/bn2, and dir3/bn1.

xxdiff can accept one of its inputs from stdin. You must replace the relevant filename by '-' (a dash) to instruct xxdiff to use stdin for that file, e.g.:

cat file2 | sort | xxdiff file1 - file3

If all the file paths are directories, a directory diff is invoked. Note that xxdiff doesn't do three-way directory diffs.

If the "unmerge" option is given, then xxdiff can only be invoked with a single file containing the conflicts.

3.1   Return Value

xxdiff returns the same values that diff(1) or diff3(1) return. See the respective man pages of those utilities for details.

3.2   Command-line Options

Generic options

--help Show help about options.
--help-qt Show Qt specific options.
--help-all Show all options.
--help-html Output documentation in HTML.
--version, -v Show version information.

Qt options

--qt, -Q <arg> Set options to be given to Qt application options parser. See Qt manual, class QApplication for a list of supported options.
--display <arg> Sets the X display (default is $DISPLAY).
--style <arg> Sets the application GUI style. Possible values are motif, windows, and platinum.
--geometry <arg> Sets the client geometry of the main widget.
--font <arg> Defines the application font (for widgets).
--textfont <arg> Defines the text font (for diff text).
--name Sets the application name.
--visual <arg> Forces the application to use a particular visual on an 8-bit display (e.g. TrueColor).
--ncols <arg> Limits the number of colors allocated in the color cube on a 8-bit display.
--cmap Causes the application to install a private color map on an 8-bit display.
--nograb Tells Qt to never grab the mouse or the keyboard.
--dograb Running under a debugger can cause an implicit -nograb, use -dograb to override.
--sync Switches to synchronous mode for debugging.
--graphicssystem <arg> Sets the application graphics system. Possible values are raster, opengl (experimental), opengl1 (obsolete), x11, native.

GNU diff options (2-files only)

--ignore-all-space, -w Option passed to 2-files diff(1). Ignore white space when comparing lines.
--ignore-space-change, -b Option passed to 2-files diff(1). Ignore changes in amount of white space.
--ignore-case, -i Option passed to 2-files diff(1). Ignore changes in case; consider upper- and lower-case to be the same.
--ignore-blank-lines, -B Option passed to 2-files diff(1). Ignore changes that just insert or delete blank lines.
--recursive, -r Option passed to 2-files diff(1). This is only meaningful for directory diffs.
--text, -a Option passed to 2-files diff(1). Treat all files as text and compare them line-by-line, even if they do not appear to be text.
--exclude, -e <arg> When comparing directories, ignore files and subdirectories whose basenames match pattern.
--exclude-from <arg> When comparing directories, ignore files and subdirectories whose basenames match any pattern contained in file.
--args, -A <arg> Pass on argument to the subordinate diff program.

Options

--no-rcfile Don't query rcfile resources (.xxdiffrc).
--list-resources Lists all the supported resources and default values.
--exit-on-same, -D If there are no differences then exit quietly with exit code of 0.
--exit-if-no-conflicts, -E If there are no conflicts after making automatic merge selections, then exit quietly with exit code of 0.
--exit-with-merge-status, -X If all diff hunks are selected and no unsaved selections exist, then exit with code of 0. Normally, xxdiff will pass back the diff return code.
--single, -S Load a single file for display. This is a strange feature for those who like the display of code with xxdiff.
--merge, -m Automatically select regions that would end up being selected by an automatic merge.
--unmerge, -U Invoke on a single file with CVS-like merge conflicts, splitting the conflicts into two files for display. If this is specified, only a single file can then be given as argument.
--unmerge3 Invoke on a single file with merge conflicts generated by diff3 with the show-all option, splitting the conflicts into three files for display. If this is specified, only a single file can then be given as argument.
--resource, -R <arg> Pass on string 'str' to resource parser. Resources given in this manner on the command line supersede other resource mechanisms. One can specify multiple resource settings by repeating this option.
--merged-filename, -M <arg> Specifies the filename of the merged file for output.
--decision, -O Forces the user to take a decision upon exit. The user can choose between ACCEPT, REJECT or MERGED, in which case saving to the merged filename is forced (if the merged file exists, no warning is given about overwriting the file). If there are unresolved conflicts, a popup dialog will appear. If ACCEPT or REJECT are selected, no merged file is required. In all cases, a single line is output with the decision that was made. This generic functionality is useful for better integration with scripts that require some form of decision to be made by the user.
--indicate-input-processed Indicate that the input files have been entirely processed and are not needed anymore by printing out the string INPUT-PROCESSED on stdout as soon as possible. This can be used by scripts which create temporary files to delete those as soon as xxdiff has finished reading them. This only works from startup.
--use-temporary-files, -t Copies the input streams/files into temporary files to perform diffing. This is useful if you want to diff FIFOs.
--prompt-for-files, -p <arg> If no files are specified on the command line, show a file dialog so that the user can select them. This option is ignored if any files are specified.

Display Options

--title1 <arg> Display 'str' instead of filename in filename label 1 (left).
--title2 <arg> Display 'str' instead of filename in filename label 2 (middle).
--title3 <arg> Display 'str' instead of filename in filename label 3 (right).
--titlein, -N <arg> Display 'str' for filename in given in stdin.
--orig-xdiff Use settings as close as possible to original xdiff (for the romantics longing the old days of SGI... snif snif).
--show-merged-pane Display the merged pane on startup.

Note that the last few options are provided compatible with common GNU diff options that the user might want to use, as a mere convenience. Note also that xxdiff options are a superset of the original xdiff options, so that xxdiff is compatible with old SGI scripts that use xdiff. xxdiff options follow the GNU conventions for command-line options.

3.3   Using xxdiff as a short-lived application

xxdiff has not been designed with the intent of being used over multiple sets of files over the course of one execution---that is, it has been built around the idea that you would execute it once over a single set of inputs, use it, then exit, rather than to open new files again using the 'file' menu features without exiting. The 'file' menu features are provided as a convenience, to allow one to occasionally replace one of the files during an execution. That is the reason why you can't open xxdiff with just one file. It is just not useful that way.

4   General operation

This section describes general features and operation of xxdiff.

4.1   The text area

xxdiff shows up with two or three text regions that display the text of the files to compare, with color-coded blocks that indicate regions of text (lines) that have changes (specific sections contain a list and descriptions on what types of change can appear). Each of these regions of text is called a "hunk" in diff terminology (for more about this, see the GNU diff manual). The text area can be scrolled vertically and horizontally, when necessary.

Corresponding regions of text are aligned between the files. Since changed regions do not necessarily contains the same number of lines, empty alignment lines are appended to the shorter regions in order to keep the corresponding lines aligned (this is a simple way of solving the alignment problem; an alternate solution would have been to implement a smart type of scrolling with lines indicating correspondance of regions between them).

All the colors can be individually configured using the display options dialog or resources. The display dialog contains a legend of all the colors. Note that the default colors for different regions are often set to be the same to other types of lines when it is not necessary to dissociate them, to avoid visual clutter. You could however, customize every region to be of a different color, for example, perhaps you would want to have the dummy lines drawn of a special color to indicate that they are not really part of the text.

In the text area, there is a cursor that in indicates the current line of text being worked on. This cursor can be optionally hidden.

4.1.1   Horizontal diffs

Each of the diff hunks is normally displayed in one color, but if horizontal diffs is enabled, for each line, xxdiff find the smallest differing part of the line that differs and displays that in a different, highlighted color. This allows the user to more quickly visualize exactly what has changed between the two lines of text. No need to mention, this is highly addictive and is now enabled by default. This is the "single horizontal diffs" mode.

When there are no more than two pieces of text on a single line, if the differing parts of the lines are not too long (e.g. less than 100 chars), the horizontal diffs can isolate the differences within the line. This is the "multiple horizontal diffs" mode. In this mode, we require that between horizontal changes, inserts or deletes, there be a minimal number of common context characters, so that the eye can make out what has change between the lines. This value is configurable (see resources section).

When computing horizontal diffs, changes in whitespace can be optionally ignored. However, if whitespace has been added in the middle of a word, it will still be highlighted.

4.1.2   Per-hunk ignore whitespace

Diff Hunks with text on all sides but with just whitespace or line break differences will be detected by xxdiff and marked with a special flag. If the feature is enabled, those hunks will be drawn of a different color, thus enabling the reviewer to quickly ignore those hunks. See the merge review features section for more details.

4.1.4   Pop-up menu

Using the third mouse button in the text area brings a popup menu that contains cursor-sensitive commands, as well as the common commands to navigate between hunks.

4.1.5   Searching

You can search the text by bringing up the search dialog. Type your search query and press enter, which will apply the search and display diamond shaped match locations in the overview area. You can then navigate the search results using Ctrl-F and Ctrl-B. Searching will occur in all files simultaneously. You have to reapply the search to search for something else.

You can also move the cursor and display to a particular line from the search dialog.

4.1.6   Other options

Carriage returns (CR) characters in DOS files can be hidden in the text area.

Tabs by default are rendered aligned at each 8 characters, but can be set to any value by changing the tab width option.

4.1.7   Display options

The display options can be fully customized by bringing up the options dialog with the "Display -> Display Options..." menu item. From that dialog you can also customize the colors and fonts.

4.2   Redoing the diffs

If a file has changed while xxdiff is up, and there is need to recompute the diffs, invoke the "redo diff" command from the edit menu. The arguments used with the surrogate diff command can be changed by using the dialog provided by the "diff arguments" command. One can also replace a loaded file with a different one by using the "open" commands from the "file" menu.

4.3   Other UI elements

The following other UI elements can be optionally hidden or displayed from the Windows menu or Display menu (use the resource file to display or hide them on startup):

  • Overview area. On the right side, an area that shows a color-coded pictorial rendering of the diff hunks for the whole files, with correspondances. This area also shows the as a rectangle the currently visible portion of text for each of the files. This rectangle can also be used as a scrollbar. In addition, a marker indicates the location of the line cursor.
  • Remaining Unselected Hunks. Just above the overview area is a label that indicates the number of remaining unselected diff hunks between the files. In addition, if that number is zero, and if the files are identical byte-for-byte, it display a "(=)" string next to the number, so that you can figure out quickly if the files have any ignored whitespace changes or not (this can be important during merge review).
  • Toolbar. A toolbar that gives access to the common motion and selection commands.
  • Filenames. For each file, a region at the top that displays the filename. You can customize what shows up in this region from the command-line. Clicking on the filename puts it in the clipboard for cut-n-paste. (This label will intelligently display the end part of the filename if it is too long to fit.) This region also display the text line that the line cursor is in, for each file. You can customize what gets displayed in this labeled by using a command-line option.
  • Line numbers. For each file, a thin window that display the number of each line (dummy alignment lines don't have any number).
  • Vertical line. A vertical line can be drawn in the text area, at a specified column. This can be used for alignment purposes or for verifying that a line doesn't extend beyond a specified number of characters (many people like to limit their source code to fit in e.g. 80 characters).
  • Merged view. A view of the file resulting from the currently selected regions (see section on Merged view below).

5   Comparing two files

When invoking xxdiff with two files, we normally think of an old and a new file, where:

xxdiff old new

The default colors used here are symmetrical, so invoking the files in a different order will result in regions being assigned the same colors.

5.1   Types of hunks

The following hunk types can appear when comparing two files:

  • Same: no change in that region;
  • Insert: text has been added to the new file;
  • Delete: text has been deleted from the new file;
  • Diff: text has changed between the files.

Note that each Diff or Insert hunk is always separated by a Same hunk (if it was not the case, then two different contiguous hunks would necessarily get merged into a single Diff hunk).

5.2   Options

You can ignore trailing blanks, whitespace, or case for two-way diffs. See GNU diff(1) manual for information these features. xxdiff provides menu items to access these diff options. Those items simply add or remove switches to the diff program command-line and call the diff program again to regenerate the diffs.

Switches for GNU diff algorithm quality are also provided in the UI as a convenience.

6   Comparing three files

When invoking xxdiff with three files, we think of an ancestor file, a "mine" file, which the current user has been working on, and a "yours" file which someone else has merged in the main tree. They are normally specified in the following order:

xxdiff mine older yours

The default colors used here are symmetrical, so invoking the files in a different order will result in regions being assigned the same colors.

6.1   Types of hunks

The following hunk types can appear when comparing two files:

  • Same: no change in that region;
  • Insert: text has been added one of the files;
  • Delete: text has been deleted from one of the files;
  • DiffOne: text is different in one of the three files but the two other files are the same.
  • DiffAll: text is different in all of the three files.
  • DiffDel: text is different in two files and is absent in the third.

6.2   Ignoring one file

In three-way mode, it can be useful to temporarily ignore one of the three files to concentrate on the differences between the other two. This feature is available from the Display menu and is performed by simply remapping colors at display time and doesn't require xxdiff to recompute the differences. The ignored file will be displayed as grayed out.

7   Comparing two directories

When invoking xxdiff with two directories, we normally think of an old and a new directory, where:

xxdiff olddir newdir

The default colors used here are symmetrical, so invoking the files in a different order will result in regions being assigned the same colors.

Note

If you want to compare the files within directories all at once, use the --recursive option and you will get a single xxdiff with all the file differences. xxdiff accomplishes that by passing on the option to the subordinate diff program (e.g., GNU diff).

7.1   Types of hunks

The following hunk types can appear when comparing two directories:

  • Same: files are present in both directories and have no differences;
  • Insert: file has been added to directory;
  • Delete: file has been removed from directory;
  • Diff: files are present in both directories and have differences;
  • Directories: directories are present in both directories but we don't know if they differ;

7.2   Options

The directories can be compared recursively, in which case no directories will be shown. You can activate this from the command-line or from the ui.

You can also instruct xxdiff not to display the files that haved changed, just the insertions and deletions.

7.3   File operations

In directory diffs mode, you can invoke an xxdiff on the pair of files or directories under the line cursor. This allows you to start xxdiff on a pair of directories, and then to examine the pairs of files that have changed, all from that directory diff. That functionality is available from the popup menu in the text area (right-click).

You can also copy and remove files from that menu, see Merging files and resolving conflicts section for details.

8   Merging files and resolving conflicts

Merging files is the process of manually resolving conflicts when two files cannot be merged automatically. This is a common problem when doing parallel software development where multiple developers could be working on the same files.

Most of the merging can be handled automatically, because if the changes were applied to fairly independent parts of the files, most of the changes will be insertions or deletions. However, when overlapping changes occur, no automatic decision can be taken.

xxdiff can be used to resolve conflicts by letting the user "select" which side of a diff hunk should be killed and what side should be kept. The user can take this decision on a line-by-line basis, and can decide to keep both sides as well, in any order. xxdiff then allows the user to save the resulting file.

8.1   Selecting regions

Selecting a diff hunk can be carried out by clicking on it. The colors update to display which side is selected for output. You can select individual lines with the second button. There are three types of selection that you can carry out:

  • select clicked file;
  • select no file (take the decision that nothing will be output);
  • leave the line/hunk unselected.

If you want to select more than one side, you have to invoke the split-swap-join command (default is on 'S' key), which will split the current diff hunk if it's a Diff hunk so you can select the pieces you want from both sides. Further invocations of this command will cause swapping the regions, looping through all the different ordering possibilities, and finally joining the regions again (preserving selections where it is possible).

If you want to select individual lines, use the second button of the mouse on the lines that you want to select.

8.2   Saving the resulting file

The resulting file can be saved under one of the input filenames, under a computed "merged" filename, or under a new filename (from the File menu). The intended "merged" filename can be built from the input filenames and it's format can be specified through the resources file or the command line.

If some regions are left unselected, the save dialog will have some widgets that allows you to decide how you want to save the unselected hunks:

  • Save as merge conflicts: save all sides, separating them with merge conflict markers similar to those inserted by CVS;
  • Save with conditionals: save all sides, separating them with C pre-processor directives, so that you could then use a #define directive to have one set of changes or another be active if compiling.

The markers and pre-processor directives can be customized through the resources file.

There is a customization flag that lets you specify that xxdiff should warn you when trying to save with some regions unselected. It will bring the cursor to the first remaining unselected region and ask for confirmation. This can be used to insure that the user has made all the required decisions before saving and that no text will be forgotten.

You could also decide to save only the selected regions, from the File menu. This can be useful for making comments when reviewing merges.

8.2.1   Forcing Output of a Merged File and Better Script Integration

xxdiff is often used for merging conflicts, replacing some of the tools that are provided with popular configuration management systems. Sometime it is "required" that the conflict resolution tool output the merged file. To that extent, xxdiff has a special mode triggered with the option --decision to address specifically that need. When specified, the exit functionality is replaced with three functions:

  • exit with ACCEPT: the string "ACCEPT" is printed on stdout. The left file is automatically saved into the merged file;
  • exit with REJECT: the string "REJECT" is printed on stdout. The right file is automatically saved into the merged file;
  • exit with MERGED: the string "MERGED" is printed on stdout. If there are remaining conflictual hunks when exiting, a popup will ask how to deal with them, you are forced to make a selection on all the hunks.

We want to allow for a fast process where the user is presented with a series of xxdiffs and has to make decisions on each. The calling script can then do whatever is required to integrate the resulting file into its workflow.

If the window is killed, the merge file is not saved and NODECISION is output (the script that calls xxdiff must be prepared to deal with that somehow). Also, note that you are responsible for deleting the merged file. Also in this mode, if the merged file already exists, it gets overwritten without warning.

8.3   Rapid, sequential merge conflict resolution

Some people like to merge files within a guided process, where the visual diff program asks for a merge decision for each conflictual hunk one-by-one and then asks for a filename to use for saving the merged output. For example, that is how ClearCase's xcleardiff works when querying the user to resolve conflicts.

There are a set of commands under the Region menu that allows one to rapidly take decisions on merge conflicts. These commands perform a selection and then automatically move the cursor to the next unselected region. If there are no more unselected regions, the save dialog is brought up automatically.

8.4   Automatic merge

By default, xxdiff doesn't perform any selections. You can instruct xxdiff to perform the initial selection of the non-conflictual regions automatically. This can be specified from the command-line or from the Global menu.

Just like xxdiff can be instructed not to show up if there aren't any differences between the files, xxdiff can also be instructed not to show up if after the automatic merge there remains no conflictual regions. You can use the return value to find out.

(Note that we do not want to add a feature to xxdiff to allow it to output to the merged file if there are no conflics, because that would amount to make xxdiff a non-graphical tool, while its mandate is to use such tools underneath and display their output. Besides, that would be the single case where xxdiff writes to a file without a file dialog. You can very easily implement this from within a script using the return value of either diff or xxdiff.)

8.4.1   Requiring an output file

Sometimes we want to force the user into producing a merged output file (when calling xxdiff from an update script, for example). Thus there is a feature to put xxdiff in this mode (see resources or invocation section). In this mode, the user must save before exiting xxdiff (exiting will prompt for save filename).

8.5   Merging directories

Selecting is disable in directory diffs mode, where the concept of "saving" a directory does not really make sense. However, you can apply changes to a directory from xxdiff, such as copying and removing files under the line cursor. This can be invoked from the popup menu in the text area.

8.6   Merged view

During selection or before saving the selected regions into the result file, you might want to visualize what it would look like with the current selections. You can display the "merged view" for this purpose, an dedicated window showing the merge output, that updates interactively as you make selections.

This view will scroll to match the main display. Unselected regions are shown in this view with oblique lines ("in construction" style), and merge decisions are slightly highlighted as well. This output allows you to review the merge decisions before committing the file to output.

9   Merge review features

One of the most important uses of xxdiff is to assist the merge review process, where one developer visualizes the file changes of another and approves or rejects those changes, making comments along the way.

For this purpose, xxdiff puts selected text (i.e. when you click on a diff hunk) in the clipboard text buffer when you select it. Thus, the merge cop can select a region, and paste the results in a neighboring editor window.

These snippets of code will typically be interspersed with comments. xxdiff can be format the line contents before they are copied to the clipboard, to make them distinct from the merge comments. This can be enabled using the "format clipboard text" option. The clipboard line format is a string that contains format specifiers similar to printf for each line to be formatted prior to being put on the clipboard. The following specifiers are allowed:

%N
file line (0 is leftmost file)
%L
line number
%F
filename
%s
line contents

There is also a "clipboard header format" resource for adding the filename at the top of the copied text. This is useful for quickly pasting into a merge comments file.

Also note that clicking on the filename labels will put the filenames in the clipboard for similar cut-n-paste action. This can be useful when reviewing ClearCase revision files, which often have very long p-names.

9.1   Variable text selection

You can press ALT and Button1 to select an arbitrary number of lines. The selected lines will be marked with a special border to show what gets put in the clipboard. This is very useful when you don't want to quote an entire diff hunk, or a section of text that straddles hunks.

9.2   Per-hunk ignore whitespace

Many source code changes often just reindent or reorganize blocks of code, and result in many isolated hunks with no relevant changes to look at (for languages that don't use whitespace semantics anyway). For merge police duties, this can lead to more work to review changes, and typically, programmers (and groups, sometimes) will explicitly choose not to allow code beautification because of that very reason (...and the directed anger of merge cops themselves). xxdiff now has a new feature that alleviates this problem greatly: it will scan each diff hunk for non-whitespace changes, and if the only changes are of whitespace, it will mark the hunk with a special flag. The "ignore per-hunk whitespace" feature will draw these hunks with a different color, by default, a color very similar to the "same" hunks. The hunks are not ignored, however, as skipping from hunk to hunk will still stop at these hunks, but they can be very quickly ignored by the merge police. So go on ahead now, and reindent that code without fear.

10   Unmerging merge conflicts

Unmerging merge conflicts is a special input mode of xxdiff where a single file containing the result of an automatic merge of two files is split into two files and displayed as such.

This may sound like a "trava lengua", but unmerging merge conflicts can be a very useful feature, if you like to let your source code management system automatically perform merges and save the output without user intervention, such as the way CVS is normally used. Typical use of the CVS update command will merge the main branch changes into your local copy files. When there are conflicts, your files are modified to contain both your changes and the main branch changes in the regions that conflict. CVS inserts text markers such as the following to indicate the conflictual regions:

Some merged text.
>>>>>>>> MYFILE
I added this.
========
This line added in main branch.
<<<<<<<< 1.1
Some finetext.

Then, the user is notified of the conflictual files, and has to go inspect the conflicts and resolve them by editing the file accordingly. The problem is that it is often quite difficult (and unpleasant) to figure out exactly what happened during the automated merge process, without the original files (note that CVS does make a backup copy of your file before writing it over with the merged output, see CVS manual for details).

To help in figuring out what happened during merge and in performing the user-directed selections, xxdiff can be invoked in "unmerge mode" with the file containing the merge conflicts. It parses the file and generates two files from it, displaying them with differences. You can then perform selections as usual to produce the final merged file.

Note that we think that this is not the best way of resolving conflicts, rather just a useful feature for people who like to work this way. A better way to merge would be to use your source code management system to fetch the common ancestor revision, the latest/head of the main branch and to invoke xxdiff with your file, the ancestor and the latest/head. You can also tell xxdiff to initially perform all non-conflictual selections automatically.

10.1   Unmerging merge conflicts with three files

diff3 can be used to produce a merged file in which all the three files' regions are shown if there is a conflict. xxdiff can also parse these files and display them as a three-way diff. You then have to invoke xxdiff with the 'unmerge3' command-line argument to let it know you want the file split in three.

11   Editing files

There has been a conscious decision NOT to develop xxdiff into a fully-featured editing program. Sometimes it could be handy to be able to edit a few lines of a difficult conflict. However, that is a task best left to your own favorite editing program. Saving with merge conflicts will allow you to resolve those few remaining conflicts by hand.

However, a few commands have been provided under the File menu to spawn an editor on the input files. You can then redo the diff after your input file has changed.

12   Customization using resource file

Much of the state of xxdiff can be customized through a resource file (actually, some of the features can only be changed through resource customization). By default, xxdiff looks for the file .xxdiffrc located in the user's home directory (this file location can be overridden by setting the environment variable XXDIFFRC), and reads that file for resource definition.

The format of the resource file is a fairly simple list of colon-separated resource name/value pairs, one per line:

resourceName: "value"

Any text after "#" on a line is considered a comment and ignored.

Some resources may require string delimiters (double-quotes) around their value specification, but not all (see below).

You can also specify additional resources on the command-line, which take precedence over the resources specified in the resource file. To get a complete list of the available resources, use the --list-resources command-line option (see Options section).

Trick: you can use different resources files by invoking xxdiff like this in most shells:

XXDIFFRC=myrcfile xxdiff file1 file2

12.1   Automatic generation of the resource file

You can generate a resource file containing only the differences from the defaults from the "File -> Save Option..." menu command. This can be used to "save" the current customizable options into ~/.xxdiffrc.

13   Resource reference

This section contains a reference of the all the currently supported customizable resources in this version of xxdiff.

Geometry: 1200x600
Preferred geometry upon initialization. Format is the same a X geometry specification, plus you can also use `Maximize' to maximize on startup
Style: "Cleanlooks"
Preferred Qt style, see Qt documentation for more details. The style can otherwise be specified through command-line arguments.
Accel.[NAME].: "[ACCELERATOR]"
Accelerators for most functionality. The name of the accelerator should be explicit enough that you can find which function it is bound to.
Accel.Exit: "<key>"
Accel.ExitAccept: "<key>"
Accel.ExitMerged: "<key>"
Accel.ExitReject: "<key>"
Accel.OpenLeft: "<key>"
Accel.OpenMiddle: "<key>"
Accel.OpenRight: "<key>"
Accel.SaveAsLeft: "<key>"
Accel.SaveAsMiddle: "<key>"
Accel.SaveAsRight: "<key>"
Accel.SaveAsMerged: "<key>"
Accel.SaveAs: "<key>"
Accel.SaveSelectedOnly: "<key>"
Accel.EditLeft: "<key>"
Accel.EditMiddle: "<key>"
Accel.EditRight: "<key>"
Accel.SaveOptions: "<key>"
Accel.Search: "<key>"
Accel.SearchForward: "<key>"
Accel.SearchBackward: "<key>"
Accel.ScrollDown: "<key>"
Accel.ScrollUp: "<key>"
Accel.CursorDown: "<key>"
Accel.CursorUp: "<key>"
Accel.CursorTop: "<key>"
Accel.CursorBottom: "<key>"
Accel.RedoDiff: "<key>"
Accel.EditDiffOptions: "<key>"
Accel.EditDisplayOptions: "<key>"
Accel.DiffFilesAtCursor: "<key>"
Accel.NextAndDiffFiles: "<key>"
Accel.CopyFileRightToLeft: "<key>"
Accel.CopyFileLeftToRight: "<key>"
Accel.RemoveFileLeft: "<key>"
Accel.RemoveFileRight: "<key>"
Accel.NextDifference: "<key>"
Accel.PreviousDifference: "<key>"
Accel.NextUnselected: "<key>"
Accel.PreviousUnselected: "<key>"
Accel.SelectGlobalLeft: "<key>"
Accel.SelectGlobalMiddle: "<key>"
Accel.SelectGlobalRight: "<key>"
Accel.SelectGlobalNeither: "<key>"
Accel.SelectGlobalUnselect: "<key>"
Accel.SelectGlobalUnselectedLeft: "<key>"
Accel.SelectGlobalUnselectedMiddle: "<key>"
Accel.SelectGlobalUnselectedRight: "<key>"
Accel.SelectGlobalUnselectedNeither: "<key>"
Accel.SelectGlobalMerge: "<key>"
Accel.SelectRegionLeft: "<key>"
Accel.SelectRegionMiddle: "<key>"
Accel.SelectRegionRight: "<key>"
Accel.SelectRegionNeither: "<key>"
Accel.SelectRegionUnselect: "<key>"
Accel.SelectRegionLeftAndNext: "<key>"
Accel.SelectRegionMiddleAndNext: "<key>"
Accel.SelectRegionRightAndNext: "<key>"
Accel.SelectRegionNeitherAndNext: "<key>"
Accel.SelectRegionSplitSwapMerge: "<key>"
Accel.SelectLineLeft: "<key>"
Accel.SelectLineMiddle: "<key>"
Accel.SelectLineRight: "<key>"
Accel.SelectLineNeither: "<key>"
Accel.SelectLineUnselect: "<key>"
Accel.TabsAt3: "<key>"
Accel.TabsAt4: "<key>"
Accel.TabsAt8: "<key>"
Accel.IgnoreTrailing: "<key>"
Accel.IgnoreWhitespace: "<key>"
Accel.IgnoreCase: "<key>"
Accel.IgnoreBlankLines: "<key>"
Accel.HideCarriageReturns: "<key>"
Accel.DirDiffIgnoreFileChanges: "<key>"
Accel.DirDiffRecursive: "<key>"
Accel.UseInternalDiff: "<key>"
Accel.QualityNormal: "<key>"
Accel.QualityFastest: "<key>"
Accel.QualityHighest: "<key>"
Accel.TogglePaneMergedView: "<key>"
Accel.TogglePopupMergedView: "<key>"
Accel.ToggleToolbar: "<key>"
Accel.ToggleLineNumbers: "<key>"
Accel.ToggleMarkers: "<key>"
Accel.ToggleVerticalLine: "<key>"
Accel.ToggleOverview: "<key>"
Accel.ToggleShowFilenames: "<key>"
Accel.HorizontalDiffNone: "<key>"
Accel.HorizontalDiffSingle: "<key>"
Accel.HorizontalDiffMultiple: "<key>"
Accel.ToggleIgnoreHorizontalWhitespace: "<key>"
Accel.ToggleIgnorePerHunkWhitespace: "<key>"
Accel.ToggleFormatClipboardText: "<key>"
Accel.IgnoreFileNone: "<key>"
Accel.IgnoreFileLeft: "<key>"
Accel.IgnoreFileMiddle: "<key>"
Accel.IgnoreFileRight: "<key>"
Accel.HelpManPage: "<key>"
Accel.HelpOnContext: "<key>"
Accel.HelpAbout: "<key>"
Accel.MergedClose: "<key>"
Accel.FontResizeBigger: "<key>"
Accel.FontResizeSmaller: "<key>"
FontApp: "<xfld-font-spec>"
General application font, used for widgets and menus.
FontText: "<xfld-font-spec>"
Font to use for diff text view.
Color.[NAME].[Fore|Back]: "[COLOR]"
Color choice for diff hunks, and for certain other items in the text view.
Color.Same.Fore: "<color>"
Color.Same.Back: "<color>"
Identical text
Color.SameBlank.Fore: "<color>"
Color.SameBlank.Back: "<color>"
Identical text (blank side, for filler lines when ignore-blank-lines is enabled)
Color.Insert.Fore: "<color>"
Color.Insert.Back: "<color>"
Insert text (side with text)
Color.InsertBlank.Fore: "<color>"
Color.InsertBlank.Back: "<color>"
Insert text (blank side)
Color.DiffAll.Fore: "<color>"
Color.DiffAll.Back: "<color>"
Different in all files
Color.DiffAllSup.Fore: "<color>"
Color.DiffAllSup.Back: "<color>"
Different in all files (shadowed)
Color.DiffAllOnly.Fore: "<color>"
Color.DiffAllOnly.Back: "<color>"
Different in all files (only text on lines)
Color.DiffAllNonly.Fore: "<color>"
Color.DiffAllNonly.Back: "<color>"
Different in all files (blank side)
Color.DiffOne.Fore: "<color>"
Color.DiffOne.Back: "<color>"
(diff3 only) Different in one file
Color.DiffOneSup.Fore: "<color>"
Color.DiffOneSup.Back: "<color>"
(diff3 only) Different in one file (shadowed)
Color.DiffOneOnly.Fore: "<color>"
Color.DiffOneOnly.Back: "<color>"
(diff3 only) Different in one file (only text on lines)
Color.DiffOneNonly.Fore: "<color>"
Color.DiffOneNonly.Back: "<color>"
(diff3 only) Different in one file (blank side)
Color.DiffTwo.Fore: "<color>"
Color.DiffTwo.Back: "<color>"
(diff3 only) Common text in two files only
Color.DiffTwoSup.Fore: "<color>"
Color.DiffTwoSup.Back: "<color>"
(diff3 only) Common text in two files only (shadowed)
Color.DiffTwoOnly.Fore: "<color>"
Color.DiffTwoOnly.Back: "<color>"
(diff3 only) Common text in two files only (only text on lines)
Color.DiffTwoNonly.Fore: "<color>"
Color.DiffTwoNonly.Back: "<color>"
(diff3 only) Common text in two files only (blank side)
Color.Delete.Fore: "<color>"
Color.Delete.Back: "<color>"
(diff3 only) Delete text (side with text)
Color.DeleteBlank.Fore: "<color>"
Color.DeleteBlank.Back: "<color>"
(diff3 only) Delete text (blank side)
Color.DiffDel.Fore: "<color>"
Color.DiffDel.Back: "<color>"
(diff3 only) Different and delete text
Color.DiffDelSup.Fore: "<color>"
Color.DiffDelSup.Back: "<color>"
(diff3 only) Different and delete text (shadowed)
Color.DiffDelOnly.Fore: "<color>"
Color.DiffDelOnly.Back: "<color>"
(diff3 only) Different and delete text (only text on lines)
Color.DiffDelNonly.Fore: "<color>"
Color.DiffDelNonly.Back: "<color>"
(diff3 only) Different and delete text (blank side)
Color.DiffDelBlank.Fore: "<color>"
Color.DiffDelBlank.Back: "<color>"
(diff3 only) Different and delete text (empty side)
Color.Selected.Fore: "<color>"
Color.Selected.Back: "<color>"
Selected text
Color.SelectedSup.Fore: "<color>"
Color.SelectedSup.Back: "<color>"
Selected text (shadowed)
Color.IgnoreDisplay.Fore: "<color>"
Color.IgnoreDisplay.Back: "<color>"
Ignored for display purposes
Color.IgnoreDisplaySup.Fore: "<color>"
Color.IgnoreDisplaySup.Back: "<color>"
Ignored for display purposes (shadowed)
Color.IgnoreDisplayOnly.Fore: "<color>"
Color.IgnoreDisplayOnly.Back: "<color>"
Ignored for display purposes (only text on lines)
Color.IgnoreDisplayNonly.Fore: "<color>"
Color.IgnoreDisplayNonly.Back: "<color>"
Ignored for display purposes (blank side)
Color.Deleted.Fore: "<color>"
Color.Deleted.Back: "<color>"
Deleted text
Color.DeletedSup.Fore: "<color>"
Color.DeletedSup.Back: "<color>"
Deleted text (shadowed)
Color.Ignored.Fore: "<color>"
Color.Ignored.Back: "<color>"
Ignore text
Color.Directories.Fore: "<color>"
Color.Directories.Back: "<color>"
(dir.diffs only) Directories in directory diffs
Color.MergedUndecided.Fore: "<color>"
Color.MergedUndecided.Back: "<color>"
Merged view undecided text
Color.MergedDecided1.Fore: "<color>"
Color.MergedDecided1.Back: "<color>"
Merged view decided text, file 1
Color.MergedDecided1Sup.Fore: "<color>"
Color.MergedDecided1Sup.Back: "<color>"
Merged view decided text, file 1 (shadowed)
Color.MergedDecided2.Fore: "<color>"
Color.MergedDecided2.Back: "<color>"
Merged view decided text, file 2
Color.MergedDecided2Sup.Fore: "<color>"
Color.MergedDecided2Sup.Back: "<color>"
Merged view decided text, file 2 (shadowed)
Color.MergedDecided3.Fore: "<color>"
Color.MergedDecided3.Back: "<color>"
Merged view decided text, file 3
Color.MergedDecided3Sup.Fore: "<color>"
Color.MergedDecided3Sup.Back: "<color>"
Merged view decided text, file 3 (shadowed)
Color.MergedDecidedNeither.Fore: "<color>"
Color.MergedDecidedNeither.Back: "<color>"
Merged view decided text, neither files
Color.Background.Fore: "<color>"
Color.Background.Back: "<color>"
Global background color
Color.Cursor.Fore: "<color>"
Color.Cursor.Back: "<color>"
Line cursor color
Color.VerticalLine.Fore: "<color>"
Color.VerticalLine.Back: "<color>"
Vertical line color
Color.TextSelection.Fore: "<color>"
Color.TextSelection.Back: "<color>"
Color of text region selection
ExitOnSame: False
If true, exit if both files have no differences.
ExitIfNoConflicts: False
If true, exit if after an automatic merge there are no conflicts.
ExitWithMergeStatus: False
If true, exit with error code 0 if all merges selected and saved.
AutoSelectMerge: False
Pre-selected non-conflictual regions as an automatic merge would.
IgnoreHorizontalWhitespace: False
Ignore horizontal whitespace in horizontal diffs.
IgnorePerHunkWhitespace: False
For each hunk, ignore hunk if there are only whitespace and line break changes within that hunk. This can be useful for ignoring code reformatting for certain source code languages that allow it (e.g. C++).
FormatClipboardText: True
Enables clipboard (copy-paste) formatting. If disabled, text that goes in the clipboard is simply left unformatted.
IgnoreErrors: False
Disables diff errors reporting.
WarnAboutUnsaved: False
Enables warning upon exiting with unsaved selections.
DisableCursorDisplay: False
Disables displaying the line cursor.
DrawPatternInFillerLines: True
Some people like to have a pattern drawn for filler lines to make it really dead obvious that they are not real lines, but just inserted for display purpose. This setting enables it.
HideCarriageReturns: False
Hides CR characters found in files created under DOS/Windows.
DirDiffIgnoreFileChanges: False
In directory diffs, ignores file changes, show just additions and deletions.
DirDiffBuildSolelyFromOutput: True
In directory diffs, building diffs only from output, not checking against actual directory contents. This is a self-verification feature only, and unless you're doing development you should leave this to default (true).
DirDiffRecursive: False
In directory diffs, enable recursive diff'ing of subdirectories.
UseInternalDiff: True
(Not implemented) Use internal diff computation, does not spawn external diff program.
Show.[NAME]: [True|False]
Set of options to determine if some UI display element is visible or not upon startup.
Show.Toolbar: False
Show toolbar on startup.
Show.LineNumbers: False
Show line numbers on startup.
Show.VerticalLine: False
Show vertical line on startup.
Show.Overview: True
Show toolbar on startup.
Show.Filenames: True
Show toolbar on startup.
Show.PaneMergedView: False
Show pane merged view on startup.
Show.PopupMergedView: False
Show popup merged view on startup.
TabWidth: 8
Tab character alignment width.
Command.[NAME]: "[COMMAND]"
Commands to use to generate diffs. xxdiff is only an interface to display diff results, it doesn't actually compute diffs itself, unless you use the internal commands options, where it uses the same arguments as specified here. Most likely these are the GNU diff commands and options. Note that you can specify command switches here and the user interface will be automatically updated accordingly (e.g. if you set a command with the -w switch, and UI understands that the ignore whitespace feature has been turned on).
Command.DiffFiles2: "diff"
Command to use for comparing two files.
Command.DiffFiles3: "diff3"
Command to use for comparing three files.
Command.DiffDirectories: "diff -q -s"
Command to use for comparing two directories, non-recursively.
Command.DiffDirectoriesRec: "diff -q -s -r"
Command to use for comparing two directories, recursively.
Command.Edit: "/home/blais/p/conf/bin/e"
Command to use to spawn an editor on a file.
CommandSwitch.IgnoreTrailingBlanks: "-b"
CommandSwitch.IgnoreWhitespace: "-w"
CommandSwitch.IgnoreCase: "-i"
CommandSwitch.IgnoreBlankLines: "-B"
CommandSwitch.QualityNormal: ""
CommandSwitch.QualityFastest: "-H"
CommandSwitch.QualityHighest: "-d"
Definitions of cmdline switches that should be used to toggle diff options. These resources allow you to specify what switch corresponds to what feature. The defaults are the GNU diff switches (see diff(1)). These are only valid for two-file diff for now. See also the InitSwitch resources.
InitSwitch.IgnoreTrailingBlanks: Nop
InitSwitch.IgnoreWhitespace: Nop
InitSwitch.IgnoreCase: Nop
InitSwitch.IgnoreBlankLines: Nop
InitSwitch.QualityNormal: Nop
InitSwitch.QualityFastest: Nop
InitSwitch.QualityHighest: Nop
Initialization of a particular switch after the resources have been read in. This is used to modify the command using the switch definitions. In other words, you could either set the switch within the command specification, or use a plain command and enable/disable the switch using this resource. This resource is only provided for completeness and convenience, as setting the appropriate switch in the command itself amounts to the same. See also the CommandSwitch resources. For the quality options, you should just set a single one to 'true'.
OverviewFileWidth: 20
In overview area, width (in pixels) of each file.
OverviewSepWidth: 14
In overview area, width (in pixels) between each file.
VerticalLinePosition: 80
Initial column to draw vertical alignment line.
Tag.[NAME]: [True|False]
Tags used for conditionals used for unselected regions, when that option is used to save files.
Tag.Conflict.Start: "<<<<<<< %L"
String used to indicate the start of a merged merge conflict when saving with conflicts. Default is the CVS start tag.
Tag.Conflict.Sep: "======="
String used to separate sides of a merged merge conflict when saving with conflicts. Default is the CVS separator tag.
Tag.Conflict.SepExtra: "||||||| %M"
String used to separate sides of a merged 3-way merge conflict when saving with conflicts. Default is the tag generated by GNU diff3.
Tag.Conflict.End: ">>>>>>> %R"
String used to end a merged merge conflict when saving with conflicts. Default is the CVS end tag.
Tag.Conditional.Ifdef: "#if defined( %s )"
Ifdef string used when saving with conditionals.
Tag.Conditional.Elseif: "#elif defined( %s )"
Elseif string used when saving with conditionals.
Tag.Conditional.Endif: "#endif"
Endif string used when saving with conditionals.
Tag.Unmerge.Start: "^<<<<<<< (.*)$"
Tag that appears at the beginning of a line in a merged file to indicate the start of a merged merge conflict. Default is the CVS start tag.
Tag.Unmerge.Sep: "^=======\s*$"
Tag that appears at the beginning of a line in a merged file to separate sides of a merged merge conflict. Default is the CVS separator tag.
Tag.Unmerge.SepExtra: "^\|\|\|\|\|\|\| (.*)$"
Tag that appears at the beginning of a line in a merged file to separate sides of a merged 3-way merge conflict. Default is the tag generated by GNU diff3.
Tag.Unmerge.End: "^>>>>>>> (.*)$"
Tag that appears at the beginning of a line in a merged file to indicate the end of a merged merge conflict. Default is the CVS end tag.
ClipboardHeaderFormat: "
In file "%F":
------------------------------
"
Format of header for selection of text for formatted clipboard text.
ClipboardLineFormat: "%L: %s"
Format of each selection line for formatted clipboard text.
HorizontalDiffType: Multiple
Type of horizontal diffs display. Can be one of None, Single, Multiple. None: doesn't compute nor display horizontal diff; Single: just bracket the changes from line beginnings and ends; Multiple: compute multiple horizontal diff (if the sizes fit in the maximum size (see HorizontalDiffMax resource).
HorizontalDiffMax: 10000
Maximum table size for dynamic-programming table used for computing the horizontal diff for change lines. If the size of one horizontal hunk times the size of the other horizontal hunk is over that size, there are no multiple horizontal diffs computed for that line, and the algorithm behaves like the Single algorithm. You most likely don't want to touch that value.
HorizontalDiffContext: 5
Minimum amount of characters or token that need to be common to both lines between multiple horizontal diff hunks. If there are not that amount of common characters, skip the horizontal hunk and display it as a changed region. This resource is very useful to remove the cases where few characters align, resulting in many small horizontal hunks, which can be quite confusing. Usually a value of 5 gives enough horizontal context for the eye to figure out what happenened.
ShowPaneMergedViewPercent: 40
Initial vertical percentage size, between 0 and 100, of the pane merged view on startup.
MergedFilename: "%L.merge"
Default merged filename. %L, %M, %R can be used as placeholders for left, middle and right filenames respectively. Note that ClearCase suffixes are stripped automatically.

14   Frequently Asked Questions (FAQ)

14.1   Can I diff files with CRLF DOS characters in them?

If you want to diff files with CRLF characters in them, you can use the 'ignore whitespace option to GNU diff, which will work, even if only one of the files has the DOS characters in it.

14.2   How do I make xxdiff display the revision number of a file?

By default, the filenames window display the filename. From the command-line, however, you can set it to display an arbitrary string, which could include your current revision number.

15   Author

This program has been written from scratch and is being actively maintained by Martin Blais (blais@furius.ca).

16   Reporting bugs

All bug reports and feature requests should be submitted through the SourceForge bug tracking system at the following URL http://sourceforge.net/bugs/?group_id=2198. Please avoid sending the author email about xxdiff bugs. Please use this bug tracking system, it is extremely fast and simple to use.

17   Project history

This program has been written and inspired after gdiff, mgdiff, and Rudy Wortel's xdiff under SGI. xxdiff aims to provide a lasting open-source replacement to these programs. Writing this tool from scratch was originally motivated by the need to have horizontal diffs, which turned out to be an essential feature of this program.

This program is being extensively tested by several software development engineers at discreet, that use it daily in their merge reviewing activities. It has reached a stable state.

17.1   Licensing

This program is distributed under the GNU General Public License. See the GNU project website for full details.

17.2   Dependencies

This program depends on the availability of a textual diff program (such as GNU diff) and the Qt UI toolkit (available at http://trolltech.com).

17.3   Acknowledgements

Thanks go to discreet, for letting me deploy my program there, and for not bothering me with the occasional bug fix that I did on the job. Many more thanks to all the many engineers who tested it there and reported problems with it, as well as providing invaluable suggestions.

SourceForge is hosting my web site and I'm using many of its features. Tomas Pospisek (tpo at sourcepole.ch) has provided a Debian package. Dan Weeks has packaged it for one of the BSD variants (danimal at danimal.org). Not sure, but I think that Christian Savard (savardc at pobox.com) provided the original Gentoo port (xxdiff is now supported in Gentoo).