devshell: stash only unstaged changes in pre-commit hook
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
teutat3s 2023-07-04 01:34:01 +02:00
parent 1d4b86830e
commit e26af156c6
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1

View file

@ -14,8 +14,12 @@ fi
# https://overflow.hostux.net/questions/7650797/how-to-stash-only-unstaged-changes-in-git#60875082
old_stash=$(git rev-parse --quiet --verify refs/stash)
git stash push --quiet --staged --message "Staged changes before pre-commit hook"
git stash push --quiet --keep-index --message "Unstaged changes before pre-commit hook"
git stash push --quiet --message "Unstaged changes before pre-commit hook"
if git stash show "stash@{1}" 2>/dev/null; then
git stash pop --quiet --index "stash@{1}"
else
git stash pop --quiet --index "stash@{0}"
fi
new_stash=$(git rev-parse --quiet --verify refs/stash)
diff="git diff-index --name-only --cached $against --diff-filter d"