X-Git-Url: https://git.madduck.net/code/vcsh.git/blobdiff_plain/4424028c0faa46b809fff726c8ec3d96a8e34d32..663af6efe8d81d4386127b8fbd05320f44988658:/vcsh?ds=inline diff --git a/vcsh b/vcsh index b5e703e..cb9f216 100755 --- a/vcsh +++ b/vcsh @@ -44,18 +44,6 @@ verbose() { if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$SELF: verbose: $@"; fi } -use() { - verbose "use() begin" - if [ ! -d "$GIT_DIR" ]; then - echo E: no repository found for "$VCSH_REPO_NAME" >&2 - return 1 - fi - export GIT_DIR - export GIT_WORK_TREE="$(git config --get core.worktree)" - export VCSH_DIRECTORY="$VCSH_REPO_NAME" - verbose "use() end" -} - init() { verbose "init() begin" [ -e "$GIT_DIR" ] && @@ -81,8 +69,21 @@ leave() { unset VCSH_DIRECTORY } +use() { + verbose "use() begin" + if [ ! -d "$GIT_DIR" ]; then + echo E: no repository found for "$VCSH_REPO_NAME" >&2 + return 1 + 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"