A git pre-commit hook to do SVN style $Date$ substitution

Put the following in .git/pre-commit (make sure it’s executable):

git diff --cached --name-only > commits_list

And the following in .git/post-commit:

#!/bin/bash

if [ -f commits_list ]
then
	currentdate=`date`

	cat commits_list | while read F
	do
 	 echo $PWD/$F
 	 filebase=`basename $F`
 	 sed -i -e 's/\$Date[^$]*\$/\$Date '"$currentdate"'\$/' $PWD/$F
 	 sed -i -e 's/\$Filename[^$]*\$/\$Filename '"$filebase"'\$/' $PWD/$F
	 git add $PWD/$F
	done 

	rm commits_list
	git commit --amend --no-verify -C HEAD

fi

Still not extensively tested…