GIT Merge and Diff with p4merge on Mac

September 27, 2011 6 comments

Git is my favorite SCV system up to now and most probably will be in the future. Besides of many great features is has pretty good automatic merge tool, that is able to solve conflicts, but not all of them. I found p4merge tool much better in case of automatic merging and manual solving the most hard conflicts. Is is very simple to mix together those two things to have the best from both of them and now I will show you how to do that.

First of all, you have to install p4merge tool. Go to p4merge tool download page, choose “Browse by platform” tab, pick your platform (in my case it was Macintosh) and download P4V: Visual Client. After downloading, open dmg file and copy p4merge tool to Applications folder in your Dock.

Second step is to create two simple bash scripts: p4merge and p4diff,  that will be executed when git needs merge or diff tool. Create these scripts in directory that is in your’s system PATH (i.e. /usr/local/bin/).


/Applications/ $*


[ $# -eq 7 ] && /usr/local/bin/p4merge "$2" "$PWD/$5"

Don’t forget to add executable mode/flag to these scripts.

After p4merge and scripts are ready it’s time to configure global git settings. Edit ~/.gitconfig file and put following configuration there for merging:

    tool = p4merge
    keepBackup = false
[mergetool "p4merge"]
    cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
    external = p4diff

If you don’t want to use p4merge as diff tool, just comment (using # character) [diff] section. Sometimes it’s faster for me to use command line diff instead of visual one.

Now, when you type “git diff” or “git mergetool” in your’s project directory, p4merge tool will be started.

Categories: mac, source control Tags: , , , , ,

Code Smells After Reading “Clean Code”

July 27, 2011 Leave a comment

I created projects that I don’t want to look at any more, because of complexity and total mess. You probably heard about “Clean Code” by Robert C. Martin, if not I encourage you to buy this book and read it.

I thought that having technical knowledge is enough to create great applications. It’s not true. Source code is written by developers for developers. Having clean code is one of the most important things in software development. It’s very wide idea but I will write the most important (for me) code smells that I will try to use in my all projects. Read more…

My New Avatar at Gravatar

July 26, 2011 Leave a comment

At last I created my own avatar image! Maybe not from the scratch (I took my old picture) but still it’s real pleasure to present something done with my own hands. It took me a while, but I’m not a graphic designer though.

As you can see, it’s very simple one. All I used is Gimp. It is based on IT Crowd serial (introduction scenes). You can see it on my github account or any other page/application that uses

Categories: other Tags:

Print TODO/FIXME Comment as Warning in XCode

July 12, 2011 Leave a comment

When I’m implementing new functionality I start with the general design and then I’m implementing newly created classes and methods. Sometimes I leave a method or two for later implementation (i.e. after creating unit test for this method) and almost always putting comment:

// TODO: nice comment here

It already happened to me, that I left this comment unnecessary or (the worst case scenario) I forgot to implement this TODO part 😦 To get rid of these mistakes you can add Run Script phase in Build Phases of your project’s target with some nice shell command. To do this, click on your target, move to Build Phases tab and in right-bottom corner click Add Build Phase and choose Add Run Script. Leave shell as it is and in the content of the script paste following two lines:

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.mm" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
At the end of second line you can add i.e.:
| grep -v ExternalSources
This will prevent from printing warnings for TODO/FIXME comments in file paths containing “ExternalSources”. It’s in case you use third party source code that still needs some work to be done 🙂
The latest revision of this script can be found at my github repository: todo xcode gist
Categories: mac, programming Tags: , ,

Moving Files in XCode

July 12, 2011 2 comments

Couple of times I made silly mistake of creating new files in XCode project not in the place I want them to be in filesystem. Groups and “real” folders still confuse me. When you have such file in your project that is in correct group, but not in correct folder on the disk and you don’t want to remove it’s reference and add the same file again I have two steps solution for you.

First you open Finder (or any other file commander tool) and move the file to the correct location. When you will open XCode you will see that this moved file is red now (this is expected behavior, XCode cannot find this file under old location):

What you have to do is to highlight this file and open File Inspector (menu View -> Utilities -> File Inspector or by keyboard shortcut <command> + <option> + <1>). Just under Location combo box there is specified current location for this file. Hit the little folder icon on the right and choose the new path of the moved file:

And that’s it. The drawback of this solution is that you have to repeat this steps for each file you want to move, but if you have plenty of them, probably it’s better to remove references and add them again.

Categories: mac, programming Tags:

Learning Ruby with Project Euler

May 2, 2011 Leave a comment

After completing Ruby Koans it’s time to move forward. Next step is Project Euler. There are plenty of problems to solve, so learning advanced Ruby programming will be neccessary.

I created github project where I will post all my solutions. You can also see this project page on my blog, where I will post updates if any.

Categories: programming Tags: , ,

Introducing Jenkins CI to my github projects

May 1, 2011 3 comments

On sunday morning I had an idea of introducing continuous integration (CI) tool for my projects to have one place to see how they are going.

Currently I’m forced to use CruiseControl at work, but I don’t like it much. I was looking for some more user friendly tool. From my teammates working on Java stuff I heard about Hudson. After searching a while, I found Jenkins. It’s fork of Hudson after Oracle claimed the right to Hudson’s trademark (you can read more about it at this wiki page).

It took me about 3 hours to download, install and configure Jenkins. It also includes preparing one of my current projects to run all test cases and builds configurations from command line. I thing it’s pretty easy and takes really small effort.

Now I have automatic builds with test cases execution after each change on my remote github repository. The project you see on the picture is iPhone application, but because I used GHUnit that is able to write tests results in JUnit xml format, I also can see results from all tests.

It’s just the beginning. I’ll try to find other useful features there.

My old project – Crash3D graphic engine

April 28, 2011 Leave a comment

Today I found one of my really old pojects. It’s 3D graphic engine that I wanted to use during development of my games. I’ve never finished it. I even don’t want to look into the source code any more, because I remember that it was horrible. I was learning C++ back then. First I was writing a code and then thinking about design, and of course no tests at all instead of manual ones (today I have totally different philosophy).

Read more…

Categories: programming Tags: ,

My GameDay 2011 Conference Remarks

April 18, 2011 1 comment

That was really interesting weekend. GameDay 2011 conference was the best game development event I’ve been so far (honestly I was only at couple of them in Poland).

More detailed information about the conference you can find on the official web site, but I wanted to write couple of words about my feelings considering each lecture. The event took two days full of interesting speeches and workshops in the evening.

Read more…

CodeRetreat – TDD and Pair Programming

April 10, 2011 Leave a comment

I thought I know much about Test Driven Development (TDD) and Pair Programming. After attending CODERETREAT organized by Software Craftsmanship in Krakow I know that I was wrong. Theory is something totally different then practice.

This event was facilitated by Corey Haines, one of the inventors of this type of exercise (more info about it at this page). He encouraged us to use four elements of simple design, what really increased code testability and made it readable. He was also giving us really good hints during and between coding sessions. Next day I looked at my current home growth projects and realized how much can be improved there.

Software developer is always learning. When one thinks that he knows enough, he just don’t know that he is wrong and need to learn much more.

Categories: events Tags: , ,