p4 diff

Diff utility for comparing workspace content to depot content. (For comparing two depot paths, see p4 diff2.)

Syntax

p4 [g-opts] diff [-doptions] [-f -t -Od] [-m max] [-soptions] [file[rev] ...]

Description

p4 diff runs a diff program on your workstation that compares files in your workspace to revisions in the depot.

This command takes a file argument, which can contain a revision specifier.

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.

Tip

By default, your workstation runs the diff routine built into the p4 command-line application. You can make your workstation run an external diff program by setting the P4DIFF environment variable to point to your external diff program.

Options

-doptions

Pass options to the underlying diff routine (see Usage Notes for details).

-f

Force the diff (if no revision is specified, against the head revision), even when the client file is not open for edit.

-m max

Limit output to diffs (or status) of only the first max files, unless the -s option is used, in which case the -m option is ignored.

-Od

Limit output to only those files that differ.

-soptions

Pass display options to the underlying diff routine (see Usage Notes for details).

-t

Diff the revisions even if the files are not of type text.

g-opts

See Global Options.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

Yes

No

read

Examples

p4 diff file#5

Compare the client workspace revision of file file to the fifth depot revision.

p4 diff @2017/05/22

Compare all open files in the client workspace to the revisions in the depot as of midnight on May 22, 2017.

p4 diff -m 10 @2017/05/22

Limit to the first 10 files the comparison all open files in the client workspace to the revisions in the depot as of midnight on May 22, 2017.

p4 diff -du file

Run the comparison on file file, displaying output in a format suitable for the patch(1) utility.

p4 diff -sr | p4 -x - revert

Revert all open, unchanged files.

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 UNIX version of this command uses a pipe. Most operating systems have a similar way of performing these operations in series).

For more information about the -x option to p4, see Global Options.

Related Commands

To compare two depot revisions

p4 diff2

To view the entire contents of a file

p4 print