From b3887309819d1c3c1a80d6d102084d6d1f263ec3 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 17 Nov 2011 21:31:03 -0500 Subject: [PATCH] Support repository names with / in them (e.g., "etc/vim") Signed-off-by: James McCoy --- movein | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/movein b/movein index e2d0e90..04905c1 100755 --- a/movein +++ b/movein @@ -159,6 +159,17 @@ EOF } +git_work_tree() { + local TEMP_REPO + TEMP_REPO=$1 + GIT_WORK_TREE=../../ + + while [ "${TEMP_REPO#*/}" != "$TEMP_REPO" ]; do + TEMP_REPO="${TEMP_REPO#*/}" + GIT_WORK_TREE="../$GIT_WORK_TREE" + done +} + login() { if [ $# -ne 1 ]; then usage @@ -199,30 +210,31 @@ add() { exit 1 else trap "unset GIT_DIR; unset GIT_WORK_TREE; rm -rf $LOCAL_REPO" 0 - mkdir "$LOCAL_REPO" + mkdir -p "$LOCAL_REPO" export GIT_DIR="$LOCAL_REPO" + git_work_tree "$REPO_NAME" git init --bare git remote add origin $REPO_URL git config branch.master.remote origin git config branch.master.merge refs/heads/master git config core.bare false - git config core.worktree ../../ + git config core.worktree "$GIT_WORK_TREE" git config status.showUntrackedFiles no - GIT_WORK_TREE="$LOCAL_REPO/../../" git pull + git pull trap - 0 - mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' 'REPO_NAME' '../../'" + mr -c "$MRCONFIG" config "$LOCAL_REPO" checkout="git_fake_bare_checkout '$REPO_URL' '$REPO_NAME' '$GIT_WORK_TREE'" fi done } list() { - find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,' + find "${LOCAL_REPOS}" -mindepth 1 -type d -name '*.git' | sed "s,${LOCAL_REPOS}/,," } listremote() { ssh $GIT_HOST " - find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,' + find '${REMOTE_REPOS}' -mindepth 1 -type d -name '*.git' | sed 's,${REMOTE_REPOS}/,,' "