#!/bin/bash

# Change one or more normal repos to bare repos:
# https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F

for i in "$@"; do
   echo; echo "----------------------"
   echo Processing $i

   repo="$i"
   repo="`basename $i`"
   tmp_repo="${repo}.git"

   # Insert here: may be exit if any spaces in repo fqn
   # Insert here: check for non-existent repo/.git dir
   # Insert here: check that we are not inside the repo
   # Insert here: add exit/do-nothing if fail to mv dirs etc

   mv $repo/.git $tmp_repo
   git --git-dir=$tmp_repo config core.bare true
   rm -rf $repo
   mv $tmp_repo $repo
done

