]> ToastFreeware Gitweb - gregoa/movein.git/blobdiff - movein
add manpage
[gregoa/movein.git] / movein
diff --git a/movein b/movein
index a6a7bc43cdaec434bc3d92a843d80a2880a19748..f236b1448aa532fb26190df40026e24280b1a75e 100755 (executable)
--- a/movein
+++ b/movein
@@ -17,6 +17,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 # USA.  
 
+
 set -e
 
 usage() {
@@ -33,17 +34,24 @@ SYNOPSIS
   $bn init
   $bn ls
   $bn list
+  $bn ls-r
+  $bn list-remote
   $bn add repository_name
   $bn new repository_name file1 [file2 file3...]
   $bn login repository_name
+  $bn exec repository_name command [arg1 arg2...]
 
 COMMANDS
   init 
-      create ~/.mrconfig
+      create ~/.moveinrc, create/update  ~/.mrconfig
 
   ls
   list
-      show a list of repositories
+      show a list of local repositories
+
+  ls-r
+  list-remote
+      show a list of remote repositories
 
   add repository_name
       checkout the repository from the remote host and add it to
@@ -57,11 +65,17 @@ COMMANDS
   login repository_name
       start a subshell in repository_name
 
+  exec repository_name command [arg1 arg2...]
+      execute a command in the context of repository_name, for example:
+        $bn exec myrepo git status
+        $bn exec myrepo git ls-files
+
 EOF
 
     exit 1
 }
 
+[ $# -ge 1 ] || usage
 
 GIT_HOST=git.vireo.org
 REMOTE_REPOS=~/git
@@ -77,11 +91,6 @@ init() {
        usage
     fi
     
-    if [ -e $MRCONFIG ]; then
-       echo $MRCONFIG already exists
-       exit 1
-    fi
-    
     if [ -e $MOVEINRC ]; then
        echo $MOVEINRC already exists
        exit 1
@@ -122,11 +131,7 @@ EOF
        mkdir -p "$LOCAL_REPOS"
     fi
 
-    cat <<END > $MRCONFIG
-[DEFAULT]
-include = cat /usr/share/mr/git-fake-bare
-END
-
+    mr -c "$MRCONFIG" config DEFAULT include="cat /usr/share/mr/git-fake-bare"
     
 }
 
@@ -138,7 +143,21 @@ login() {
     export GIT_DIR="$LOCAL_REPOS/${1}.git"
     export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
 
-    $SHELL -i || :
+    GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || :
+}
+
+execin() {
+    local REPO
+    if [ $# -lt 1 ]; then
+       usage
+    fi
+
+    REPO=$1;shift
+
+    export GIT_DIR="$LOCAL_REPOS/${REPO}.git"
+    export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
+
+    "$@"
 }
 
 add() {
@@ -160,23 +179,26 @@ add() {
        git remote add origin $REPO_URL
        git config branch.master.remote origin
        git config branch.master.merge refs/heads/master
-       git config core.worktree ../../
        git config core.bare false
-       GIT_WORK_TREE="$PWD" git pull
+       git config core.worktree ../../
+       git config status.showUntrackedFiles no
+       GIT_WORK_TREE="$LOCAL_REPO/../../" git pull
        trap - 0
-       cat <<END >> $MRCONFIG
 
-[$LOCAL_REPO]
-checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'
-END
+       mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"
     fi
-
 }
 
 list() {
     find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
 }
 
+listremote() {
+    ssh $GIT_HOST "
+        find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
+    " </dev/null
+}
+
 new() {
     if [ $# -lt 2 ]; then 
        usage
@@ -206,21 +228,17 @@ new() {
        git remote add origin $REPO_URL
        git config branch.master.remote origin
        git config branch.master.merge refs/heads/master
-       git config core.worktree ../../
        git config core.bare false
-#      for file in  ; do 
-       export GIT_WORK_TREE="$PWD"
-           git add "$@"
-#      done
+       git config core.worktree ../../
+       git config status.showUntrackedFiles no
+       export GIT_WORK_TREE="$LOCAL_REPO/../../"
+       git add "$@"
        git commit -m "initial checkin"
        git push --all
        
        trap - 0
-       cat <<END >> $MRCONFIG
 
-[$LOCAL_REPO]
-checkout = git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '../../'
-END
+       mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'"
     fi
 
 }
@@ -232,19 +250,28 @@ case "$command" in
        init $@
        ;;
     add)
-        add $@
+       add $@
        ;;
     new)
-        new $@
+       new $@
        ;;
     login)
-        login $@
+       login $@
+       ;;
+    exec)
+       execin "$@"
        ;;
     ls)
-        list
+       list
        ;;
     list)
-        list
+       list
+       ;;
+    ls-r)
+       listremote
+       ;;
+    list-remote)
+       listremote
        ;;
 
     *)