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
36 $bn add repository_name
37 $bn new repository_name file1 [file2 file3...]
38 $bn login repository_name
46 show a list of repositories
49 checkout the repository from the remote host and add it to
52 new repository_name file1 [file2 file3...]
53 create a new repository on the remote host, and checkin the
54 listed files to the new repository. Add the new repository
58 start a subshell in repository_name
66 GIT_HOST=git.vireo.org
72 [ -e "$MOVEINRC" ] && . "$MOVEINRC"
80 if [ -e $MRCONFIG ]; then
81 echo $MRCONFIG already exists
85 if [ -e $MOVEINRC ]; then
86 echo $MOVEINRC already exists
90 echo -n "git server hostname? [git.vireo.org] "
92 if [ -z "$GIT_HOST" ]; then
93 GIT_HOST=git.vireo.org
96 echo -n "path to remote repositories? [~/git] "
98 if [ -z "$REMOTE_REPOS" ]; then
102 echo -n "Local repository directory? [~/.movein] "
104 if [ -z "$LOCAL_REPOS" ]; then
105 LOCAL_REPOS=~/.movein
108 echo -n "Location of .mrconfig file? [~/.mrconfig] "
110 if [ -z "$MRCONFIG" ]; then
114 cat <<EOF > $MOVEINRC
116 REMOTE_REPOS=$REMOTE_REPOS
117 LOCAL_REPOS=$LOCAL_REPOS
121 if [ ! -d "$LOCAL_REPOS" ]; then
122 mkdir -p "$LOCAL_REPOS"
125 cat <<END > $MRCONFIG
127 include = cat /usr/share/mr/git-fake-bare
134 if [ $# -ne 1 ]; then
138 export GIT_DIR="$LOCAL_REPOS/${1}.git"
139 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
145 if [ $# -ne 1 ]; then
148 REPO_NAME=$1.git ; shift
149 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
150 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
152 if [ -e "$LOCAL_REPO" ]; then
153 echo $LOCAL_REPO already exists
156 trap "rm -rf $LOCAL_REPO" 0
158 export GIT_DIR="$LOCAL_REPO"
160 git remote add origin $REPO_URL
161 git config branch.master.remote origin
162 git config branch.master.merge refs/heads/master
163 git config core.worktree ../../
164 git config core.bare false
165 GIT_WORK_TREE="$PWD" git pull
167 cat <<END >> $MRCONFIG
170 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'
177 find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
181 if [ $# -lt 2 ]; then
184 REPO_NAME=$1.git ; shift
185 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
186 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
188 if [ ! -e "$1" ]; then
193 if [ -e "$LOCAL_REPO" ]; then
194 echo $LOCAL_REPO already exists
197 trap "rm -rf $LOCAL_REPO" 0
198 mkdir -p "$LOCAL_REPO"
201 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
204 export GIT_DIR="$LOCAL_REPO"
206 git remote add origin $REPO_URL
207 git config branch.master.remote origin
208 git config branch.master.merge refs/heads/master
209 git config core.worktree ../../
210 git config core.bare false
212 export GIT_WORK_TREE="$PWD"
215 git commit -m "initial checkin"
219 cat <<END >> $MRCONFIG
222 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'