+#!/bin/bash
+# usage: ungitar foo-dir <foo.gitar
+
+set -e
+trap "echo 'Unexpected error!' 1>&2" ERR
+if ! [ -e "$1" ]; then
+ mkdir "$1"
+fi
+cd "$1"
+
+if [ -e '.git' ]; then
+ echo 'The destination directory is already a git repository!' 1>&2
+ exit 1
+fi
+trap "rm -rf .git" EXIT
+
+ftx .git
+git-read-tree master
+git-checkout-index --all --force