From c6f8f430d76e6186b46c9a76f6bb2ac1d2420fd7 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 29 Mar 2013 16:58:47 -0400 Subject: [PATCH] DEV: Handles empty stash case in pre-commit hook. Handles the case when reword is called and the `commit --amend` invokes the pre-commit hook, when there is no stash the `git stash pop -q` in that case leaves the rebase in an odd state. Fixes by only calling the stash pop if changes were saved. --- etc/git-hooks/pre-commit | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etc/git-hooks/pre-commit b/etc/git-hooks/pre-commit index c1d771cb..0c1d6b22 100755 --- a/etc/git-hooks/pre-commit +++ b/etc/git-hooks/pre-commit @@ -15,7 +15,7 @@ set -e # stash everything that wasn't just staged # so that we are only testing the staged code -git stash -q --keep-index +stash_result=$(git stash --keep-index) # Run flake8 linting flake8 zipline tests @@ -26,4 +26,8 @@ nosetests -x # N.B. this won't run if linting or unit tests fail # But if either fail, it's probably best to have only the offending # staged commits 'active', anyway. -git stash pop -q +stash_result=$(git stash --keep-index) +if [ "$stash_result" != "No local changes to save." ] +then + git stash pop -q +fi