Trying to add file to the root of the branch fails with following error: Added Fast Import crash Report
git filter-repo --force --commit-callback "if not commit.parents: commit.file_changes.append(FileChange(b'M', 'C:\MDC\MDC.7z', '$(git hash-object -w 'C:\MDC\MDC.7z')', 100644))"
Traceback (most recent call last):
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 3840, in <module>
filter.run()
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 3777, in run
self._parser.run(self._input, self._output)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 1396, in run
self._parse_commit()
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 1249, in _parse_commit
self._commit_callback(commit, aux_info)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 3334, in _tweak_commit
self._insert_into_stream(commit)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 3752, in _insert_into_stream
self._parser.insert(obj)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 1374, in insert
obj.dump(self._output)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 702, in dump
change.dump(file_)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 599, in dump
quoted_filename = PathQuoting.enquote(self.filename)
File "C:/Program Files/Git/mingw64/libexec/git-core\git-filter-repo", line 190, in enquote
if unquoted_string.startswith(b'"') or b'\n' in unquoted_string:
TypeError: startswith first arg must be str or a tuple of str, not bytes
fatal: stream ends early
fast-import: dumping crash report to .git/fast_import_crash_14772
fast-import crash report: https://pastebin.com/DKrz883c
Windows 10
Git Version 2.24
It seems that self.filename
is unicode and enquote
works with bytes.
I don't know enough about internals of git-filter-repo
. May be 'C:\MDC\MDC.7z'
should be bytes: b'C:\MDC\MDC.7z'
. Or maybe it's a bug; I recommend to report this at their issue tracker.
In Python3 unicode and byte strings are incompatible. See:
$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> u'test'.startswith('"')
False
>>> u'test'.startswith(b'"')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: startswith first arg must be str or a tuple of str, not bytes
>>> b'test'.startswith('"')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
>>> b'test'.startswith(b'"')
False