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
74 GIT_HOST=git.vireo.org
80 [ -e "$MOVEINRC" ] && . "$MOVEINRC"
88 if [ -e $MOVEINRC ]; then
89 echo $MOVEINRC already exists
93 echo -n "git server hostname? [git.vireo.org] "
95 if [ -z "$GIT_HOST" ]; then
96 GIT_HOST=git.vireo.org
99 echo -n "path to remote repositories? [~/git] "
101 if [ -z "$REMOTE_REPOS" ]; then
105 echo -n "Local repository directory? [~/.movein] "
107 if [ -z "$LOCAL_REPOS" ]; then
108 LOCAL_REPOS=~/.movein
111 echo -n "Location of .mrconfig file? [~/.mrconfig] "
113 if [ -z "$MRCONFIG" ]; then
117 cat <<EOF > $MOVEINRC
119 REMOTE_REPOS=$REMOTE_REPOS
120 LOCAL_REPOS=$LOCAL_REPOS
124 if [ ! -d "$LOCAL_REPOS" ]; then
125 mkdir -p "$LOCAL_REPOS"
128 mr -c "$MRCONFIG" config DEFAULT include="cat /usr/share/mr/git-fake-bare"
133 if [ $# -ne 1 ]; then
137 export GIT_DIR="$LOCAL_REPOS/${1}.git"
138 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
140 GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || :
144 if [ $# -ne 1 ]; then
147 REPO_NAME=$1.git ; shift
148 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
149 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
151 if [ -e "$LOCAL_REPO" ]; then
152 echo $LOCAL_REPO already exists
155 trap "rm -rf $LOCAL_REPO" 0
157 export GIT_DIR="$LOCAL_REPO"
159 git remote add origin $REPO_URL
160 git config branch.master.remote origin
161 git config branch.master.merge refs/heads/master
162 git config core.bare false
163 git config core.worktree ../../
164 git config status.showUntrackedFiles no
165 GIT_WORK_TREE="$LOCAL_REPO/../../" git pull
168 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"
173 find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
178 find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
183 if [ $# -lt 2 ]; then
186 REPO_NAME=$1.git ; shift
187 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
188 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
190 if [ ! -e "$1" ]; then
195 if [ -e "$LOCAL_REPO" ]; then
196 echo $LOCAL_REPO already exists
199 trap "rm -rf $LOCAL_REPO" 0
200 mkdir -p "$LOCAL_REPO"
203 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
206 export GIT_DIR="$LOCAL_REPO"
208 git remote add origin $REPO_URL
209 git config branch.master.remote origin
210 git config branch.master.merge refs/heads/master
211 git config core.bare false
212 git config core.worktree ../../
213 git config status.showUntrackedFiles no
214 export GIT_WORK_TREE="$LOCAL_REPO/../../"
216 git commit -m "initial checkin"
221 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"