Apologies if this is stating the obvious, but if there's nothing to push, you won't get any lines on stdin. The sample .git/hooks/pre-push.sample
has a while loop:
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
...
done
and that appears to work when I try it here with an echo inside that loop and nothing else - I get nothing when I have nothing to push, and output when I do.