Fix the git terminology by always referring to the "working tree"
[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 working tree fully populated is
6 # allowed to repopulate it sparsely.
7 LOCKDIR=/run/lock/vcsh
8 [ -d "$LOCKDIR" ] || exit 0
9
10 LOCKPID=$(cat "$LOCKDIR/pid")
11 # Use the parent pid because the hooks are launched as children of vcsh.
12 [ "$LOCKPID" = $PPID ] || { echo "Repository entered from another vcsh instance. Aborting." 1>&2; exit 1; }
13
14 : "${XDG_CONFIG_HOME:="$HOME/.config"}"
15 . "$XDG_CONFIG_HOME/vcsh/hooks-available/sparse-checkout.sh"
16 git read-tree -mu HEAD
17
18 # Unlock the working tree.
19 rm -rf "$LOCKDIR"