cdiff - perform a cleardiff which includes lines of surrounding context
cdiff [-Help] [-Debug] [-after NUMBER] [-before NUMBER] [-blank_ignore] [-fmt FORMAT] [-linenumbers] [-nocontext] [-noheaders] [-noprolog] [-pred] [-unlimited] [-tabstop NUMBER] [-output FILE] XPNAME ...
Print this help message and exit.
Print version information and exit
Enable debugging output.
Number of lines of context to show after a difference.
Number of lines of context to show before a difference.
Show unlimited lines of context (all common lines).
Pass the -blank_ignore option to cleardiff(1).
Include line numbers (for each file) in the output.
Include absolute reference line numbers (for each file) in the output.
Pass the -pred option to cleardiff(1).
Don't print lines of context.
Don't include change headers in the output.
Don't print the ``legend'' prolog at the beginning that shows which file names correspond to which file numbers.
If specified, then expand tab into spaces using the given argument as the tabstop setting (each tab-setting corresponds to the given number of spaces). If unspecified, no tab-expansion is performed.
Specify output format attributes. Valid FORMAT values are:
Specify that output should be in the context-diff format used by Larry
Wall's patch program. Causes all other formats to be ignored (Note:
requires diff -C
).
Specify the prefix for a deleted line (default = ``<'')
Specify the prefix for an inserted line (default = ``>'')
Specify the prefix for a deleted/moved line (default: same as for deleted)
Specify the prefix for an inserted/moved line (default: same as for inserted)
Specify the prefix for a line of context that is common to all files (default = ``'')
Specify the width of any line numbers that are to appear in the output (for use with the -linenumbers and -reflinenumbers options). NUMBER must be a positive integer (default = 4)
Specify that line numbers should be printed in reverse order (for use with the -linenumbers option). By default line numbers are printed left-to-right in the order:
file 1, file 2, ..., file N
Specifying reverse causes them to be printed in reverse order as in:
file N, ..., file 2, file 1
Specify the text to separate a deleted/inserted/common prefix from the actual source (default = ``'')
Specify the prefix (left-header) for header-lines that indicate a change was made (default = ``-----'')
Specify the suffix (right-header) for header-lines that indicate a change was made (default = ``-----'')
Specify the suffix+prefix for header-lines that indicate a change was made
Specify the contents of the dividing line that separates a section of context from the following/preceding section (default = ``*********************************'')
Specify the prefix for the name of the base-file in the prologue section (default = ``<<<'')
Specify the prefix for the name of a contributor-file in the prologue section (default = ``>>>'')
FORMAT keywords may be abbreviated to a unique prefix and are case insensitive. This option may be specified multiple times.
Redirect output to the named file (should have the same effect as redirecting STDOUT on the cmdline using ``> FILE'').
Extended pathname to the desired element in your view (the version path may be abbreviated).
Option names are case insensitive and only a unique prefix is required.
cdiff will produce a serial-format difference listing with surrounding lines of context for the named files. A filename may be specified as a version-extended pathname (abbreviated or otherwise), or simply by a version selector (in which case the corresponding element is assumed to be the same as the element associated with the previously specified filename).
Exit status is 0 if there are no differences to report, 1 if there are, and 2 if an error occurred.
You typically give cdiff a single file if you just want to compare against the predecessor version in ClearCase (the -pred option is the default if only one filename is given):
$ cdiff dir.c
******************************** <<< file 1: /vobs/myproj/dir.c@@/main/4 >>> file 2: dir.c ********************************
static Dta_buf dtabuf; static Dta_buf *dtapnt = &dtabuf; static union REGS reg, nreg;
-----[after 57 inserted 58-61]----- > #if defined(M_I86LM) > static struct SREGS sreg; > #endif > -----[end of inserted lines]----- DIR * opendir(name) char *name; { struct stat statb; ******************************** void closedir(dirp) DIR *dirp; { free_dircontents(dirp->dd_contents); -----[108 changed to 112]----- < free((void *) dirp); ---------- > free((char *) dirp); -----[end of changed lines]----- }
struct direct * readdir(dirp) DIR *dirp;
You can also specify the FROM and TO files directly
$ cdiff dir.c.OLD dir.c
******************************** <<< file 1: dir.c.orig >>> file 2: dir.c ********************************
static Dta_buf dtabuf; static Dta_buf *dtapnt = &dtabuf; static union REGS reg, nreg;
-----[after 57 inserted 58-61]----- > #if defined(M_I86LM) > static struct SREGS sreg; > #endif > -----[end of inserted lines]----- DIR * opendir(name) char *name; { struct stat statb; ******************************** void closedir(dirp) DIR *dirp; { free_dircontents(dirp->dd_contents); -----[108 changed to 112]----- < free((void *) dirp); ---------- > free((char *) dirp); -----[end of changed lines]----- }
struct direct * readdir(dirp) DIR *dirp;
The output is similar to that of cleardiff -serial
except that lines of context are included. The default is to print 5 lines
of surrounding context before and after each insert/change/delete. There is
a -before
and a -after option to change the number of lines of context. There is also a -unlimited option if you want all lines of context to be included. You can use the -linenumbers option to include lines numbers for each file. You can also use the -noheaders option if you dont like seeing the comments in the square brackets with the
dashed lines. Options may be abbreviated to a unique prefix. For example:
$ cdiff -nohead -bef 1 -aft 1 -line dir.c.orig dir.c
******************************** <<< file 1: dir.c.orig >>> file 2: dir.c ******************************** 57 57 > 58 #if defined(M_I86LM) > 59 static struct SREGS sreg; > 60 #endif > 61 58 62 DIR * ******************************** 107 111 free_dircontents(dirp->dd_contents); < 108 free((void *) dirp); > 112 free((char *) dirp); 109 113 } ******************************** 141 145 dirp->dd_cp = dp; < 142 < 143 return 1; 144 146 }
$ cdiff -nohead -bef 1 -aft 1 -line -refline dir.c.orig dir.c
You can add reference line-numbers as well, using the -reflinenumbers to give a unique number to each output line:
******************************** <<< file 1: dir.c.orig >>> file 2: dir.c ******************************** 1 57 57 2 > 58 #if defined(M_I86LM) 3 > 59 static struct SREGS sreg; 4 > 60 #endif 5 > 61 6 > 58 62 DIR * ******************************** 7 107 111 free_dircontents(dirp->dd_contents); 8 < 108 free((void *) dirp); 9 > 112 free((char *) dirp); 10 109 113 } ******************************** 11 141 145 dirp->dd_cp = dp; 12 < 142 13 < 143 return 1; 14 144 146 }
There is also a -fmt option which can take several different keyword settings to change the output format:
$ cdiff -fmt del=DELETE -fmt ins=INSERT -fmt sep='|' \ -noheaders -bef 2 -aft 2 -line \ dir.c.orig dir.c
******************************** <<< file 1: dir.c.orig >>> file 2: dir.c ******************************** 56 56 | static union REGS reg, nreg; 57 57 | INSERT 58 | #if defined(M_I86LM) INSERT 59 | static struct SREGS sreg; INSERT 60 | #endif INSERT 61 | 58 62 | DIR * 59 63 | opendir(name) ******************************** 106 110 | { 107 111 | free_dircontents(dirp->dd_contents); DELETE 108 | free((void *) dirp); INSERT 112 | free((char *) dirp); 109 113 | } 110 114 | ******************************** 140 144 | dirp->dd_loc = off - (i + 1); 141 145 | dirp->dd_cp = dp; DELETE 142 | DELETE 143 | return 1; 144 146 | } 145 147 |
Hopefully, this ``tutorial'' should have provided you with a good set of cookbook examples for using cdiff. if you ever want to see this manual page, you need only invoke cdiff using the -help option:
$ cdiff -help
sclc -- sclc uses cdiff to compare versions of files when counting lines of source code
Brad Appleton <brad@bradapp.net