diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 4ec9548cf344b7238006941092e04564ca8a2b1c..7ebf9f5d77cccdaf82804f88c25ce73dd0f2c6cd 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -151,14 +151,16 @@ executed in the context of your shell. Interesting knobs you can turn: * <$VCSH_GITIGNORE>: - Can be either <exact> or <recursive>. + Can be <exact>, <recursive>, or <none>. - <exact> will seed the repo-specific <.gitignore> with all file and directory + <exact> will seed the repo-specific ignore file with all file and directory names which `git ls-files` returns. <recursive> will descend through all directories recursively additionally to the above. + <none> will not write any ignore file. + Defaults to <exact>. Less interesting knobs you could turn: diff --git a/vcsh b/vcsh index 7a0f7120171efa714ba3d413f00718bc20d57eed..f1f50def85502ff90d21f0d1b0f6ae1e380cb15d 100755 --- a/vcsh +++ b/vcsh @@ -238,7 +238,7 @@ upgrade() { hook pre-upgrade use git config core.worktree "$GIT_WORK_TREE" - git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" + [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" git config vcsh.vcsh 'true' [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" hook post-upgrade @@ -259,6 +259,12 @@ which() { } write_gitignore() { + # Don't do anything if the user does not want to write gitignore + if [ "x$VCSH_GITIGNORE" = 'xnone' ] then + info "Not writing gitignore as '\$VCSH_GITIGNORE' is set to 'none'" + exit + fi + use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 gitignores=$(for file in $(git ls-files); do @@ -272,7 +278,7 @@ 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 - if [ x$VCSH_GITIGNORE = x'recursive' ] && [ -d "$gitignore" ]; then + if [ "x$VCSH_GITIGNORE" = 'xrecursive' ] && [ -d "$gitignore" ]; then { echo "$gitignore/*" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; } fi done @@ -289,8 +295,8 @@ write_gitignore() { fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53 } -if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then - fatal "'\$VCSH_GITIGNORE' must be either 'exact' or 'recursive'" 1 +if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ]; then + fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'recursive', or 'none'" 1 fi if [ "$1" = 'clone' ]; then