#!/bin/sh

if [ -z $1 ]; then
	echo Usage: $0 headerfile
	exit 1
fi
rinfoheader=$1

oldinfo=
if [ -f $rinfoheader ]; then
	oldinfo=`cat $rinfoheader`
else
	echo > $rinfoheader
fi

rinfo=`git describe --tag --exact-match HEAD 2> /dev/null || git rev-parse --short HEAD`
newinfo="#define CTAGS_REPOINFO \"${rinfo}\""

if [ "$newinfo" != "$oldinfo" ]; then
	echo "$newinfo" > $rinfoheader
fi
