-use() {
- verbose "use() begin"
- if [ ! -d "$GIT_DIR" ]; then
- error "no repository found for '$VCSH_REPO_NAME'"
- return 12
- fi
- export GIT_DIR
- export GIT_WORK_TREE="$(git config --get core.worktree)"
- export VCSH_DIRECTORY="$VCSH_REPO_NAME"
- verbose "use() end"
-}
-
-
-if [ "$1" = 'clone' ]; then
- export VCSH_COMMAND="$1"
- GIT_REMOTE="$2"
- export GIT_REMOTE
- VCSH_REPO_NAME="$3"
- [ -z "$VCSH_REPO_NAME" ] && VCSH_REPO_NAME=$(basename "$GIT_REMOTE" .git)
- export VCSH_REPO_NAME
- export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git"
-elif [ "$1" = 'delete' ] ||
- [ "$1" = 'enter' ] ||
- [ "$1" = 'init' ] ||
- [ "$1" = 'run' ] ||
- [ "$1" = 'seed-gitignore' ] ||
- [ "$1" = 'setup' ]; then
- [ -z $2 ] && fatal "$1: please specify repository to work on" 1
- export VCSH_COMMAND="$1"
- export VCSH_REPO_NAME="$2"
- export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git"
- shift 2
- export VCSH_EXTERNAL_COMMAND="$*"
- if [ "$VCSH_COMMAND" = 'run' ]; then
- [ -z "$VCSH_EXTERNAL_COMMAND" ] && fatal "$1 $2: please specify a command" 1
- fi
-elif [ "$1" = 'help' ] ||
- [ "$1" = 'list' ]; then
- export VCSH_COMMAND="$1"
-else
- [ -z $1 ] && help && exit 0
- export VCSH_COMMAND='run'
- export VCSH_REPO_NAME="$1"
- export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git"
- [ -d $GIT_DIR ] || { help; exit 1; }
- shift 1
- export VCSH_EXTERNAL_COMMAND="git $*"
-fi
-
-
-for check_directory in "$VCSH_BASE" "$HOME/.gitignore.d"
-do
- if [ ! -d "$check_directory" ]; then
- if [ -e "$check_directory" ]; then
- fatal "$check_directory exists but is not a directory" 13
- else
- echo "$SELF: info: attempting to create $check_directory"
- mkdir -p "$check_directory" || fatal "could not create $check_directory" 50
- fi
- fi
-done
-
-
-if [ "$VCSH_COMMAND" = 'clone' ]; then
- verbose "clone begin"