#!/bin/sh

if test "$1" == "rebase" -o "$1" == "amend"; then
read LINE
hash=`echo $LINE | cut -f 1 -d\ `
branch=`git branch --contains $hash | sed "s#*##" | sed "s# ##" | head -n 1`
else
branch=`git rev-parse --abbrev-ref HEAD`
fi

if test "$branch" == "master"
then
echo `git describe` > `git rev-parse --show-toplevel`/VERSION
else
echo $branch-`git rev-parse --short HEAD` > `git rev-parse --show-toplevel`/VERSION
fi
echo "Version=\""`cat VERSION`"\""
