git-apply: do not read past the end of buffer