diff options
author | Patrick Spek <p.spek@tyil.nl> | 2023-03-08 10:10:00 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-03-08 10:10:00 +0100 |
commit | e6af4b9162352c9cad7a7d38aa80236b10d375a9 (patch) | |
tree | b1b15e71d2698a3a120a173463e759995c64b2e8 | |
parent | fdef03a6176461256ad2b165008131d63582add9 (diff) |
Only stash and pop if the tree is dirty
-rw-r--r-- | lib/subcommands/pull.bash | 11 |
1 files 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 } |