Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make path to .gitignore.d and .gitattributes.d configurable #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions vcsh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ fi
: ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"}
: ${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"}
: ${VCSH_BASE:="$HOME"}
: ${VCSH_GITIGNORE_D:="$VCSH_BASE/.gitignore.d"}
: ${VCSH_GITATTRIBUTES_D:="$VCSH_BASE/.gitattributes.d"}
: ${VCSH_GITIGNORE:=exact}
: ${VCSH_GITATTRIBUTES:=none}
: ${VCSH_WORKTREE:=absolute}
Expand Down Expand Up @@ -442,12 +444,12 @@ upgrade() {
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"
[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME"
[ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME"
[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile "$VCSH_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"
[ -e "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME" ] && git add -f "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME"
[ -e "$VCSH_GITATTRIBUTES_D/$VCSH_REPO_NAME" ] && git add -f "$VCSH_GITATTRIBUTES_D/$VCSH_REPO_NAME"
hook post-upgrade
}

Expand Down Expand Up @@ -506,17 +508,17 @@ write_gitignore() {
fi
done
IFS=$OLDIFS
if diff -N "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" > /dev/null; then
if diff -N "$tempfile" "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME" > /dev/null; then
rm -f "$tempfile" || error "could not delete '$tempfile'"
exit
fi
if [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ]; then
info "'$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME' differs from new data, moving it to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME.bak'"
mv -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME.bak" ||
fatal "could not move '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME.bak'" 53
if [ -e "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME" ]; then
info "'$VCSH_GITIGNORE_D/$VCSH_REPO_NAME' differs from new data, moving it to '$VCSH_GITIGNORE_D/$VCSH_REPO_NAME.bak'"
mv -f "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME" "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME.bak" ||
fatal "could not move '$VCSH_GITIGNORE_D/$VCSH_REPO_NAME' to '$VCSH_GITIGNORE_D/$VCSH_REPO_NAME.bak'" 53
fi
mv -f "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ||
fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53
mv -f "$tempfile" "$VCSH_GITIGNORE_D/$VCSH_REPO_NAME" ||
fatal "could not move '$tempfile' to '$VCSH_GITIGNORE_D/$VCSH_REPO_NAME'" 53
}

debug $(git version)
Expand Down Expand Up @@ -646,8 +648,8 @@ 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"
[ ! "x$VCSH_GITIGNORE" = 'xnone' ] && check_dir "$VCSH_GITIGNORE_D"
[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && check_dir "$VCSH_GITATTRIBUTES_D"

verbose "$VCSH_COMMAND begin"
VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND
Expand Down