From: Antonio Ospite Date: Thu, 24 Jan 2019 14:54:48 +0000 (+0100) Subject: hooks: factor out an update-working-tree.sh script X-Git-Url: https://git.ao2.it/config/vcsh.git/commitdiff_plain/5afec708492bbba786c5b8ddd7715118cddcedba?ds=inline hooks: factor out an update-working-tree.sh script In some cases the working tree needs to be updated outside of populate-sparsely.sh (which is meant for a post-enter hook), so split out this task from the main script. --- diff --git a/.config/vcsh/hooks-available/populate-sparsely.sh b/.config/vcsh/hooks-available/populate-sparsely.sh index 937122a..cca8218 100755 --- a/.config/vcsh/hooks-available/populate-sparsely.sh +++ b/.config/vcsh/hooks-available/populate-sparsely.sh @@ -19,13 +19,8 @@ LOCKPID=$(cat "$LOCKDIR/pid") # shellcheck source=/dev/null . "$XDG_CONFIG_HOME/vcsh/hooks-available/enable-sparse-checkout.sh" -# Verify if the current branch is valid before updating the working tree. -# This avoids errors with empty repositories which would only confuse the -# user. -if git rev-parse --verify HEAD >/dev/null 2>&1; -then - git read-tree -mu HEAD -fi +# shellcheck source=/dev/null +. "$XDG_CONFIG_HOME/vcsh/hooks-available/update-working-tree.sh" # Unlock the working tree. rm -rf "$LOCKDIR" diff --git a/.config/vcsh/hooks-available/update-working-tree.sh b/.config/vcsh/hooks-available/update-working-tree.sh new file mode 100755 index 0000000..8d88e8c --- /dev/null +++ b/.config/vcsh/hooks-available/update-working-tree.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Verify if the current branch is valid before updating the working tree. +# This avoids errors with empty repositories which would only confuse the +# user. +if git rev-parse --verify HEAD >/dev/null 2>&1; +then + git read-tree -mu HEAD +fi +