Previous Table of Contents Index Next
Perforce 2009.1: Command Reference



p4 diff
Synopsis
Compare a client workspace file to a revision in the depot.
Syntax
p4 [g-opts] diff [-dflag -f -m max -sa -sb -sd -se -sr -sl -t] [file[rev#]...]
Description
p4 diff runs a diff program on the Perforce client, comparing files in the client workspace to revisions in the depot.
This command takes a file argument, which can contain a revision specifier. If a revision specifier is included, the file in the client workspace is diffed against the specified revision. If a revision specifier is not included, the client workspace file is compared against the revision currently being edited (usually the head revision). In either case, the client file must be open for edit, or the comparison must be against a revision other than the one to which the client file was last synced.
If the file argument includes wildcards, all open files that match the file pattern are diffed. If no file argument is provided, all open files are diffed against their depot counterparts.
By default, the diff routine used is the one built into the p4 client program. To change this diff routine to an external diff program, set the P4DIFF environment or registry variable to point to the new program.
Options
-dflags
-m max
Show only the names of files opened for integrate that have been resolved, but that have been modified after being resolved.
Show only the names of unopened files that are missing from the client workspace, but present in the depot.
Show only the names of unopened files in the client workspace that are different than the revision in the depot.
-sl file...
Every unopened file is compared with the depot, and listed with a status of same, diff, or missing.
If you use the -f flag together with the -sl flag, files that are open for edit are also compared and their status is listed.
Usage Notes
Can File Arguments Use
Revision Specifier?
RCS output format, showing additions and deletions made to the file and associated line ranges.
unified output format, showing added and deleted lines with sufficient context for compatibility with the patch(1) utility.
ignore line-ending (CR/LF) convention when finding diffs
p4 diff -dub file
specifies a unified diff that ignores changes in whitespace.
The header line of a unified diff produced with the -du option for use with patch(1) displays filenames in Perforce syntax, not local syntax.
Examples
Compare the client workspace revision of file file to the fifth depot revision.
Compare all open files in the client workspace to the revisions in the depot as of midnight on May 22, 1999.
Run the comparison on file file, displaying output in a format suitable for the patch(1) utility.
This differs from p4 revert -a (revert all unchanged files, where resolving a file, even if no changes are made, counts as a change), in that it reverts files whose workspace content matches the depot content, including resolved files that happen to be identical to those in the depot.
The first command shows all open, unchanged files. The second command (running p4 -x and taking arguments, one per line, from standard input, abbreviated as "-") reverts each file in that list.
(This is the UNIX version of this command; it uses a pipe. Most operating systems have some equivalent way of performing these operations in series).
For more information about the -x option to p4, see the Global Options section.
Related Commands


Previous Table of Contents Index Next

Perforce 2009.1: Command Reference
Copyright 1999-2009 Perforce Software.