3 # Copyright © 2008 Mike O'Connor <stew@vireo.org>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 $0: manage home directory using mr
28 $bn - a command to manage detached git repositories using mr
34 $bn add repository_name
35 $bn new repository_name file1 [file2 file3...]
42 checkout the repository from the remote host and add it to
45 new repository_name file1 [file2 file3...]
46 create a new repository on the remote host, and checkin the
47 listed files to the new repository. Add the new repository
55 GIT_HOST=flounder.vireo.org
61 [ -e source $MOVEIN ] && source $MOVEIN
69 if [ -e $MRCONFIG ]; then
70 echo $MRCONFIG already exists
74 if [ -e $MOVEIN ]; then
75 echo $MOVEIN already exists
79 echo -n "git server hostname? [git.vireo.org] "
81 if [ -z "$GIT_HOST" ]; then
82 GIT_HOST=git.vireo.org
85 echo -n "path to remote repositories? [~/git] "
87 if [ -z "$REMOTE_REPOS" ]; then
91 echo -n "Local repository directory? [~/.fgit] "
93 if [ -z "$LOCAL_REPOS" ]; then
97 echo -n "Location of .mrconfig file? [~/.mrconfig] "
99 if [ -z "$MRCONFIG" ]; then
105 REMOTE_REPOS=$REMOTE_REPOS
106 LOCAL_REPOS=$LOCAL_REPOS
111 cat <<END > $MRCONFIG
113 include = cat /usr/share/mr/git-fake-bare
121 if [ $# -ne 1 ]; then
124 REPO_NAME=$1.git ; shift
125 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
126 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
128 if [ -e "$LOCAL_REPO" ]; then
129 echo $LOCAL_REPO already exists
132 trap "rm -rf $LOCAL_REPO" 0
134 export GIT_DIR="$LOCAL_REPO"
136 git remote add origin $REPO_URL
137 git config branch.master.remote origin
138 git config branch.master.merge refs/heads/master
139 git config core.worktree ../../
140 git config core.bare false
141 GIT_WORK_TREE="$PWD" git pull
143 cat <<END >> $MRCONFIG
146 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'
153 if [ $# -lt 2 ]; then
156 REPO_NAME=$1.git ; shift
157 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
158 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
160 if [ ! -e "$1" ]; then
165 if [ -e "$LOCAL_REPO" ]; then
166 echo $LOCAL_REPO already exists
169 trap "rm -rf $LOCAL_REPO" 0
170 mkdir -p "$LOCAL_REPO"
173 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
176 export GIT_DIR="$LOCAL_REPO"
178 git remote add origin $REPO_URL
179 git config branch.master.remote origin
180 git config branch.master.merge refs/heads/master
181 git config core.worktree ../../
182 git config core.bare false
184 export GIT_WORK_TREE="$PWD"
187 git commit -m "initial checkin"
191 cat <<END >> $MRCONFIG
194 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'