Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Tuesday, October 12, 2010

Colorizing and autopaging svn diffs and other commands

I can't remember the last time I jacked off to black and white pornography.

Can you?

OF COURSE YOU CANT! Color is fucking awesome! No one yanks their crank to black and white shit anymore.

Once you've tasted color, you can never go back.

This brings us to the subject of version control. Over the last few years I've been spoiled by git, but have recently switched jobs and been using svn again. Using git has taught me to actually care what I'm committing — as opposed to just creating one giant commit at the end of the day — which has meant I've been looking at lots of diffs.

Git gives you lovely colorized, paged diffs that frequently stiffen the schlong. While svn, on the other hand, still gives you the same uncolored, unpaged horse shit as it did several years ago! I can't fucking believe the meat puppets at svn haven't gotten their asses into gear and stolen some basic UI ideas from the competition. WTF guys?!

Here's how you enable color for everything in git:

git config --global color.ui always

There are more granular options if you want them, but fuck that, color is awesome!

Svn has no such option. So I, like many others, have been forced to hack the mainframe to get color. Check my hacks:


This script defines a function called "svn" that hijacks calls to the svn program and essentially rewrites some of the commands. For example, this command:

svn diff -r1:7 foo

would get rewritten to:

svn diff -r1:7 foo | colordiff | sed -e 's/\r//g' | less -RF

Another example:

svn log foo

would get rewritten to:

svn log foo | less -F

Notice that I'm still interacting with svn via the same command set, and am not training myself away from the existing commands. Hopefully this will prevent me from losing the plot and ripping off cocks when forced to use svn on a machine that doesn't have my hacks.

Sunday, October 5, 2008

git add --patch gives me an erection

One of the reasons I tossed out my playboys and husslers in favour of the git man pages is git add --patch (or git add -p)

To say something like
git add -p is the fucking bomb, I wish it was a pony so I could ride it around the backyard and pet it and feed it straw all day long
would be the understatement of the new millenium.

If you use git and aren't familiar with git add -p, then take off your pants and read this raving immediately.

OMG wtf is it?!!?


git add --patch lets you cherry pick the changes you want to add to the index. This means you can make 10 changes to a file, then only add 5 of them to the next commit.

I dunno about you, but when I'm hacking the mainframe I can never seem to stick to one task. I always notice some bug, or some fucked up white space, or have to hack something else to get the current task done etc. Its nigh fucking impossible for me to keep the changes I make suitable for one atomic commit.

So I'm a bad boy. I don't care. Smack my ass and tell my parents. Just make sure you have breasts and a vagina if you do, or I'll bust your fucking chops. Hell, you can even skip the vagina if your breasts are exceptional, but don't try and tell me your working directory doesn't get tangled as fuck too.

How do you use it?


It's easy. Just go git add -p file1 file2 ... or just git add -p to work with all tracked files. This launches a program that will loop through all the changed hunks one by one asking you whether you want to stage them or not. It looks a lil sumthang like this:



For every hunk, it prints out a diff and asks you what to do with it. You can hit ? to see the choices you have:


To quit just hit ctrl-c but be aware that the hunks you added will still be in the index.

Other useful tidbits


git add -p is actually a sub routine of the git add --interactive program. Sometimes it's faster to use git add --interactive (aka git add -i) to select which files you want git add -p to work with rather than entering them in on the command line.

Remember to do a git diff --cached to before you do the final git commit to make sure you didn't add anything extra by mistake.

If you do add something by mistake then use git reset HEAD path/to/file to remove the changes from the index.



Have a nice day.

Sunday, July 13, 2008

git commit --amend gives me an erection

Sometimes at work, I find out something that is so fucking awesome I just have to tell someone. Unfortunately, there usually is no one at work to tell since no one would understand my ravings. At times like these the best I can do is check left, then right, then quietly jack off under my desk.

Needless to say, when I discovered the --amend flag for git commit, my righty was down my pants in a flash.

Lemme explain the use case. One day that evil porn star genius Doctor Coctopus decides to upgrade the AI in his extra appendages to allow him to act in multiple sex scenes simultaneously. He hacks furiously at the mainframe for a bit and arrives at a good point to commit his work. He does the following:

git add pron_hacks.c
git add more_pron_hacks.c
git add extreme_pron_hacks.c
git commit

He then does some more hacks before realising that he forgot to add some stuff to the previous commit! Fuck!

If he didn't know about git commit --amend he might do something like this:

git reset --soft HEAD~1
git add auxiliary_pron_hacks.c
git commit

He would then have to remember the commit message he typed and reproduce it (adding some extra bits for the new stuff).

But, if he did know about git commit --amend he would do something like this instead:

git add auxiliary_pron_hacks.c
git commit --amend

This would alter the previous commit, incorporating the new changes. It would also prefill his commit message with the old commit message.


I forget to add code to my commits all the fucking time (probably because I use git add -i and go into patch mode so much), so for me the --amend flag is THA SHIT.