Diff utility for comparing the content at two repo paths. (For comparing workspace content to repo content, see p4 diff (graph).)
p4 diff2 [options] fromFile[@sha1|@reference] tofile[@sha1|@reference]
p4 diff2
runs on the server to compare one set of graph repo files (the 'source') to another (the 'target'). Source and target file sets can be specified on the 'p4 diff2' command line.
fromFile and toFile can include @sha1 or @reference specifiers; by default, the head revisions are diffed.
'p4 diff2' precedes each diffed file pair with a header line of the
following form:
==== source#rev (type) - target#rev (type) ==== summary
A source or target file shown as '<none>' means there is no file at the specified name or reference to pair with its counterpart. The summary status is one of the following: 'identical' means file contents and types are identical, 'types' means file contents are identical but the types are different, and 'content' means file contents are different.
|
Runs the diff routine with one of a subset of the standard UNIX diff options. See p4 diff2 (graph) for a listing of these options. |
|
Limit output to only those files that differ. |
|
Quiet diff. Display only the header; if file1 and
file2 are identical, display only
" |
|
Generate unified output format, showing added and deleted lines
with sufficient context for compatibility with the
|
The diff options supported by p4 diff2
are:
Option | Name |
---|---|
|
RCS output format, showing additions and deletions made to the file and associated line ranges. |
|
context output format, showing line number ranges and num lines of context around the changes. |
|
summary output format, showing only the number of chunks and lines added, deleted, or changed. |
|
unified output format, showing added and deleted lines with
num lines of context, in a form compatible with the
|
|
ignore line-ending (CR/LF) convention when finding diffs |
|
ignore changes made within whitespace; this option implies
|
|
ignore whitespace altogether; this option implies
|
To pass more than one option to the diff routine, group them together. For example:
$ p4 diff2 -dub file1 file2
specifies a unified diff that ignores changes in whitespace.
-du
option for patch(1)
use displays the diffed files in
Helix Server
syntax, not local syntax.When p4 diff2
is used to diff
binary
files, the line
... files differ ...
is printed if they are not identical.
-b branch[[fromfile[rev]]
tofile[rev]]
allows you to specify a
fromfile
file pattern and a
tofile
revision, or a fromfile
revision and a tofile
file pattern.p4
diff2
.p4 diff2 //repo/main/src/...@00662f4 //repo/main/src/...@refs/heads/bugfix
where @00662f4
represents the commit SHA-1 and refs/heads/bugfix
represents the branch. The output might show differences between the files currently in the branch and files in the commit:
==== //repo/main/src/chat.c#1e7637e (text) - //repo/main/src/chat.c#1e7637e (text) ==== identical ==== //repo/main/src/db.c#6950848 (text) - //repo/main/src/db.c#2ab62af (text) ==== content 2,3d1 < Additional database code. < Add Btree code ==== //repo/main/src/main.c#184e90a (text) - //repo/main/src/main.c#5a8f6ff (text) ==== content 3d2 < Enable additional database code.
where #number represents the blob SHA-1 of a file associated with the commit SHA-1.