X-Git-Url: https://git.madduck.net/code/vcsh.git/blobdiff_plain/738f3a10cd747b77e64e8a3240e1e124ce276d49..a14137fd1d5f5ee32d38d5529d5e7bb471e97fb3:/vcsh diff --git a/vcsh b/vcsh index 9bef842..d1283e4 100755 --- a/vcsh +++ b/vcsh @@ -24,7 +24,7 @@ basename() { } SELF=$(basename $0) -VERSION='1.20130724' +VERSION='1.20130829' fatal() { echo "$SELF: fatal: $1" >&2 @@ -81,6 +81,11 @@ 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_WORKTREE" = 'xabsolute' ] && [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then + fatal "'\$VCSH_WORKTREE' must equal 'absolute', or 'relative'" 1 +fi help() { @@ -214,9 +219,8 @@ hook() { init() { hook pre-init [ ! -e "$GIT_DIR" ] || fatal "'$GIT_DIR' exists" 10 - export GIT_WORK_TREE="$VCSH_BASE" - mkdir -p "$GIT_WORK_TREE" || fatal "could not create '$GIT_WORK_TREE'" 50 - cd "$GIT_WORK_TREE" || fatal "could not enter '$GIT_WORK_TREE'" 11 + mkdir -p "$VCSH_BASE" || fatal "could not create '$VCSH_BASE'" 50 + cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 git init upgrade hook post-init @@ -269,7 +273,6 @@ push() { } retire() { - unset GIT_WORK_TREE unset VCSH_DIRECTORY } @@ -311,17 +314,26 @@ status() { upgrade() { hook pre-upgrade - use - git config core.worktree "$GIT_WORK_TREE" + # fake-bare repositories are not bare, actually. Set this to false + # because otherwise Git complains "fatal: core.bare and core.worktree + # do not make sense" + git config core.bare false + # 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 [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" hook post-upgrade } use() { git_dir_exists - export GIT_WORK_TREE="$(git config --get core.worktree)" export VCSH_DIRECTORY="$VCSH_REPO_NAME" }