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

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:

Merge remote-tracking branch 'andschwa/docs'
[code/vcsh.git] / vcsh
diff --git a/vcsh b/vcsh
index 068c61817dc5a08e371e0802fecb028730352cf2..d39f41581da5ab93442e7073bd6eb3189730d571 100755 (executable)
--- a/vcsh
+++ b/vcsh
@@ -19,7 +19,7 @@
 # If '.git-HEAD' is appended to the version, you are seeing an unreleased
 # version of vcsh; the master branch is supposed to be clean at all times
 # so you can most likely just use it nonetheless
-VERSION='1.20131229.git-HEAD'
+VERSION='1.20140313'
 SELF=$(basename $0)
 
 fatal() {
@@ -74,9 +74,10 @@ fi
 
 # Read defaults
 : ${VCSH_REPO_D:=$XDG_CONFIG_HOME/vcsh/repo.d}
-: ${VCSH_HOOK_D:=$XDH_CONFIG_HOME/vcsh/hooks-enabled}
+: ${VCSH_HOOK_D:=$XDG_CONFIG_HOME/vcsh/hooks-enabled}
 : ${VCSH_BASE:=$HOME}
 : ${VCSH_GITIGNORE:=exact}
+: ${VCSH_GITATTRIBUTES:=none}
 : ${VCSH_WORKTREE:=absolute}
 
 if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then
@@ -224,7 +225,7 @@ init() {
        [ ! -e "$GIT_DIR" ] || fatal "'$GIT_DIR' exists" 10
        mkdir -p "$VCSH_BASE" || fatal "could not create '$VCSH_BASE'" 50
        cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11
-       git init
+       git init --shared=0600
        upgrade
        hook post-init
 }
@@ -334,9 +335,11 @@ upgrade() {
                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'
+       [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile ".gitattributes.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"
+       [ -e "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME"
        hook post-upgrade
 }
 
@@ -362,6 +365,8 @@ write_gitignore() {
 
        use
        cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11
+       OLDIFS="$IFS"
+       IFS=$(printf '\n\t')
        gitignores=$(for file in $(git ls-files); do
                while true; do
                        echo $file; new="${file%/*}"
@@ -382,6 +387,7 @@ write_gitignore() {
                        { echo "$gitignore/*" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; }
                fi
        done
+       IFS="$OLDIFS"
        if diff -N "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" > /dev/null; then
                rm -f "$tempfile" || error "could not delete '$tempfile'"
                exit
@@ -395,7 +401,7 @@ write_gitignore() {
                fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53
 }
 
-debug `git version`
+debug $(git version)
 
 if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then
        fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1
@@ -498,6 +504,7 @@ check_dir() {
 
 check_dir "$VCSH_REPO_D"
 [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && check_dir "$VCSH_BASE/.gitignore.d"
+[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && check_dir "$VCSH_BASE/.gitattributes.d"
 
 verbose "$VCSH_COMMAND begin"
 export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g')