From 5f06c19c5512783068125d7fd5ca8438269902a2 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Sat, 27 Apr 2019 15:04:27 -0700 Subject: [PATCH] filter-repo: ensure we properly quote a filename When we invoked the 'ls' command of fast-import, we just passed the filename as-is. That will work for most filenames, but some have to be quoted. Make sure we do so. Signed-off-by: Elijah Newren --- git-filter-repo | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-filter-repo b/git-filter-repo index 7613dc4..a24abd8 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1311,11 +1311,12 @@ class FastExportFilter(object): # buffers filling up so I instead read from it as I go. for change in commit.file_changes: parent = new_1st_parent or commit.parents[0] # exists due to above checks - self._output.write("ls :{} {}\n".format(parent, change.filename)) + quoted_filename = PathQuoting.enquote(change.filename) + self._output.write("ls :{} {}\n".format(parent, quoted_filename)) self._output.flush() parent_version = fi_output.readline().split() if change.type == 'D': - if parent_version != ['missing', change.filename]: + if parent_version != ['missing', quoted_filename]: return False else: blob_sha = change.blob_id @@ -1323,7 +1324,7 @@ class FastExportFilter(object): self._output.write("get-mark :{}\n".format(change.blob_id)) self._output.flush() blob_sha = fi_output.readline().rstrip() - if parent_version != [change.mode, 'blob', blob_sha, change.filename]: + if parent_version != [change.mode, 'blob', blob_sha, quoted_filename]: return False return True