3 # Copyright © 2008 Mike O'Connor <stew@vireo.org>
10 $0: manage home directory using mr
13 $bn - a command to manage detached git repositories using mr
19 $bn add repository_name
20 $bn new repository_name file1 [file2 file3...]
27 checkout the repository from the remote host and add it to
30 new repository_name file1 [file2 file3...]
31 create a new repository on the remote host, and checkin the
32 listed files to the new repository. Add the new repository
40 GIT_HOST=flounder.vireo.org
54 if [ -e $MRCONFIG ]; then
55 echo $MRCONFIG already exists
59 if [ -e $MOVEIN ]; then
60 echo $MOVEIN already exists
64 echo -n "git server hostname? [git.vireo.org] "
66 if [ -z "$GIT_HOST" ]; then
67 GIT_HOST=git.vireo.org
70 echo -n "path to remote repositories? [~/git] "
72 if [ -z "$REMOTE_REPOS" ]; then
76 echo -n "Local repository directory? [~/.fgit] "
78 if [ -z "$LOCAL_REPOS" ]; then
82 echo -n "Location of .mrconfig file? [~/.mrconfig] "
84 if [ -z "$MRCONFIG" ]; then
90 REMOTE_REPOS=$REMOTE_REPOS
91 LOCAL_REPOS=$LOCAL_REPOS
98 include = cat /usr/share/mr/git-fake-bare
106 if [ $# -ne 1 ]; then
109 REPO_NAME=$1.git ; shift
110 LOCAL_REPO=$LOCAL_REPOS/$REPO_NAME
111 REPO_URL=ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME
113 if [ -e "$LOCAL_REPO" ]; then
114 echo $LOCAL_REPO already exists
117 trap "rm -rf $LOCAL_REPO" 0
119 export GIT_DIR="$LOCAL_REPO"
121 git remote add origin $REPO_URL
122 git config branch.master.remote origin
123 git config branch.master.merge refs/heads/master
124 git config core.worktree ../../
125 git config core.bare false
126 GIT_WORK_TREE="$PWD" git pull
128 cat <<END >> $MRCONFIG
131 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'
138 if [ $# -lt 2 ]; then
141 REPO_NAME=$1.git ; shift
142 LOCAL_REPO="$LOCAL_REPOS/$REPO_NAME"
143 REPO_URL="ssh://$GIT_HOST/$REMOTE_REPOS/$REPO_NAME"
145 if [ ! -e "$1" ]; then
150 if [ -e "$LOCAL_REPO" ]; then
151 echo $LOCAL_REPO already exists
154 trap "rm -rf $LOCAL_REPO" 0
155 mkdir -p "$LOCAL_REPO"
158 GIT_DIR=$REMOTE_REPOS/$REPO_NAME git --bare init
161 export GIT_DIR="$LOCAL_REPO"
163 git remote add origin $REPO_URL
164 git config branch.master.remote origin
165 git config branch.master.merge refs/heads/master
166 git config core.worktree ../../
167 git config core.bare false
169 export GIT_WORK_TREE="$PWD"
172 git commit -m "initial checkin"
176 cat <<END >> $MRCONFIG
179 checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'