How to find out what files aren’t added in your Perforce client

How to find out what files aren’t added in your Perforce client(image taken from jparise’s photstream)

I’ve first used Perforce in 2002. At the time we were using another product. Perforce was about 10 times as fast and 10 times less likely to make me want to storm into the comms room, rip the source code server out the rack and drop it off the fire escape into the street. It was also atomic.

A lot has changed in the intervening years. Subversion has come of age, distributed version control has become the next new thing, and I don’t have access to the comms room any more. Oh, and I’m using Perforce again. One thing I miss is Subversion’s ability to tell you the status of all files in the sandbox (which is roughly equivalent to a P4 client), including unversioned ones:

graham-tackleys-mac-mini:~/Documents/workspace/playpen jsimpson$ svn st
? a.html

In this instance, you can tell that ‘a.html’ and ‘’ aren’t versioned in Subversion because they have a status of ‘?’.

What do you do for the Perforce command line client? If you’re a Windows user, you can do this:

dir /s/b/a-d | p4 -x- have > nul: 2>missing.txt

The part to the left of the pipe (the ‘|’ symbol) gives you a list of all the file in your current working directory. The part to the right of the pipe queries perforce to see if the files are in the repository. Any files that are in the repository get binned, whereas any files that aren’t get written to the missing.txt file with the dreaded Perforce error message: file(s) not on client.

Unix users can try this one:

find . -type f | p4 -x- have > /dev/null 2>missing.txt

This valuable snippet comes from Laura Wingerd’s definitive work on Perforce. Is there another Perforce one-liner that you can’t live without? Let us know!

%d bloggers like this: