From: Richard Hartmann Date: Thu, 19 Sep 2013 21:41:27 +0000 (+0200) Subject: Merge branch 'feature--shortnames' X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/b32b489829142ea899ed50913fcff931ef051c27?hp=e98b51e220feeca897582e1dd879ebc76e5f6dfd Merge branch 'feature--shortnames' Conflicts: vcsh --- diff --git a/changelog b/changelog index 1f1d1e6..da31aec 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,17 @@ +2013-09-09 Richard Hartmann + + * Release 1.20130909 + * Add support for relative worktrees + +2013-08-29 Richard Hartmann + + * Release 1.20130829 + * Add support for `vcsh commit` + * Add support for `vcsh status ` + * Add pre-/post-init hooks + * Documentation improvements + * Minor cleanups + 2013-07-24 Richard Hartmann * Release 1.20130724 diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 89ebff5..56df4ed 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -184,6 +184,15 @@ Interesting knobs you can turn: Defaults to . +* <$VCSH_VCSH_WORKTREE>: + Can be , or . + + will set an absolute path; defaulting to <$HOME>. + + will set a path relative to <$GIT_DIR>. + + Defaults to . + Less interesting knobs you could turn: * <$VCSH_DEBUG>: diff --git a/vcsh b/vcsh index 3e2a6b6..ab58f3a 100755 --- a/vcsh +++ b/vcsh @@ -24,7 +24,7 @@ basename() { } SELF=$(basename $0) -VERSION='1.20130724' +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() { @@ -214,9 +223,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 +277,6 @@ push() { } retire() { - unset GIT_WORK_TREE unset VCSH_DIRECTORY } @@ -311,17 +318,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" } @@ -349,7 +365,11 @@ write_gitignore() { file="$new" done; done | sort -u) - tempfile=$(mktemp) || fatal "could not create tempfile" 51 + + # Contrary to GNU mktemp, mktemp on BSD/OSX requires a template for temp files + # Use the template GNU mktemo defaults to + tempfile=$(mktemp tmp.XXXXXXXXXX) || fatal "could not create tempfile" 51 + echo '*' > "$tempfile" || fatal "could not write to '$tempfile'" 57 for gitignore in $gitignores; do echo "$gitignore" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57 @@ -401,6 +421,7 @@ if [ "$VCSH_COMMAND" = 'clone' ]; then export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" + git version exit elif [ "$VCSH_COMMAND" = 'which' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a filename" 1