All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
   3 # mrsetup - set up an account using mr
 
   5 # Copyright © 2008 martin f. krafft <madduck@madduck.net>
 
   6 # Released under the terms of the Artistic Licence 2.0
 
  10 MY_GIT_SERVER=git.madduck.net
 
  12 MY_ACCOUNT="$(whoami)@$(hostname --fqdn)"
 
  13 MY_ACCOUNT_GIT_REPO=${MY_GIT_REPOS}/accounts/${MY_ACCOUNT}.git
 
  14 MY_GIT_URL_BASE=ssh://$MY_GIT_SERVER
 
  15 MY_MR_REPO_URL=$MY_GIT_URL_BASE/$MY_GIT_REPOS/pub/etc/mr.git
 
  16 MY_ACCOUNT_REPO_URL=$MY_GIT_URL_BASE/$MY_ACCOUNT_GIT_REPO
 
  17 MR_REPO_URL=ssh://git.madduck.net/~/git/pub/code/mr.git
 
  23 if [ -z "${SSH_AUTH_SOCK:-}" ]; then
 
  24   echo E: '$SSH_AUTH_SOCK' is not set. >&2
 
  28 if [ ! -x "$(command -v git)" ]; then
 
  29   echo E: git is not installed. >&2
 
  33 if [ -e .mrconfig ]; then
 
  34   echo E: .mrconfig already exists. >&2
 
  38 if [ -d "$MR_FGIT" ]; then
 
  39   echo E: "$MR_FGIT" already exists. >&2
 
  43 if [ -d ".git" ]; then
 
  44   echo E: .git already exists. >&2
 
  48 if [ -d code/mr ]; then
 
  49   if [ -x code/mr/mr ]; then
 
  50     echo W: code/mr already exists, let us hope for the best... >&2
 
  52     echo E: code/mr already exists. >&2
 
  56   echo I: cloning mr into ${MR_CODE}...
 
  57   mkdir --parent ${MR_CODE%/*}
 
  58   git clone --no-checkout $MR_REPO_URL $MR_CODE
 
  59   (cd $MR_CODE && git checkout -b vcsh origin/vcsh)
 
  60   mkdir --parent $BIN_DIR
 
  61   ln -s ../${MR_CODE}/mr $BIN_DIR/mr
 
  65 cat <<_eof > .mrconfig
 
  67 include = cat $MR_CODE/lib/*
 
  70 checkout = git_fake_bare_checkout $MY_MR_REPO_URL ${MR_FGIT##*/} ../../
 
  72 echo I: initial .mrconfig:
 
  76 echo I: cloning mr configuration...
 
  80 echo I: bootstrapping default .mrconfig...
 
  81 cp $MR/templ/.mrconfig .
 
  83 echo I: setting up base...
 
  86 if ssh $MY_GIT_SERVER "test -d $MY_ACCOUNT_GIT_REPO" </dev/null; then
 
  87   echo I: checking out local git repository...
 
  88   dir="$(mktemp -d home.XXXXXXXX)"
 
  90   git clone --no-checkout $MY_ACCOUNT_REPO_URL "$dir"/co
 
  92   git checkout-index --quiet --index --all
 
  98   echo I: creating remote git repository for this account...
 
 100     GIT_DIR=${MY_ACCOUNT_GIT_REPO} git --bare init
 
 101     echo 'account setup for $MY_ACCOUNT'
 
 103   echo I: setting up local git repository...
 
 105   git remote add origin $MY_ACCOUNT_REPO_URL
 
 106   git config branch.master.remote origin
 
 107   git config branch.master.merge refs/heads/master
 
 109   git commit -m'initial checkin'
 
 114 echo I: spawning a shell...
 
 115 $SHELL -i -l </dev/tty >/dev/tty
 
 117 echo I: back from the shell.