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
37 $bn add repository_name
38 $bn new repository_name file1 [file2 file3...]
39 $bn login repository_name
43 create ~/.moveinrc, create/update ~/.mrconfig
47 show a list of repositories
50 checkout the repository from the remote host and add it to
53 new repository_name file1 [file2 file3...]
54 create a new repository on the remote host, and checkin the
55 listed files to the new repository. Add the new repository
59 start a subshell in repository_name
67 GIT_HOST=git.vireo.org
73 [ -e "$MOVEINRC" ] && . "$MOVEINRC"
81 if [ -e $MOVEINRC ]; then
82 echo $MOVEINRC already exists
86 echo -n "git server hostname? [git.vireo.org] "
88 if [ -z "$GIT_HOST" ]; then
89 GIT_HOST=git.vireo.org
92 echo -n "path to remote repositories? [~/git] "
94 if [ -z "$REMOTE_REPOS" ]; then
98 echo -n "Local repository directory? [~/.movein] "
100 if [ -z "$LOCAL_REPOS" ]; then
101 LOCAL_REPOS=~/.movein
104 echo -n "Location of .mrconfig file? [~/.mrconfig] "
106 if [ -z "$MRCONFIG" ]; then
110 cat <<EOF > $MOVEINRC
112 REMOTE_REPOS=$REMOTE_REPOS
113 LOCAL_REPOS=$LOCAL_REPOS
117 if [ ! -d "$LOCAL_REPOS" ]; then
118 mkdir -p "$LOCAL_REPOS"
121 mr -c "$MRCONFIG" config DEFAULT include="cat /usr/share/mr/git-fake-bare"
126 if [ $# -ne 1 ]; then
130 export GIT_DIR="$LOCAL_REPOS/${1}.git"
131 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
133 GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || :
137 if [ $# -ne 1 ]; then
140 REPO_NAME=$1.git ; shift
141 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
142 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
144 if [ -e "$LOCAL_REPO" ]; then
145 echo $LOCAL_REPO already exists
148 trap "rm -rf $LOCAL_REPO" 0
150 export GIT_DIR="$LOCAL_REPO"
152 git remote add origin $REPO_URL
153 git config branch.master.remote origin
154 git config branch.master.merge refs/heads/master
155 git config core.bare false
156 git config core.worktree ../../
157 git config status.showUntrackedFiles no
158 GIT_WORK_TREE="$LOCAL_REPO/../../" git pull
161 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"
166 find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
170 if [ $# -lt 2 ]; then
173 REPO_NAME=$1.git ; shift
174 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
175 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
177 if [ ! -e "$1" ]; then
182 if [ -e "$LOCAL_REPO" ]; then
183 echo $LOCAL_REPO already exists
186 trap "rm -rf $LOCAL_REPO" 0
187 mkdir -p "$LOCAL_REPO"
190 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
193 export GIT_DIR="$LOCAL_REPO"
195 git remote add origin $REPO_URL
196 git config branch.master.remote origin
197 git config branch.master.merge refs/heads/master
198 git config core.bare false
199 git config core.worktree ../../
200 git config status.showUntrackedFiles no
201 export GIT_WORK_TREE="$LOCAL_REPO/../../"
203 git commit -m "initial checkin"
208 mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"