README: mention that the idea came from John Whitley
[config/vcsh.git] / .config / vcsh / hooks-available / populate-sparsely.sh
1 #!/bin/sh
2
3 set -e
4
5 # Only the same instance of vcsh that had the work dir fully populated is
6 # allowed to repopulate it sparsely.
7 LOCKDIR=/run/lock/vcsh
8 LOCKPID=$(cat "$LOCKDIR/pid")
9 # Use the parent pid because the hooks are launched as children of vcsh.
10 [ "$LOCKPID" = $PPID ] || { echo "Repository entered from another vcsh instance. Aborting." 1>&2; exit 1; }
11
12 : "${XDG_CONFIG_HOME:="$HOME/.config"}"
13 . "$XDG_CONFIG_HOME/vcsh/hooks-available/sparse-checkout.sh"
14 git read-tree -mu HEAD
15
16 # Unlock the work dir.
17 rm -rf "$LOCKDIR"