From e6af4b9162352c9cad7a7d38aa80236b10d375a9 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 8 Mar 2023 10:10:00 +0100 Subject: Only stash and pop if the tree is dirty --- lib/subcommands/pull.bash | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/subcommands/pull.bash b/lib/subcommands/pull.bash index 4061f1b..42a51e1 100644 --- a/lib/subcommands/pull.bash +++ b/lib/subcommands/pull.bash @@ -6,10 +6,17 @@ subcommand() { + local dirty + notice "bashtard/pull" "Pulling latest changes in $BASHTARD_ETCDIR" - git -C "$BASHTARD_ETCDIR" stash + if ! git -C "$BASHTARD_ETCDIR" diff-index --quiet HEAD -- + then + dirty=1 + fi + + [[ -n $dirty ]] && git -C "$BASHTARD_ETCDIR" stash git -C "$BASHTARD_ETCDIR" pull origin master || return 4 git -C "$BASHTARD_ETCDIR" submodule update --recursive --remote || return 4 - git -C "$BASHTARD_ETCDIR" stash pop + [[ -n $dirty ]] && git -C "$BASHTARD_ETCDIR" stash pop } -- cgit v1.1