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,
26 $0: manage home directory using mr
29 $bn - a command to manage detached git repositories using mr
39 $bn add repository_name
40 $bn new repository_name file1 [file2 file3...]
41 $bn login repository_name
45 create ~/.moveinrc, create/update ~/.mrconfig
49 show a list of local repositories
53 show a list of remote repositories
56 checkout the repository from the remote host and add it to
59 new repository_name file1 [file2 file3...]
60 create a new repository on the remote host, and checkin the
61 listed files to the new repository. Add the new repository
65 start a subshell in repository_name
73 GIT_HOST=git.vireo.org
79 [ -e "$MOVEINRC" ] && . "$MOVEINRC"
87 if [ -e $MOVEINRC ]; then
88 echo $MOVEINRC already exists
92 echo -n "git server hostname? [git.vireo.org] "
94 if [ -z "$GIT_HOST" ]; then
95 GIT_HOST=git.vireo.org
98 echo -n "path to remote repositories? [~/git] "
100 if [ -z "$REMOTE_REPOS" ]; then
104 echo -n "Local repository directory? [~/.movein] "
106 if [ -z "$LOCAL_REPOS" ]; then
107 LOCAL_REPOS=~/.movein
110 echo -n "Location of .mrconfig file? [~/.mrconfig] "
112 if [ -z "$MRCONFIG" ]; then
116 cat <<EOF > $MOVEINRC
118 REMOTE_REPOS=$REMOTE_REPOS
119 LOCAL_REPOS=$LOCAL_REPOS
123 if [ ! -d "$LOCAL_REPOS" ]; then
124 mkdir -p "$LOCAL_REPOS"
127 mr -c "$MRCONFIG" config DEFAULT include="cat /usr/share/mr/git-fake-bare"
132 if [ $# -ne 1 ]; then
136 export GIT_DIR="$LOCAL_REPOS/${1}.git"
137 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
139 GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || :
143 if [ $# -ne 1 ]; then
146 REPO_NAME=$1.git ; shift
147 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
148 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
150 if [ -e "$LOCAL_REPO" ]; then
151 echo $LOCAL_REPO already exists
154 trap "rm -rf $LOCAL_REPO" 0
156 export GIT_DIR="$LOCAL_REPO"
158 git remote add origin $REPO_URL
159 git config branch.master.remote origin
160 git config branch.master.merge refs/heads/master
161 git config core.bare false
162 git config core.worktree ../../
163 git config status.showUntrackedFiles no
164 GIT_WORK_TREE="$LOCAL_REPO/../../" git pull
167 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"
172 find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
177 find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
182 if [ $# -lt 2 ]; then
185 REPO_NAME=$1.git ; shift
186 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
187 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
189 if [ ! -e "$1" ]; then
194 if [ -e "$LOCAL_REPO" ]; then
195 echo $LOCAL_REPO already exists
198 trap "rm -rf $LOCAL_REPO" 0
199 mkdir -p "$LOCAL_REPO"
202 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
205 export GIT_DIR="$LOCAL_REPO"
207 git remote add origin $REPO_URL
208 git config branch.master.remote origin
209 git config branch.master.merge refs/heads/master
210 git config core.bare false
211 git config core.worktree ../../
212 git config status.showUntrackedFiles no
213 export GIT_WORK_TREE="$LOCAL_REPO/../../"
215 git commit -m "initial checkin"
220 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"