Try appending "@all" to the file path. For example, this produces a single-revision repo for me:
python /usr/share/doc/git-core/contrib/fast-import/git-p4 clone --destination=master-pom \
//depot/services/master-pom/trunk/...
This command imported the full history:
python /usr/share/doc/git-core/contrib/fast-import/git-p4 clone --destination=master-pom \
//depot/services/master-pom/trunk/...@all
I tried using the example git-p4 but gave up for several reasons and wrote my own fast-import pump. It was a while back, so some of the problems may have been fixed now: but git-p4 had trouble with large changelists (such as the initial creation of a branch) (although using the client spec may have helped, I don't think I tried it) and files with the "+S" filetype modifier (which is Bad And Evil, but we used to use it). And my Python-fu wasn't up to letting me fix the issues I had.
EDIT: since someone asked for it, here it is.
http://www.araqnid.plus.com/p4utils.git/ has several p4 things, of which p4-git-xfer is the p4->git (one-way) replicator. It has quite a few issues though, due to being mainly a personal handy-tool rather than a real piece of infrastructure.
Getting started:
p4-git-xfer clone -d $PWD/dictionary.git -n //depot/services/midoffice/dictionary/... \
trunk 'release/*' 'branch/*' \
trunk=master release/*=r* branch/*=dev/*
will clone that perforce path to a bare "dictionary.git". The first arguments after the base path are "branch specs" that tell the replicator where to find branches under the base. The later ones (with '=' symbols) are "mirror specs" that tell the replicator how to create local branches from the imported ones. The branch specs cause "refs/remotes/p4/trunk", "refs/remotes/p4/release/1.0" etc. to be created. The mirror specs force "refs/heads/master" to mirror "refs/remotes/p4/trunk", "refs/heads/r1.0" to mirror "refs/remotes/p4/release/1.0" etc. It was intended as a way to allow me to select just particular branches from those that were replicated to get propagated to clones.
It will attempt to detect how a branch is created, but that's a bit of a guess anyway with Perforce. Apart from that, it doesn't try to do any branch tracking at all: even whole-branch merges won't be written out as such, sorry.
After the initial clone, running p4-git-xfer fetch
from inside the git replica will do an incremental update. The high-water-mark changelist is taken from marks/p4
within the git repo. This is a marks file that fast-import loads, so if you do any fancy footwork like using filter-branch to rewrite things, beware you may have to update this too.
It's not pretty, and has some medium-to-serious issues; I use it mainly for my own convenience, to isolate myself from Perforce problems, not as a day-to-day criticial infrastructure component. It's one-way: I generally use the p4-am script to apply patches created by git format-patch
. That itself only works mostly, with general parsing nastiness, problems with end-of-file newlines, binary changes etc.