hooks: rename sparse-checkout.sh to enable-sparse-checkout.sh
[config/vcsh.git] / .config / vcsh / hooks-available / enable-sparse-checkout.sh
diff --git a/.config/vcsh/hooks-available/enable-sparse-checkout.sh b/.config/vcsh/hooks-available/enable-sparse-checkout.sh
new file mode 100755 (executable)
index 0000000..2ebf5a5
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+# If the vcsh repository does not exist, exit without doing anything.
+[ -d "$GIT_DIR" ] || exit 0
+
+: "${XDG_CONFIG_HOME:="$HOME/.config"}"
+
+git config core.sparseCheckout true
+rm -f "$GIT_DIR/info/sparse-checkout"
+ln -s "$XDG_CONFIG_HOME/vcsh/sparse-checkout" "$GIT_DIR/info/sparse-checkout"