p4 command line equivalent to “git log -p”?
Here's a reasonable approximation:
p4log () { p4 changes "$1" | awk '{print $2}' | xargs -i p4 describe -du {} | less -F}
Note that unlike git log -p
, an argument is mandatory. You can give a pattern like p4log ...
to run it against everything under the current directory recursively.
Details
p4 changes "$1"
: Get one-line change summaries (most recent to oldest) for files matched by the pattern.
awk '{print $2}'
: Extract the change number.
p4 describe -du CHANGE [$CHANGE2 etc]
: Output the complete change description and diffs. The -du specifies unified diff format, which is closest to git's diff format.
xargs -i p4 describe -du {}
: Run the describe command with all the change numbers as its arguments.
less -F
: Page if longer than one screen, dump to terminal otherwise. Git pipes most of its output through less -F by default