echo "$SELF: info: $1"
}
-clone () {
+clone() {
init
git remote add origin "$GIT_REMOTE"
git config branch.master.remote origin
git merge origin/master
}
-delete () {
+delete() {
old_dir="$PWD"
cd "$HOME"
- use || exit $?
+ use
info "This operation WILL DETROY DATA!"
files=$(git ls-files)
echo "These files will be deleted:
cd "$old_dir"
}
-enter () {
- use || exit $?
+enter() {
+ use
$SHELL
}
setup
}
-list () {
+list() {
for i in "$VCSH_BASE"/*.git; do
echo $(basename "$i" .git)
done
}
-run () {
- use || exit $?
+run() {
+ use
$VCSH_EXTERNAL_COMMAND
}
-seed_gitignore () {
- use || exit $?
+seed_gitignore() {
+ use
# Switching directory as this has to be executed from $HOME to be of any use.
# Going back into old directory at the end in case `vcsh use` is reactivated.
old_dir="$PWD"
use() {
if [ ! -d "$GIT_DIR" ]; then
- error "no repository found for '$VCSH_REPO_NAME'"
- return 12
+ fatal "no repository found for '$VCSH_REPO_NAME'" 12
fi
export GIT_WORK_TREE="$(git config --get core.worktree)"
export VCSH_DIRECTORY="$VCSH_REPO_NAME"
export VCSH_COMMAND="$1"
export VCSH_REPO_NAME="$2"
export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git"
- [ "$1" = 'run' ] && shift 2 && export VCSH_EXTERNAL_COMMAND="$@"
- [ "$1" = 'seed-gitignore' ] && export VCSH_COMMAND=seed_gitignore
+ [ "$VCSH_COMMAND" = 'run' ] && shift 2 && export VCSH_EXTERNAL_COMMAND="$@"
+ [ "$VCSH_COMMAND" = 'seed-gitignore' ] && export VCSH_COMMAND='seed_gitignore'
elif [ "$1" = 'list' ]; then
export VCSH_COMMAND="$1"
elif [ -n "$1" ]; then