diff --git a/hooks/prepare-commit-msg b/hooks/prepare-commit-msg index 6ade9aab2d4..d5bf5171b59 100755 --- a/hooks/prepare-commit-msg +++ b/hooks/prepare-commit-msg @@ -2,7 +2,7 @@ errors=0 for file in $(git diff --cached --name-only | grep "\.go"); do - diff="$(gofmt -d "${file}")" + diff="$(git show ":${file}" | gofmt -d)" if [[ -n "$diff" ]]; then echo "# *** ERROR: *** File ${file} has not been gofmt'd." >> $1 errors=1