]> git.madduck.net Git - code/vcsh.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

vcsh: Add support for choosing relative or absolute core.worktree
authorRichard Hartmann <richih@debian.org>
Mon, 2 Sep 2013 22:51:14 +0000 (00:51 +0200)
committerRichard Hartmann <richih@debian.org>
Mon, 2 Sep 2013 22:51:14 +0000 (00:51 +0200)
doc/vcsh.1.ronn
vcsh

index 89ebff5a161a60eb8a1b2857259392a7addf1133..56df4ed26e74cdbb7a4109056b8415570843d846 100644 (file)
@@ -184,6 +184,15 @@ Interesting knobs you can turn:
 
   Defaults to <exact>.
 
 
   Defaults to <exact>.
 
+* <$VCSH_VCSH_WORKTREE>:
+  Can be <absolute>, or <relative>.
+
+  <absolute> will set an absolute path; defaulting to <$HOME>.
+
+  <relative> will set a path relative to <$GIT_DIR>.
+
+  Defaults to <absolute>.
+
 Less interesting knobs you could turn:
 
 * <$VCSH_DEBUG>:
 Less interesting knobs you could turn:
 
 * <$VCSH_DEBUG>:
diff --git a/vcsh b/vcsh
index 60fcd99f17ee0b0d0ef5523567daf5a3cb34d1ed..d1283e4e3e8bc3bc9bbf9ba4962ca8ec4fd5ee81 100755 (executable)
--- a/vcsh
+++ b/vcsh
@@ -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_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() {
 
 
 help() {
@@ -313,8 +318,13 @@ upgrade() {
        # because otherwise Git complains "fatal: core.bare and core.worktree
        # do not make sense"
        git config core.bare false
        # 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
        [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME"
        git config vcsh.vcsh         'true'
        use