felipec / git-remote-bzr

Transparent bidirectional bridge between Git and Bazaar for Git
GNU General Public License v2.0
75 stars 17 forks source link

carriage return in git commit message causes push to bzr to fail #23

Closed zmanuel closed 5 years ago

zmanuel commented 5 years ago

Windows line endings (\r\n) are fine, they are probably filtered by bzrlib itself at some point, but a plain \r makes it through and causes an exception:

23:53 $ git push
Traceback (most recent call last):
  File "/home/manuel/bin/git-remote-bzr", line 1022, in <module>
    sys.exit(main(sys.argv))
  File "/home/manuel/bin/git-remote-bzr", line 1008, in main
    do_export(parser)
  File "/home/manuel/bin/git-remote-bzr", line 708, in do_export
    parse_commit(parser)
  File "/home/manuel/bin/git-remote-bzr", line 676, in parse_commit
    builder.commit(data.decode('utf-8', 'replace'))
  File "/usr/lib/python2.7/dist-packages/bzrlib/vf_repository.py", line 193, in commit
    self._validate_unicode_text(message, 'commit message')
  File "/usr/lib/python2.7/dist-packages/bzrlib/repository.py", line 142, in _validate_unicode_text
    raise ValueError('Invalid value for %s: %r' % (context, text))
ValueError: Invalid value for commit message: u'four\rno, three'
error: failed to push some refs to 'bzr::/alt/home/nocrypt/manuel/Tron/git/git-remote-bzr/test/trash directory.main/bzrrepo'

PR #22 contains the test that produces the above error and a fix; \r's are just filtered out.

Offending commits in the wild are for example in https://github.com/godotengine/godot, I lost the precise commit :( I can dig it up again if needed.

felipec commented 5 years ago

Should be fixed now.