#!/bin/sh # # Copyright © 2008 Mike O'Connor # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any # later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. set -e usage() { bn=$(basename $0) cat < $MOVEINRC GIT_HOST=$GIT_HOST REMOTE_REPOS=$REMOTE_REPOS LOCAL_REPOS=$LOCAL_REPOS MRCONFIG=$MRCONFIG EOF if [ ! -d "$LOCAL_REPOS" ]; then mkdir -p "$LOCAL_REPOS" fi mr -c "$MRCONFIG" config DEFAULT include="cat /usr/share/mr/git-fake-bare" } login() { if [ $# -ne 1 ]; then usage fi export GIT_DIR="$LOCAL_REPOS/${1}.git" export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)" GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || : } execin() { local REPO if [ $# -lt 1 ]; then usage fi REPO=$1;shift export GIT_DIR="$LOCAL_REPOS/${REPO}.git" export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)" "$@" } add() { if [ $# -ne 1 ]; then usage fi REPO_NAME=$1.git ; shift LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME if [ -e "$LOCAL_REPO" ]; then echo $LOCAL_REPO already exists exit 1 else trap "rm -rf $LOCAL_REPO" 0 mkdir "$LOCAL_REPO" export GIT_DIR="$LOCAL_REPO" git init --bare git remote add origin $REPO_URL git config branch.master.remote origin git config branch.master.merge refs/heads/master git config core.bare false git config core.worktree ../../ git config status.showUntrackedFiles no GIT_WORK_TREE="$LOCAL_REPO/../../" git pull trap - 0 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'" fi } list() { find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,' } listremote() { ssh $GIT_HOST " find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,' "