X-Git-Url: https://git.madduck.net/code/vcsh.git/blobdiff_plain/6927829eb87b6abbe8b9cdee346624c73aecb512..09f129a260f5347219b8ac84c6f2204fa2b0d9a6:/vcsh diff --git a/vcsh b/vcsh index 60fcd99..508c087 100755 --- a/vcsh +++ b/vcsh @@ -24,7 +24,7 @@ basename() { } SELF=$(basename $0) -VERSION='1.20130829' +VERSION='1.20130909' fatal() { echo "$SELF: fatal: $1" >&2 @@ -81,6 +81,15 @@ fi [ -z "$VCSH_HOOK_D" ] && VCSH_HOOK_D="$XDG_CONFIG_HOME/vcsh/hooks-enabled" [ -z "$VCSH_BASE" ] && VCSH_BASE="$HOME" [ -z "$VCSH_GITIGNORE" ] && VCSH_GITIGNORE='exact' +[ -z "$VCSH_WORKTREE" ] && VCSH_WORKTREE='absolute' + +if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then + fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 +fi + +if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ] && [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then + fatal "'\$VCSH_WORKTREE' must equal 'absolute', or 'relative'" 1 +fi help() { @@ -313,8 +322,13 @@ upgrade() { # because otherwise Git complains "fatal: core.bare and core.worktree # do not make sense" git config core.bare false - # in core.worktree, keep a relative reference to the base directory - git config core.worktree $(cd $GIT_DIR && GIT_WORK_TREE="$VCSH_BASE" git rev-parse --show-cdup) + # core.worktree may be absolute or relative to $GIT_DIR, depending on + # user preference + if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ]; then + git config core.worktree $(cd $GIT_DIR && GIT_WORK_TREE="$VCSH_BASE" git rev-parse --show-cdup) + elif [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then + git config core.worktree "$VCSH_BASE" + fi [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" git config vcsh.vcsh 'true' use @@ -372,10 +386,6 @@ write_gitignore() { fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53 } -if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then - fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 -fi - if [ "$1" = 'clone' ]; then [ -z "$2" ] && fatal "$1: please specify a remote" 1 export VCSH_COMMAND="$1"