#!/bin/sh LANG=C; export LANG PROGNAME=${0##*/} BASEDIR=~git err () { echo "$PROGNAME: $@" 1>&2 exit 1 } usage () { echo "Usage: $PROGNAME REPOS" exit 1 } while getopts 'hm:' ch; do case $ch in m) description=$OPTARG;; h) usage;; \?) exit 1;; esac done if [ -n "$1" ]; then case "$1" in *[./]*) err "Invalid repository name";; esac GIT_DIR="$BASEDIR/$1.git" else if [ -z "$GIT_DIR" ]; then err "Missing GIT_DIR" fi fi if [ -d "$GIT_DIR" ]; then err "$GIT_DIR already exists" fi if [ -z "$description" ]; then description="Git repository ${GIT_DIR##*/} created by $PROGNAME at `date`" fi set -e export GIT_DIR git init --bare --shared=group echo "$description" > "$GIT_DIR/description"