#!/bin/sh
# Revert file(s) or all modified files in a directory
# and touch them back to the checkin date
for f in "$@"
do
	if [ -d "$f" ]; then
		$0 `git status --porcelain $f/* | egrep "^ M|^M " | sed 's/^...//'`
	else
		if git checkout -- "$f"; then
			changed="`git log --format=%ad --date="format:%Y%m%d%H%M.%S" -1 -- \"$f\"`"
			touch -t $changed "$f"
			echo reverted $f to $changed
		fi
	fi
done
