]> 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:

Introduce config file and control over what goes into .gitignore/$foo
authorRichard Hartmann <richih.mailinglist@gmail.com>
Tue, 20 Dec 2011 23:34:31 +0000 (00:34 +0100)
committerRichard Hartmann <richih.mailinglist@gmail.com>
Mon, 26 Dec 2011 20:14:26 +0000 (21:14 +0100)
* configuration is in $XDG_CONFIG_HOME/vcsh/config
* $VCSH_GITIGNORE can be set to 'exact' or 'recursive'

vcsh

diff --git a/vcsh b/vcsh
index 990a234ce11828baf2b34e50bd9f5edf94a73f31..f7c565da62350d9c3f2d0fff0afda347d489434a 100755 (executable)
--- a/vcsh
+++ b/vcsh
@@ -6,10 +6,13 @@
 # license your code under the GNU GPL version 2 or later.
 
 
 # license your code under the GNU GPL version 2 or later.
 
 
-[ -n "$VCSH_DEBUG" ]      && set -vx
-[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
-[ -z "$VCSH_REPO_D" ]     && VCSH_REPO_D="$XDG_CONFIG_HOME/vcsh/repo.d"
-[ -z "$VCSH_BASE" ]       && VCSH_BASE="$HOME"
+[ -n "$VCSH_DEBUG" ]                  && set -vx
+[ -z "$XDG_CONFIG_HOME" ]             && XDG_CONFIG_HOME="$HOME/.config"
+[ -r "$XDG_CONFIG_HOME/vcsh/config" ] && . "$XDG_CONFIG_HOME/vcsh/config"
+[ -n "$VCSH_DEBUG" ]                  && set -vx
+[ -z "$VCSH_REPO_D" ]                 && VCSH_REPO_D="$XDG_CONFIG_HOME/vcsh/repo.d"
+[ -z "$VCSH_BASE" ]                   && VCSH_BASE="$HOME"
+[ -z "$VCSH_GITIGNORE" ]              && VCSH_GITIGNORE='exact'
 
 SELF=$(basename $0)
 
 
 SELF=$(basename $0)
 
@@ -179,7 +182,9 @@ write_gitignore() {
        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
        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
-               [ -d "$gitignore" ] && { echo "$gitignore/*" | sed 's/^/!/' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; }
+               if [ x$VCSH_GITIGNORE = x'recursive' ] && [ -d "$gitignore" ]; then
+                       { echo "$gitignore/*" | sed 's/^/!/' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; }
+               fi
        done
        if diff -N "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" > /dev/null; then
                rm -f "$tempfile" || error "could not delete '$tempfile'"
        done
        if diff -N "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" > /dev/null; then
                rm -f "$tempfile" || error "could not delete '$tempfile'"
@@ -194,6 +199,10 @@ write_gitignore() {
                fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53
 }
 
                fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53
 }
 
+if [ ! x$VCSH_GITIGNORE = x'exact' ] && [ ! x$VCSH_GITIGNORE = x'recursive' ]; then
+       fatal "\$VCSH_GITIGNORE must be either 'exact' or 'recursive'" 1
+fi
+
 if [ "$1" = 'clone' ]; then
        [ -z $2 ] && fatal "$1: please specify a remote" 1
        export VCSH_COMMAND="$1"
 if [ "$1" = 'clone' ]; then
        [ -z $2 ] && fatal "$1: please specify a remote" 1
        export VCSH_COMMAND="$1"