From ccf035efa66c3e899d74cbf82124402dc8066c6e Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 25 Oct 2008 12:40:12 +0200 Subject: [PATCH] Use current Zit or Git dir for exclude file We put the generic exclude file in $ZIT_DIR, if it's present, or in $GIT_DIR otherwise. This solution is more robust than the previous one relying on ~/.zitignore, since it doesn't set the config up with absolute paths, and it's also cleaner as it doesn't create files outside of the Zit/Git dirs. The diskspace saving is not as strong, since we still need at least one exclude file per directory with tracked content, but it's still at least one block cheaper than using the standard per-repo exclude file .git/info/exclude, since we go for .somefile.git/exclude in the worst case. --- zit | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/zit b/zit index dc40855..06fc3b4 100755 --- a/zit +++ b/zit @@ -66,15 +66,20 @@ zit_init() { test -d $GIT_DIR || abort "Failed to create $GIT_DIR" git init || abort "Failed to initialize Git repository in $GIT_DIR" rm -rf $GIT_DIR/{hooks,info,branches,refs/tags,objects/pack,description} - ZIT_IGNORE="$HOME/.zitignore" - if ! test -f "$ZIT_IGNORE"; then - touch "$ZIT_IGNORE" || abort "Cannot create $ZIT_IGNORE file" - echo "# Ignore patterns used by Zit repositories" > "$ZIT_IGNORE" - echo "# By default it's the single '*' glob, since we want to ignore all" >> $ZIT_IGNORE - echo "# non-tracked files in the work-tree" >> $ZIT_IGNORE - echo "*" >> $ZIT_IGNORE + if test -d "$ZIT_DIR"; then + ZIT_EXCLUDE="$ZIT_DIR/exclude" + else + ZIT_EXCLUDE="$GIT_DIR/exclude" + fi + if ! test -f "$ZIT_EXCLUDE"; then + touch "$ZIT_EXCLUDE" || abort "Cannot create $ZIT_EXCLUDE file" + echo "# Ignore patterns used by Zit repositories in the parent worktree." > "$ZIT_EXCLUDE" + echo "# By default it's the single '*' glob, since we want to ignore all" >> "$ZIT_EXCLUDE" + echo "# non-tracked files in the work-tree." >> "$ZIT_EXCLUDE" + echo "# This file is autogenerated and there's usually no need to edit it." >> "$ZIT_EXCLUDE" + echo "*" >> "$ZIT_EXCLUDE" fi - git config core.excludesfile "$ZIT_IGNORE" + git config core.excludesfile "$ZIT_EXCLUDE" git add -f $ZIT_FILE || abort "Failed to add $ZIT_FILE" git commit "$@" || abort "Failed to make first commit for $ZIT_FILE" else -- 2.32.0.93.g670b81a890