Annoyance, colored diffs in perforce

Quick one-off here, let’s begin.

Git has nice colored diffs, like this:

Perforce does not:

A simple script can remedy this:

Here’s the script:

Simply drop it somewhere in your $PATH and use it like so:

p4 diff | p4c.rb

You can find it in my one-offs directory (it’s called p4c.rb). We recently switched from subversion to perforce (definitely not my choice, I pushed for git), and so far it’s awful. I am definitely not a fan. This makes it a little better.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Comments

4 Responses to “Annoyance, colored diffs in perforce”

  1. bartman on February 1st, 2010 7:39 pm

    > We recently switched from subversion to perforce (definitely not my choice, I pushed for git).

    Hehe… I had the same thing happen to me recently. My solution was to start using git-p4, as I had been using git-svn before. Give it a try, it’s actually pretty good… albeit slower then git-svn.

  2. bartman on February 1st, 2010 7:41 pm

    Oh, one more thing.

    Since your blog is titled :wq … I imagine you use vim. Why not let vim color your diffs?

    p4 diff | vim -R -

    I keep this handy shell function around:

    v() { $@ | vim -R – ; }

    So I can simplify the above as:

    v p4 diff

    … well, if I actually ever wanted to run p4 directly :)

  3. David on March 12th, 2010 1:15 pm

    If you want it even closer to a git diff, use unified mode:
    p4 diff -du

  4. Eric on May 26th, 2010 11:43 am

    Set the P4DIFF ennvironment variable to colordiff… a tool which colorizes diff output. For example:

    export P4DIFF=colordiff; p4 diff -dU 5

Leave a Reply




Bad Behavior has blocked 228 access attempts in the last 7 days.