Why cowsay is no joke

Created: 11 Oct 2013

A little while ago a colleague asked me a question that made me very happy: he wanted to know if it was me who made a dinosaur that tells people off if they use git incorrectly.

Throughout my time at Songkick we’ve stored internal repositories on a git server ithat we push to via ssh and also throughout that time we’ve also had a number of confused developers on our internal Skype chat wonder why they can’t push to one of them due to broken permissions.

Every time the conversation started with instructions to fix the permissions on the repository and then moves onto the root cause: when creating the repo with git init --bare, the --shared option was not used.

Only now, if you run git on that machine, /usr/local/bin/git steps in and if you’ve forgotten to add --shared you get told off by a stegosaurus:


$ git init
 ________________________________________
/ Friends don't let friends run git init \
\ without --shared                       /
 ----------------------------------------
\                             .       .
 \                           / `.   .' " 
  \                  .---.  <    > <    >  .---.
   \                 |    \  \ - ~ ~ - /  /    |
         _____          ..-~             ~-..-~
        |     |   \~~~\.'                    `./~~~/
       ---------   \__/                        \__/
      .'  O    \     /               /       \  " 
     (_____,    `._.'               |         }  \/~~~/
      `----.          /       }     |        /    \__/
            `-.      |       /      |       /      `. ,~~|
                ~-.__|      /_ - ~ ^|      /- _      `..-'   
                     |     /        |     /     ~-.     `-. _  _  _
                     |_____|        |_____|         ~ - . _ _ _ _ _>

Source of /usr/local/bin/git

#!/bin/bash
#
# Wrapper to stop people creating repos without the --shared option.
# So that there are fewer ragepunches.
 
YOUR_ACTUAL_GIT='/usr/bin/git'
 
if [ "$1" = 'init' ] && ! echo "$@" | egrep -q -- '[[:space:]]--shared([[:space:]]|$)'
then
    cowsay -f stegosaurus \
      "Friends don't let friends run git init without --shared"
    exit 999
else
    exec $YOUR_ACTUAL_GIT "$@"
fi

I had to wait a couple of months until it claimed its first victim.

Making a program to nudge people in the right direction turns out to have been heaps more effective than having endless conversations in Skype about it.

Footnote

I was quite taken with the idea of saying “if I had a pound for every time people complained about broken git permissions, I would have had X pounds” but one of many problems with using Skype for team communications is that it’s almost impossible to find out the value of X, given that there are no useful logfiles.

That lack of useful logs is why the question was asked so many times; since it’s so painfully slow to search many months worth of a busy Skype chat, instead we just ask the question again.