Annoyance, colored diffs in perforce

February 1, 2010

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.

tags: , , , ,
posted in color, git, perforce, ruby, terminal by Lee

Follow comments via the RSS Feed | Leave a comment | Trackback URL

7 Comments to "Annoyance, colored diffs in perforce"

  1. bartman wrote:

    > 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 wrote:

    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 wrote:

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

  4. Eric wrote:

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

    export P4DIFF=colordiff; p4 diff -dU 5

  5. tfi fridays wrote:

    I am starting to take my feet on associate packages too, so this text is excellent place to begin! Shared it on Stumbleupon and submitted on Digg

  6. Let vim colorize p4 diff | parseInt('010') wrote:

    […] to know this today from here. Share this:TwitterFacebookLinkedInLike this:LikeBe the first to like this post. This entry was […]

  7. Jason wrote:

    Thanks, very handy.

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org