From 2136eba343c8c4a6d61f4ca4a59cfe01f30813f0 Mon Sep 17 00:00:00 2001 From: Anton Tsviatkou Date: Wed, 13 Jul 2016 20:21:06 -0700 Subject: [PATCH] Allow to exclude symlinking of files base on git exclude patterns HOMESHICK_IGNORE environment variable with comma-separated exclude patterns will add entries to .git/info/exclude Excluded files will be ignored during symlink step, but still can be checked into the repository --- lib/commands/clone.sh | 1 + lib/commands/link.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/commands/clone.sh b/lib/commands/clone.sh index 6a1d1327..00b6ad02 100644 --- a/lib/commands/clone.sh +++ b/lib/commands/clone.sh @@ -34,6 +34,7 @@ function clone { success fi [ -n "$HOMESHICK_USE_CASTLE_ROOT" ] && set_castle_root_mode "$cloned_castle_name" + [ -n "$HOMESHICK_IGNORE" ] && echo "$HOMESHICK_IGNORE" | tr ',' '\n' >> "$repo_path/.git/info/exclude" return $EX_SUCCESS } diff --git a/lib/commands/link.sh b/lib/commands/link.sh index 4adf7d86..63f83ee8 100644 --- a/lib/commands/link.sh +++ b/lib/commands/link.sh @@ -98,6 +98,8 @@ function get_repo_files { # (used when there are newlines in the path) path=${path/#\"/} path=${path/%\"/} + local excluded=$(cd "$root" && git ls-files -i --exclude-from=.git/info/exclude "$path") + [ -n "$excluded" ] && continue; if [ -n "$search" ];then # Check if home/ is a submodule [[ $path == 'home' ]] && continue