git p4 submit fails

I figured it out. The issue is caused by the line endings. I retested the problem with a different file and in this case, the error is caused by the line endings of the file checked out in the perforce workspace being win-style crlf, and the line endings of the file in the git repo being unix style lf.

In this case, I checked out the file in perforce, ran dos2unix against it, and submitted that, then ran git p4 submit and it worked.

That's not the real solution. That's just workaround. I sent an e-mail to git's mailing list, asking for a fix. http://marc.info/?l=git&m=136630231402536&w=2


For me submitting worked after I set git config apply.ignorewhitespace change.

I think the error occurs because the git core.whitespace setting is restrictive per default:

The ones that are turned on by default are blank-at-eol, which looks for spaces at the end of a line; blank-at-eof, which notices blank lines at the end of a file; and space-before-tab, which looks for spaces before tabs at the beginning of a line.

(see http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)

Setting apply.ignorewhitespace change allows git apply to fix these errors. Changing the core.whitespace setting to be less restrictive should also fix the problem, but I have not tried this.