From 5afec708492bbba786c5b8ddd7715118cddcedba Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Thu, 24 Jan 2019 15:54:48 +0100 Subject: [PATCH] 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. --- .config/vcsh/hooks-available/populate-sparsely.sh | 9 ++------- .config/vcsh/hooks-available/update-working-tree.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100755 .config/vcsh/hooks-available/update-working-tree.sh 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 + -- 2.1.4