Perforce 2005.1 Command Reference
<< Previous Chapter
p4 diff
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 dirs

p4 diff2

Synopsis

Compare two depot file revisions.

Syntax

p4 [g-opts] diff2 [-dflags -q -t] file1[rev] file2[rev]
p4 [g-opts] diff2 [-dflags -q -t] -b branch [[fromfile[rev]] tofile[rev]]

Description

p4 diff2 uses the Perforce server's built-in diff routine to compare two file revisions from the depot. These revisions are usually two versions of the same file, but they can be revisions of entirely separate files. If no file revision is explicitly provided with the file argument, the head revision is used.

p4 diff2 does not use the diff program specified by the environment variable P4DIFF. The diff algorithm used by p4 diff2 runs on the machine hosting the Perforce server, and always uses the server's built-in diff routine.

You can specify file patterns as arguments in place of specific files, with or without revision specifiers; this causes Perforce to perform multiple diffs for each pair of files that match the given pattern. If you invoke p4 diff2 with file patterns, escape the file patterns from the OS shell by using quotes or backslashes, and be sure that the wildcards in the two file patterns match.

Perforce presents the diffs in UNIX diff format, prepended with a header. The header is formatted as follows:

The possible values and meanings of summary are:

If either file1 or file2 does not exist at the specified revision, the header will display the summary as <none>.

Options

-q

Quiet diff. Display only the header, and don't even display that when the file revisions' contents and types are identical.

-dflags

Runs the diff routine with one of a subset of the standard UNIX diff flags. See the Usage Notes below for a listing of these flags.

-b branchname
fromfile[rev] tofile[rev]

Use a branch specification to diff files in two branched codelines. The files that are compared can be limited by file patterns in either fromfile or tofile.

-t

Diff the file revisions even if the file(s) are not of type text.

g-opts

See the Global Options section.

Usage Notes

Can File Arguments Use
Revision Specifier?

Can File Arguments Use
Revision Range?

Minimal Access Level Required

Yes

No

read access necessary
for both file revisions

specifies a unified diff that ignores changes in whitespace.

is printed if they are not identical.

Examples

p4 diff2 -ds file#1 file

Compare the second revision of file file to its head revision, and display a summary of what chunks were added to, deleted from, or changed within the file.

p4 diff2
file@34 file@1998/12/04

Diff the revision of file that was in the depot after changelist 34 was submitted against the revision in the depot at midnight on December 4, 1998.

p4 diff2
//depot/rel1/... //depot/rel2/...#4

Compare the head revisions of all files under //depot/rel1 to the fourth revision of all files under //depot/rel2

p4 diff2
//depot/rel1/* //depot/rel2/...

Not allowed. The wildcards in each file pattern must match.

p4 diff2
-b branch2 //depot/rel2/...#2 @50

Compare the second revision of the files in //depot/rel2/... to the files branched from it by branch specification branch2 at the revision they were at in changelist 50.

Related Commands

To compare a client workspace file to a depot file revision

p4 diff

To view the entire contents of a file

p4 print


Perforce 2005.1 Command Reference
<< Previous Chapter
p4 diff
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 dirs
Please send comments and questions about this manual to [email protected].
Copyright 1999-2005 Perforce Software. All rights reserved.
Last updated: 05/12/05