newren / git-filter-repo

Quickly rewrite git repository history (filter-branch replacement)
Other
8.52k stars 708 forks source link

replace-text-limited-to-certain-files: `TypeError: %d format: a real number is required, not bytes` #468

Closed andry81 closed 3 days ago

andry81 commented 1 year ago

I am trying to use replace-text-limited-to-certain-files branch to use --replace-text-filename-callback option.

Steps to install:

  1. python -m pip install git-filter-repo
  2. copy git-filter-repo into Scripts python directory and rename to git-filter-repo-replace-text
  3. replace shebang line to #!/usr/bin/env python

Shell code:

SOURCETREE_PATH_FILE=README.md

git-filter-repo-replace-text --replace-text-filename-callback \
'import os
source_tree_file = os.environ["SOURCETREE_PATH_FILE"]
return True if source_tree_file == filename else False
' --replace-text "<p/>==></p>" --refs t1~1..master

The code throws an error:

Traceback (most recent call last):
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 4016, in <module>
    filter.run()
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 3947, in run
    self._parser.run(self._input, self._output)
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 1414, in run
    self._parse_commit()
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 1267, in _parse_commit
    self._commit_callback(commit, aux_info)
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 3500, in _tweak_commit
    if not self._prunable(commit, new_1st_parent,
  File "C:\Python\x64\310\Scripts\git-filter-repo-replace-text", line 3220, in _prunable
    self._output.write(b"ls :%d %s\n" % (parent, quoted_filename))
TypeError: %d format: a real number is required, not bytes
fatal: stream ends early
fast-import: dumping crash report to .git/fast_import_crash_3428
newren commented 3 days ago

The replace-text-limited-to-certain-files branch has been deleted. The new --file-info-callback added in commit 615720731589 (filter-repo: add a --file-info-callback, 2024-10-23) is much more general and obviates the need for the work on that branch.